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

[Trigger] "All Players" variable

Status
Not open for further replies.
Level 2
Joined
Oct 10, 2007
Messages
12
I'm trying to figure out how to perform an action on all players. Specifically, I want to assign the same resources for all players in just a couple Action lines. This will also help for more advanced things I may want to apply to all players, such as some cinematic features (if it is even possible).

allplayer.gif


Is there any way to set it to work with all players instead of just one player at a time? I read something about arrays, but I'm not sure how that works.

One of the other things I tried was this...

badtriggers.gif


... except I don't know if that will work how I want it to, because if it is random, couldn't the same player be selected more than once, and some players not at all?

Please help me out with this. Thanks!
 
Level 9
Joined
Jul 24, 2007
Messages
308
make it lilke this :
  • trigger
    • Events
      • your event
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Player - Set (Player((Integer A))) Current gold to 0
          • Player - Set (Player((Integer A))) Current lumber to 750
(Player((Integer A))) is :Conversation - Convert Player Index to Player then choose For Loop Integer A
 
Level 6
Joined
Nov 4, 2004
Messages
125
Criminal's suggestion works too, but i'd prefer to use a player group:
  • Player Resources
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Add 1000 to (Picked player) Current gold
          • Player - Add 500 to (Picked player) Current lumber
Keep in mind that player groups leak. So if you don't use "GetPlayersAll()" (like in this case, which just returns a bj variable), you might want to unleak when using this more often. Hope that helped!

And btw, that 0.00 seconds wait seems utterly unnecessary to me. It will only cause a 0.27 seconds wait which I'm pretty sure you don't need.
 
Level 2
Joined
Oct 10, 2007
Messages
12
Criminal's suggestion works too, but i'd prefer to use a player group:
  • Player Resources
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Add 1000 to (Picked player) Current gold
          • Player - Add 500 to (Picked player) Current lumber
Keep in mind that player groups leak. So if you don't use "GetPlayersAll()" (like in this case, which just returns a bj variable), you might want to unleak when using this more often. Hope that helped!

And btw, that 0.00 seconds wait seems utterly unnecessary to me. It will only cause a 0.27 seconds wait which I'm pretty sure you don't need.

Thanks, I tried this and it seems to work fine. I wish I knew how to use Player Groups yesterday, LOL. Ah well, "live and learn" eh?


Also, that was a good tip on the Integers, Criminal. Now I know for when I try to use integers for something similar. :grin:
 
Status
Not open for further replies.
Top