Hourly Server Restart
#1

Hi, i was wondering how i could make my server restart every 4 hours. I want it to restart to refresh it and reload all the stuff and bring down lag. Idk if this would be a filterscript or what?

5 minutes before restart

Client Message To All: Server restarting in 5 minutes...

any ideas?
Reply
#2

Oh that's simple! I'll help you through it:

First, we need to determine how long four hours would be in a time format that the server can understand. I'll give you some values:

1 minute = 60000

30 minutes = 1800000

1 hour = 3600000

Now, let's do some math for the timers here. We need one timer to execute when the server starts (i.e. OnGameModeInit), it should be 3 hours and 55 minutes before the timer get's called.

The time calculation for that would be: 3600000 x 3 = 10800000. We then need to calculate 55 minutes, and for that it would be: 60000 x 55 = 3300000. Now let's get the total time: 10800000 + 3300000 = 14100000.

Let's set the timer, for this I'll be using y_timers!

pawn Код:
public OnGameModeInit()
{
    ServerRestartDelay();
    return 1;
}
... and now we need to add the first timer function (which will be called after 3 hours and 55 minutes from the moment the server was initialized.

pawn Код:
Delay:ServerRestartDelay[14100000, ]()
{
    ServerRestartFinalDelay();
    SendClientMessageToAll(-1, "WARNING: The server will be auomatically restarted in 5 minutes.");
    return 1;
}
You'll notice that there is a function inside the timer's function called "ServerRestartFinalDelay", for this we need to setup one last timer. It will be called after five minutes from the moment the first timer finished. I won't elaborate on the time calculations this time, you should be able to understand it using the values above.

pawn Код:
Delay:ServerRestartFinalDelay[300000, ]()
{
    SendClientMessageToAll(-1, "WARNING: The server is going down for a restart NOW.");
    SendRconCommand("gmx");
    return 1;
}
And that's it! The server will restart after 4 hours from the time you initialized the server, but will also send a message five minutes before the restart to all players on the server. I hope this helps!

References: y_timers
Reply
#3

i got:

(329) : error 017: undefined symbol "ServerRestartDelay"
329:
pawn Код:
ServerRestartDelay();
(802) : error 029: invalid expression, assumed zero
(802) : error 017: undefined symbol "ServerRestartDelay"
(802) : error 001: expected token: ";", but found "return"
(802) : fatal error 107: too many error messages on one line

802:
pawn Код:
Delay:ServerRestartDelay[14100000, ]();
Reply
#4

You need to download y_timers, and include it in your script!

http://forum.sa-mp.com/showthread.ph...light=y_timers
Reply
#5

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
You need to download y_timers, and include it in your script!

http://forum.sa-mp.com/showthread.ph...light=y_timers
i did that.. i added

#include <y_timers> to the top of my gm
Reply
#6

Quote:
Originally Posted by googamalugafoo
Посмотреть сообщение
i did that.. i added

#include <y_timers> to the top of my gm
Which is why it doesn't work because if you were to download the YSI library, you should of put the whole YSI folder in your pawno/includes folder and then included it like so:

pawn Код:
#include <YSI\y_timers>
Reply
#7

still same errors..
Reply
#8

Quote:
Originally Posted by googamalugafoo
Посмотреть сообщение
still same errors..
Let me guess, you haven't actually downloaded YSI, did you?
Reply
#9

Quote:
Originally Posted by playbox12
Посмотреть сообщение
Let me guess, you haven't actually downloaded YSI, did you?
yes i did, i extracted it pawno include and added it to the top of my script. Im not that much of a noob lol
Reply
#10

You shouldn't be receiving those errors then. If you could, please take an SS of the top of your mode and an SS of your pawno/includes directory just so I can double check?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)