Help with Timers - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with Timers (
/showthread.php?tid=118412)
Help with Timers -
GreenHammy - 03.01.2010
Hello, i need help on timers
SetTimer("Timer",300000, 1);
say it does that but when it executes Timer, it just does it constantly, is there a way for it to only do it once then repeat so for example it only does the function once every 5 mins
Re: Help with Timers -
Jakku - 03.01.2010
pawn Code:
SetTimer("Timer",300000, true);
Re: Help with Timers -
Correlli - 03.01.2010
pawn Code:
SetTimer("Timer", 300000, 0);
or just
pawn Code:
SetTimer("Timer", 300000, false);
if you want to run it once.
But
pawn Code:
SetTimer("Timer", 300000, 1);
will repeat every 5 minutes (300000 miliseconds).
Re: Help with Timers -
GreenHammy - 03.01.2010
nice ok ty
Re: Help with Timers -
GreenHammy - 03.01.2010
is there also a way to make it change from 5-10 mins so instead of it being 5 mins it can be random between 5-10mins every time it starts again?
Re: Help with Timers -
Correlli - 03.01.2010
pawn Code:
forward myTimer();
// use this at OnGameModeInit/OnFilterScriptInit.
SetTimer("myTimer", randomEx(300000, 600000), false); // 5 - 10 minutes.
public myTimer()
{
// your code..
// start the timer once again.
SetTimer("myTimer", randomEx(300000, 600000), false); // 5 - 10 minutes.
return true;
}
pawn Code:
stock randomEx(minnum = cellmin, maxnum = cellmax) return random(maxnum - minnum + 1) + minnum;
/* i think this function is created by Y_Less, but i'm not sure. */
Re: Help with Timers -
GreenHammy - 03.01.2010
Thanks, that works perfectly
Re: Help with Timers -
Correlli - 03.01.2010
You're welcome.