- Joined
- Jul 21, 2008
- Messages
- 1,121
Can someone, please, make this trigger leakless using HandleVars (not vJASS). I am having troubles with destroying trigger actions.
Note: Trigger below is simple votekick system.
Thanks in advance!
Note: Trigger below is simple votekick system.
JASS:
function KickEnd takes nothing returns nothing
local trigger t = GetTriggeringTrigger()
local integer i = GetHandleInt(t, "i")
local integer p = GetHandleInt(t, "p")
local dialog d = GetClickedDialog()
if (GetTriggerEventId()==EVENT_GAME_TIMER_EXPIRED) then
if ((2*i) >= CountPlayersInForceBJ(udg_HumanGroup)) then
call LeaverRemove(ConvertedPlayer(p))
endif
call FlushHandleLocals(t)
call DestroyTrigger(t)
call DialogClear(d)
call DialogDestroy(d)
endif
if (GetTriggerEventId()!=EVENT_GAME_TIMER_EXPIRED and udg_DialogButton==GetClickedButton()) then
set i = i + 1
call SetHandleInt(t,"i",i)
endif
set d = null
set t = null
endfunction
function Trig_KickStart_Actions takes nothing returns nothing
local trigger t
local dialog d
local integer a
local integer p
local integer i
if ((StringLength(GetEventPlayerChatString())==7) or (StringLength(GetEventPlayerChatString())==8)) then
set p = S2I(SubStringBJ(GetEventPlayerChatString(), 7, StringLength(GetEventPlayerChatString())))
if (p<=1 or p>10) then
return
endif
set d = DialogCreate()
call DialogClear(d)
call DialogSetMessage( d, ( "Do you want to kick|n Player " + GetPlayerName(ConvertedPlayer(S2I(SubStringBJ(GetEventPlayerChatString(), 7, StringLength(GetEventPlayerChatString()))))) ) )
set udg_DialogButton = DialogAddButton( d, "Yes", 1 )
call DialogAddButton( d, "No", 2 )
set t = CreateTrigger()
set i = 0
call SetHandleInt(t, "i", i)
call SetHandleInt(t, "p", p)
call TriggerRegisterDialogEvent( t, d )
call TriggerRegisterTimerEventSingle( t, 15.00 )
set z = TriggerAddAction( t, function KickEnd )
call SetHandleHandle(t, "z", z)
set a = 1
loop
exitwhen a > 10
if ( IsPlayerInForce(ConvertedPlayer(a), udg_HumanGroup) ) then
call DialogDisplay( ConvertedPlayer(a), d,true )
endif
set a=a+1
endloop
endif
set d = null
set t = null
set z = null
endfunction
//===========================================================================
function InitTrig_KickStart takes nothing returns nothing
set gg_trg_KickStart = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_KickStart, Player(0), "-kick ", false )
call TriggerAddAction( gg_trg_KickStart, function Trig_KickStart_Actions )
endfunction
Thanks in advance!
Last edited: