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

Remove units From "user" Players that are not playing game

Status
Not open for further replies.
Level 3
Joined
Nov 1, 2012
Messages
27
I want to know how to remove (must be via triggers?) the things (units,buildings, etc.) from the units for players that are supposed to be on game, but are not.

Example: My map has 8 slot for "user" players. But in case there are just 3 or 4 people on game, i want to remove the units from the non playing slots.
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
This removes units once a player leaves the game

  • Your trigger
    • Events
      • Player - Player 1 (Red) leaves the game
      • Player - Player 2 (Blue) leaves the game
      • Player - Player 3 (Teal) leaves the game
      • Player - Player 4 (Purple) leaves the game
      • Player - Player 5 (Yellow) leaves the game
      • Player - Player 6 (Orange) leaves the game
      • Player - Player 7 (Green) leaves the game
      • Player - Player 8 (Pink) leaves the game
    • Conditions
    • Actions
      • Set Group[(Player number of (Triggering player))] = (Units owned by (Triggering player))
      • Unit Group - Pick every unit in Group[(Player number of (Triggering player))] and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Custom script: call DestroyGroup(udg_Group[GetConvertedPlayerId(GetTriggerPlayer())])
And this may check if a player plays or not in the beginning of a game :

  • Revoming
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 1 (Red) slot status) Not equal to Is playing
        • Then - Actions
          • Set Group[1] = (Units owned by Player 1 (Red))
          • Unit Group - Pick every unit in Group[1] and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
          • Custom script: call DestroyGroup(udg_Group[1])
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 2 (Blue) slot status) Not equal to Is playing
        • Then - Actions
          • Set Group[2] = (Units owned by Player 2 (Blue))
          • Unit Group - Pick every unit in Group[2] and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
          • Custom script: call DestroyGroup(udg_Group[2])
        • Else - Actions
      • -------- ###### Apply this to all plyers ######### --------
 
Level 20
Joined
Jun 27, 2011
Messages
1,864
^A better version for your second trigger.
  • Untitled Trigger 001
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • For each (Integer Temp_Int) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player(Temp_Int)) slot status) Not equal to Is playing
            • Then - Actions
              • Set Temp_UnitGroup = (Units owned by (Player(Temp_Int)))
              • Unit Group - Pick every unit in Temp_UnitGroup and do (Actions)
                • Loop - Actions
                  • Set Temp_Unit = (Picked unit)
                  • Unit - Remove Temp_Unit from the game
                  • Custom script: set udg_Temp_Unit = null
              • Custom script: call DestroyGroup( udg_Temp_UnitGroup )
            • Else - Actions
 
Level 37
Joined
Mar 6, 2006
Messages
9,243

  • Your trigger
    • Events
      • Player - Player 1 (Red) leaves the game
      • ...
    • Conditions
    • Actions
      • Custom script : set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by (Triggering player)) and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game

No need for an array or a unit group variable.
 
Level 3
Joined
Nov 1, 2012
Messages
27
just didn't understand why take action "Custom script: call DestroyGroup" is there a problem if i don't put it?
 
Status
Not open for further replies.
Top