• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Chat Commands: -set VALUE action: change variable to VALUE

Status
Not open for further replies.
Level 5
Joined
Jun 5, 2009
Messages
121
Hi guys,

I have a problem with a Chat Command i try this now for like 2 hours ._.

How in the hell is it possible to do this in a trigger like:

Event: Player - Player 1 (Red) types a chat message containing (-set + X)
Action: set integer-variable to entered number

X should be any number i want

+rep for help

Greetings, Chris
 
Try this:

  • Test
    • Events
      • Player - Player 1 (Red) types a chat message containing -set as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 5)) Equal to (==) -set
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring((Entered chat string), 6, (Length of (Entered chat string)))) Equal to (==) 0
        • Then - Actions
          • Set integer = 0
          • Game - Display to (All players) the text: (Integer variable is set to: + 0)
          • -------- This if is just to make sure that the entered chat string is actually 0 instead of some text (explained in the next if) --------
        • Else - Actions
          • Set string = (Substring((Entered chat string), 6, (Length of (Entered chat string))))
          • Set integer = (Integer(string))
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • integer Equal to (==) 0
              • Then - Actions
                • Game - Display to (All players) the text: The entered value is not an integer number. Integer variable is set to 0.
                • -------- This is because whenever you convert a string that's not an integer to an integer it becomes 0... --------
              • Else - Actions
                • -------- Don't forget that if the entered chat message contains a real, it will be rounded down to an integer. --------
                • -------- So 10.9 will become 10, 10.3 will also become 10 etc... --------
                • Game - Display to (All players) the text: (Integer variable is set to: + (String(integer)))
The variable integer will be set to the integer that has been typed in.

Basically what you do here is: set variable string to the string that has been typed in after -set , then set the integer variable to a conversion of the variable string to an integer.
Then display a text message to all players by converting the integer variable back to a string.

Also: Don't forget that in the condition (Substring((Entered chat string), 1, 5)) Equal to (==) -set contains a spacebar after -set since it checks for 5 characters, not 4 :)

I also added a few conditions to check wether the entered chat string contains a integer number or text. Check the comments, it should be quite self-explenatory...
 
Last edited:
Simple Understanding of Substring((Entered chat string) , x , y )
Okay, for example you type "-379564837" (without the quotes), and you have this Substring((Entered chat string) , 3 , 7 ), this means that the trigger will read a value from the 3rd digit to the 7th digit, so the output display would be 795648 since it takes the digit 3 to 7.

Take a look at my test map and see for yourself how this things work.

If you don't understand how the test map works, do question me.
 

Attachments

Status
Not open for further replies.
Back
Top