HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

ResumeTimer bugged to death?

04-16-2007, 12:24 PM#1
UnMi
Collapse JASS:
function do_nothing takes nothing returns nothing

endfunction

function Trig_Random_Timer_Actions takes nothing returns nothing
    call DisplayTimedTextToPlayer(Player(0),0,0,100000,"Press s to stop the timer, and g to resume it")
    call TimerStart(udg_t,5,true,function do_nothing)
    call TimerDialogDisplay(CreateTimerDialog(udg_t),true)
endfunction

function stop_timer takes nothing returns nothing
    call PauseTimer(udg_t)
endfunction

function resume_timer takes nothing returns nothing
    call ResumeTimer(udg_t)
endfunction

//===========================================================================
function InitTrig_Random_Timer takes nothing returns nothing
    local trigger stop_t = CreateTrigger()
    local trigger resume_t = CreateTrigger()
    set gg_trg_Random_Timer = CreateTrigger()
    call TriggerRegisterTimerEventSingle(gg_trg_Random_Timer,1.00)
    call TriggerRegisterPlayerChatEvent(stop_t,Player(0),"s",true)
    call TriggerRegisterPlayerChatEvent(resume_t,Player(0),"g",true)
    call TriggerAddAction(gg_trg_Random_Timer,function Trig_Random_Timer_Actions)
    call TriggerAddAction(stop_t,function stop_timer)
    call TriggerAddAction(resume_t,function resume_timer)
 //   set stop_t = null
//    set resume_t = null
endfunction
Triggername: Random Timer
Global Timer: t

Stopping it and resuming the timer will almost instantly bug it out, if not after one or two more expirations.
Did I miss something?
04-16-2007, 03:08 PM#2
blu_da_noob
ResumeTimer doesn't work for periodics, in that it will only run twice (I think it was twice, trying to remember from when I had this problem, might have been once) after resuming instead of repeating. You'll have to use TimerStart again, either with your original interval or use some more complicated setup if you need it to stay perfectly in sync.