scope LalatestUnload initializer Init
globals
private group g = CreateGroup()
endglobals
private function lulu takes nothing returns boolean
//unit is loaded
call GroupAddUnit(g,GetTriggerUnit())
return false
endfunction
private function checkifloaded takes nothing returns nothing
local unit f = GetEnumUnit()
if not IsUnitLoaded(f) then
call GroupRemoveUnit(g,f)
//unloaded, do whatever
endif
set f = null
endfunction
private function Enumerationlala takes nothing returns nothing
call ForGroup(g,function checkifloaded)
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_LOADED)
call TriggerAddCondition(t,Condition(function lulu))
call TimerStart(CreateTimer(),0.08,true,function Enumerationlala)
//modify interval to determine how frequently it will check it
endfunction
endscope