• 🏆 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!

Player index

Status
Not open for further replies.
Level 9
Joined
Mar 9, 2010
Messages
272
This is proberbly a stupid question to most of you but can somebody please tell me how to do this. When i have a event that envolves chat messages:
  • Events: Player-Player (problem) types a message containing (whatever) as An exact match.
How do i make the event repond to all players than going through each one at a time. Like index1-16 but that dosnt seem to work. Can someone help me out here please.
 
  • Trigger
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • For each (IntegerA) from 1 to 12, do (Actions)
      • Loop - Actions
        • Trigger - Add to Trigger2 <gen> the event (Player - Player(IntegerA) types a message containing -set tax 50 As an exact match
  • Trigger2
  • Events
  • Conditions
    • (Owner of (Barracks 0028 <gen>)) Equal to (Triggering Player) //Player Comparison
  • Actions
    • Unit - Set life of Paladin 0570 <gen> to 50.00
To get "Player(IntegerA)", when it asks for Player, go to Conversion - Convert player index to player.

(Uh, Mr. Anachron, uh :p)
 
Level 9
Joined
Mar 9, 2010
Messages
272
It Works !! but dont keep your hope up< if i want to make different tax amount ( it will go up in 50s/50/100/150/200 etc) a trigger for -set tax 50, works but if i want a triggers for -set tax 100 Etc, do i have to make multiple *trigger- Add to trigger2 <gen> the event (player -player(integerA) types a message containing -set tax 50 As an exact match* if so do i have to make multiple triggers of your 2nd example for it to work. !!
 
Last edited by a moderator:
No, just do that:
  • Trigger
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • For each (IntegerA) from 1 to 12, do (Actions)
      • Loop - Actions
        • Trigger - Add to Trigger2 <gen> the event (Player - Player(IntegerA) types a message containing -set tax As a Substring
  • Trigger2
  • Events
  • Conditions
    • (Owner of (Barracks 0028 <gen>)) Equal to (Triggering Player) //Player Comparison
  • Actions
    • Set Number = (Substring(Entered chat string, 10, 12))
    • Unit - Set life of Paladin 0570 <gen> to (Real(Number))
So, "Number" is a String variable and that thing is the "Substring" function.
When it asks for a value on your Set Life action, go to "Conversion" -> Convert String to Real and select the "Number" variable.

(Substring(Entered chat string, 10, 12)) means that it will take your typed text, start counting from the 10th character of your text and stop on the 12th character of your text. So, any 3-digit number typed after the -set tax, will be your Paladin's healed life.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
The trigger shouldn't kill the unit, unless you type a negative health value in.

Also I recommend using the length of entered chat string:

  • Unit - Set life of Paladin 0014 <gen> to (Real((Substring((Entered chat string), 5, (Length of (Entered chat string))))))
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
The "5" was just some random value I left there, so pay no attention to it :)

Length of (Entered chat string) returns the number of characters in the entered string.

If you type

-set tax 10

it will return 11 as the length and will use that instead of a static value.

So you can type

-set tax 1
-set tax 10
-set tax 100
-set tax 1000

and they all work correctly regardless of how many digits there are.
 
Status
Not open for further replies.
Top