• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

Do X for all players

Status
Not open for further replies.
Level 1
Joined
Feb 11, 2020
Messages
4
Hi, I'm new to map making in wc3, however, not a stranger to programming in general. I was just wondering, is there a way to do something for all players without doing a separate action for each of them?

I keep running into the issue of having to make the same action for each individual player..
 
You're looking for this:
  • Actions
    • Player Group - Pick every player in (All players) and do (Actions)
      • Loop - Actions
        • Player - Set (Picked player) Current gold to 750
You should check out the links in my signature. There's a lot of information in there that I wish I knew from the very beginning, especially Memory Leaks (Things That Leak).

Note that Pick every player in (All players) doesn't leak but here's an example of a Player Group that would leak because it's not handled properly:
  • Actions
    • Player Group - Pick every player in (All players matching (((Matching player) is an ally of Player 1 (Red)) Equal to True)) and do (Actions)
      • Loop - Actions
        • Player - Set (Picked player) Current gold to 750
And here is the same trigger but with the Player Group first being set as a Variable, and then second being destroyed after it's done being used. This cleans up the memory leak.
  • Actions
    • Set VariableSet PlayerGroupVariable = (All players matching (((Matching player) is an ally of Player 1 (Red)) Equal to True))
    • Player Group - Pick every player in PlayerGroupVariable and do (Actions)
      • Loop - Actions
        • Player - Set (Picked player) Current gold to 750
    • Custom script: call DestroyForce (udg_PlayerGroupVariable)
Check out Things That Leak for a more detailed explanation.

I figured i'd throw this info at you now as I wish someone did for me when I first started.

Also, be prepared for weird Reforged bugs... "Set VariableSet" is driving me insane.
 
Last edited:
Status
Not open for further replies.
Back
Top