• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Counting specific unit / building and displaying it as text to player

Status
Not open for further replies.
Level 2
Joined
Aug 24, 2021
Messages
8
Hi All,

I am wondering if you can help me out with this.

i want to be able to have the game display as a text when they type something like "-count" to show the number of X building to them, so at any point of the game they can check how many they have. This number would obviously change as they build more or if they are killed


I worked it out how to do it in a leaderboard, but not for it to display as a text response

So i have the easy part complete with condition play type exact match -count and display to player 1, i just dont know how to do it without the leaderboard only count trigger.

any help would be great

thanks!
 
Last edited:
Level 12
Joined
Feb 5, 2018
Messages
522
Well assuming you set up all the variables for the building counting, this should be easy.

  • Building Count
    • Events
      • Player - Player 1 (Red) types a chat message containing -count as An exact match
      • Player - Player 2 (Blue) types a chat message containing -count as An exact match
      • Player - Player 3 (Teal) types a chat message containing -count as An exact match
    • Conditions
    • Actions
      • Set VariableSet PlayerCheck = (Triggering player)
      • -------- --------
      • Set VariableSet PlayerNumber = (Player number of PlayerCheck)
      • -------- --------
      • Game - Display to (Player group(PlayerCheck)) for 10.00 seconds the text: (String(Building_Count[PlayerNumber]))
Depending on how you set up your variables you might need to add conditions, but I strongly recommend using arrays. Or you can just use a bunch of if/then/else blocks. Hope this gets you started.

This variable Building_Count is an integer array variable. You can replace with your own variable.
Playercheck = player variable
PlayerNumber = integer variable
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,640
You can also add all of the buildings to a unit group temporarily. Then you can display the number of units in the group.
  • Actions
  • Set Variable TempGroup = Units owned by (Triggering player) matching Matching unit is a structure equal to True
  • Game - Display to (Player group(Triggering player) for 10.00 seconds the text: (String(Number of units in TempGroup))
  • Custom script: call DestroyGroup(udg_TempGroup)
 
Status
Not open for further replies.
Top