SA-MP Forums Archive
Starting Timers with 1-second difference - 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: Starting Timers with 1-second difference (/showthread.php?tid=334279)



Starting Timers with 1-second difference - Dairyll - 14.04.2012

So I have four 1-second timers that start on OnGameModeInit. I'm trying to make them start 1 second apart from each other. How would I be able to pull this off?


Re: Starting Timers with 1-second difference - Marco_Valentine - 14.04.2012

1000 equals one second. Hence start one at 1000, the next at 2000 and the other at 3000? That should be exactly what you're looking for


Re: Starting Timers with 1-second difference - Dairyll - 14.04.2012

How would I do that script-wise?

Edit: Is it safe to use this: https://sampwiki.blast.hk/wiki/Useful_Functions#Wait


Re: Starting Timers with 1-second difference - Marco_Valentine - 14.04.2012

show me the lines that you have for your timers..


Re: Starting Timers with 1-second difference - Dairyll - 14.04.2012

Код:
myTimers[0] = SetTimer("serverLoops", 1000, true);
myTimers[1] = SetTimer("playerLoops", 1000, true);
myTimers[2] = SetTimer("dbLoops", 1000, true);
myTimers[3] = SetTimer("miscLoops", 1000, true);



Re: Starting Timers with 1-second difference - Marco_Valentine - 14.04.2012

Код:
myTimers[0] = SetTimer("serverLoops", 1000, true);
myTimers[1] = SetTimer("playerLoops", 2000, true);
myTimers[2] = SetTimer("dbLoops", 3000, true);
myTimers[3] = SetTimer("miscLoops", 4000, true);
They will all start one second apart from each other now.


Re: Starting Timers with 1-second difference - Dairyll - 14.04.2012

You just changed the interval though, not the actual starting time.


AW: Starting Timers with 1-second difference - Nero_3D - 14.04.2012

And what would be the use of that, just that they still overlap each second afterwards ?

Also the wait function hangs your whole server, so the timer wont proceed meanwhile


Re: Starting Timers with 1-second difference - Dairyll - 14.04.2012

Would 500-ms difference work better instead?


Re: Starting Timers with 1-second difference - Shetch - 14.04.2012

Код:
SetTimer("serverLoops", 1000, true);

public serverLoops()
{
SetTimer("playerLoops", 1000, false);
}
and so on.