Stopping timer and starting timer with the same duration - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Stopping timer and starting timer with the same duration (
/showthread.php?tid=513274)
Stopping timer and starting timer with the same duration -
TheSimpleGuy - 15.05.2014
I can't think of using SetTimerEx & SetTimer as stopping a timer and starting it again with the same duration as I stopped. How do I do that, or if someone gives me an idea on how to do it?
Re: Stopping timer and starting timer with the same duration -
Beckett - 15.05.2014
Well just a small idea came up to my mind not sure if it's good or not, create a variable then start every one second increase it (when the timer starts) (+1) when the timer stops, stop increasing when you wanna start another timer.
SetTimer("timer",var*1000,false/true);
Re: Stopping timer and starting timer with the same duration -
Campbell- - 15.05.2014
I'm not quite sure what your goal is but it seems like you want to stop a timer and restart it:
pawn Код:
new tHandle = SetTimerEx(...);
// Restarting
KillTimer(tHandle);
tHandle = SetTimerEx(...);
Re: Stopping timer and starting timer with the same duration -
KingHual - 15.05.2014
1. Upon SetTimerEx, store GetTickCount() in a variable, e.g. initTime
2. Upon KillTimer, set initTime to GetTickCount()-initTime
3. Upon the next SetTimerEx, just use SetTimerEx(x, interval-initTime, ...);