Warcraft III resources & community, 2003–2006 · archived

Removing Units when some one has left the game

4 posts
#1

Removing Units when some one has left the game

hi folk anyone w=know how to tr=remove units if a player leaves?
#2

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.
#3
Or this:


    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.
#4
Thank you for your help it is very appreciated :D p.s have a good weekend!!!