[Tutorial] Using Timers
#1

Okay, so at first I was a little confused with timers. But soon i figured it out. They are actually really simple.

Lets say you want the server to restart by itself every 1 hour. This is how you would do it.

1. Forward the timer. At the top of your script put forward timerName(); So i will name it Restart
pawn Code:
forward Restart();
2. Now under OnGameModeInit we will start the timer when the GM starts.
SetTimer("name", time, repeating);
repeating; true = repeat, false = dont repeat

(the time is in milliseconds)
(Remember capitalization matters)


So in our case it would be;
pawn Code:
SetTimer("Restart",3600000,true);
3600000 milliseconds = 1 hour
true means it will repeat the timer (in this case it wont matter since the timer restarts with the Gamemode)

Ok so the timer is set up. Now we need to tell the timer what to do when it gets to 0.

Any where in the script you have to put public timerName() So;
pawn Code:
public Restart()
Now under this you want it to send the Rcon CMD.

pawn Code:
public Restart()
{
    SendRconCommand("gmx");
}
After 1 hour the server should restart the GM and then the next hour it will do the same and so on. Any questions/errors? Post a message
Reply


Messages In This Thread
Using Timers - by SnG.Scot_MisCuDI - 09.03.2012, 02:15
Re: Using Timers - by newbienoob - 09.03.2012, 03:47
Re: Using Timers - by HDFord - 09.03.2012, 10:28
Re: Using Timers - by SnG.Scot_MisCuDI - 09.03.2012, 12:39
Re: Using Timers - by ninjahippie - 20.03.2012, 10:17
Re: Using Timers - by Basicz - 20.03.2012, 10:47
Re: Using Timers - by Vince - 20.03.2012, 11:40
Re: Using Timers - by SnG.Scot_MisCuDI - 22.03.2012, 22:06

Forum Jump:


Users browsing this thread: 1 Guest(s)