Help with Timers
#1

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
Reply
#2

pawn Code:
SetTimer("Timer",300000, true);
Reply
#3

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).
Reply
#4

nice ok ty
Reply
#5

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?
Reply
#6

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. */
Reply
#7

Thanks, that works perfectly
Reply
#8

You're welcome.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)