Issue information

Issue ID
#2876
Status
Duplicate
Severity
None
Started
Hercules Elf Bot
Mar 17, 2009 19:11
Last Post
Hercules Elf Bot
Mar 17, 2009 19:11
Confirmation
N/A

Hercules Elf Bot - Mar 17, 2009 19:11

Originally posted by [b]VoidLess[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=2876

stopnpctimer stops executing of OnTimer<time>: labels
but it doesn't stop incrementing timer

proved it with such code:

bug_timer is holding the timer, that is examined
timer_control2 npc switchs timer on/off
timer_show3 announce current tick every second

as you can see, ticks are getting incremented while stopped
(OnTimer events are not launched however)
CODE
-[tab]script[tab]bug_timer[tab]-1,{
OnInit:
initnpctimer;
set $@time_flag,1;
end;

OnTimer1000:
end;
}

prontera,172,198,4[tab]script[tab]timer_control2[tab]904,{
if($@time_flag){
    stopnpctimer "bug_timer";
    announce "timer stopped",bc_all,0xFF0000;
    set $@time_flag,0;
}
else{
    startnpctimer "bug_timer";
    announce "timer started",bc_all,0xFF0000;
    set $@time_flag,1;
}
end;
}

-[tab]script[tab]timer_show3[tab]-1,{
OnInit:
OnTimer1000:
initnpctimer;
set .sec,getnpctimer(0,"bug_timer")/1000;
announce "-> "+.sec+" <-",bc_all,0xFF0000;
end;
}


script_commands.txt says:
QUOTE
To create the timer, use the 'initnpctimer', which will start it running.
'stopnpctimer' will pause the timer, without clearing the current tick, while
'startnpctimer' will let the paused timer continue.

so timer has to be freezed value while stopped