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

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..
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,582
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.
Top