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

Removing Units when some one has left the game

Status
Not open for further replies.
Level 2
Joined
May 27, 2006
Messages
16
JASS:
function Trig_Untitled_Trigger_002_Func001002001 takes nothing returns boolean
    return ( GetEnumPlayer() == GetTriggerPlayer() )
endfunction

function Trig_Untitled_Trigger_002_Func001002 takes nothing returns nothing
    if ( Trig_Untitled_Trigger_002_Func001002001() ) then
        call RemoveUnit( GetEnumUnit() )
    else
        call DoNothing(  )
    endif
endfunction

function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing
    call ForGroupBJ( GetUnitsInRectAll(GetPlayableMapRect()), function Trig_Untitled_Trigger_002_Func001002 )
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_002 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_002 = CreateTrigger(  )
    
    //Add for each player you want this to effect
    call TriggerRegisterPlayerEventLeave( gg_trg_Untitled_Trigger_002, Player(0) ) //Player red leaves
    call TriggerRegisterPlayerEventLeave( gg_trg_Untitled_Trigger_002, Player(1) ) //Players blue leaves
    
    call TriggerAddAction( gg_trg_Untitled_Trigger_002, function Trig_Untitled_Trigger_002_Actions )
endfunction

Add a triggering event for each player you want it to effect where I commented.
 
Level 7
Joined
May 1, 2005
Messages
291
Or this:

Code:
    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
        Player - Player 9 (Gray) leaves the game
        Player - Player 10 (Light Blue) leaves the game
        Player - Player 11 (Dark Green) leaves the game
        Player - Player 12 (Brown) leaves the game
    Conditions
    Actions
        Unit Group - Pick every unit in (Units owned by (Triggering player)) and do (Actions)
            Loop - Actions
                Unit - Remove (Picked unit) from the game

hope it helps.
 
Status
Not open for further replies.
Top