Hey there everyone!
I'm working on this one code, that would round up all the units owned by a single, and to kill them. This will be used when people leave, are kicked, etc. etc. I also have it running at Initialization, in-case slots aren't open. I have it display text that the player has left, or was never present, ping them, and then (should) wait 120.00 seconds and kill them.
This is what I currently have:
The only thing is, in the function remove, it seems to freeze at the TriggerSleepAction() call. After the alloted time, no character is killed. I've also done a test with simply printing text after the sleep, still to no avail. If I remove the call, it will work perfectly fine. But I really do wish to have the break between it, as to create a little interesting challenge for the corpses' items.
Would anyone know why it's doing this to me? I have a guess that it may have to be using it as the Filter in GroupEnumUnitsOfPlayer(), but have no way to test this (in all honesty, I don't know how any of the *Enum*() triggers work at all, so wouldn't know how to rewrite what I did. I posted here previously and someone graciously helped me out, however was unaware that I planned on adding the TriggerSleepAction() in. ).
I'm working on this one code, that would round up all the units owned by a single, and to kill them. This will be used when people leave, are kicked, etc. etc. I also have it running at Initialization, in-case slots aren't open. I have it display text that the player has left, or was never present, ping them, and then (should) wait 120.00 seconds and kill them.
This is what I currently have:
JASS:
library Funcs
function remove takes nothing returns boolean
local unit character = GetFilterUnit()
local string name = GetUnitName(character)
local integer y = 0
call PingMinimap (GetUnitX(character), GetUnitY(character), 2.00)
loop
exitwhen y == 11
call DisplayTextToPlayer(Player(y), 0.0, 0.0, "The owner of " + name + " has left the game. His idle character has been pinged, and " + name + " will drop his items in 120 seconds, and die.")
set y = y+1
endloop
call TriggerSleepAction(120.00)
call KillUnit( character )
set character = null
return true
endfunction
endlibrary
JASS:
function check_empty takes nothing returns nothing
local group KillGroup = CreateGroup()
local integer x = 0
call TriggerSleepAction(0.00)
loop
exitwhen x==11
if ( GetPlayerSlotState(Player(x)) != PLAYER_SLOT_STATE_PLAYING ) then
call GroupEnumUnitsOfPlayer(KillGroup, Player(x), Filter(function remove))
endif
set x = x+1
endloop
set x = 0
call DestroyGroup(KillGroup)
set KillGroup = null
endfunction
//===========================================================================
function InitTrig_Init takes nothing returns nothing
set gg_trg_Init = CreateTrigger( )
call TriggerAddAction( gg_trg_Init, function check_empty )
endfunction
The only thing is, in the function remove, it seems to freeze at the TriggerSleepAction() call. After the alloted time, no character is killed. I've also done a test with simply printing text after the sleep, still to no avail. If I remove the call, it will work perfectly fine. But I really do wish to have the break between it, as to create a little interesting challenge for the corpses' items.
Would anyone know why it's doing this to me? I have a guess that it may have to be using it as the Filter in GroupEnumUnitsOfPlayer(), but have no way to test this (in all honesty, I don't know how any of the *Enum*() triggers work at all, so wouldn't know how to rewrite what I did. I posted here previously and someone graciously helped me out, however was unaware that I planned on adding the TriggerSleepAction() in. ).