Hourly Server Restart
#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


Messages In This Thread
Hourly Server Restart - by SnG.Scot_MisCuDI - 03.12.2011, 17:55
Re: Hourly Server Restart - by Scenario - 03.12.2011, 18:08
Re: Hourly Server Restart - by SnG.Scot_MisCuDI - 03.12.2011, 18:55
Re: Hourly Server Restart - by Scenario - 03.12.2011, 19:28
Re: Hourly Server Restart - by SnG.Scot_MisCuDI - 03.12.2011, 19:29
Re: Hourly Server Restart - by Scenario - 03.12.2011, 19:34
Re: Hourly Server Restart - by SnG.Scot_MisCuDI - 03.12.2011, 19:44
Re: Hourly Server Restart - by playbox12 - 03.12.2011, 21:10
Re: Hourly Server Restart - by SnG.Scot_MisCuDI - 04.12.2011, 04:06
Re: Hourly Server Restart - by Scenario - 04.12.2011, 04:16

Forum Jump:


Users browsing this thread: 1 Guest(s)