Help at Gmx timer
#1

hey guys I want a help, in how to make a timer for the cmd gmx I want the server to restart every 8 hours any one could help ?
Reply
#2

Use a timer and make a public function which the only instruction is a rcon command gmx, such as

PHP код:

forward restartGamemode
();
public 
restartGamemode()
{
   
SendRconCommand("gmx");
   return 
1;
}
public 
OnGameModeInit()
{
    
SetTimer("restartGamemode"28800000false);
    return 
1;

28800000 = 3600000 milliseconds (1 hour) * 8.
Reply
#3

ah ty brother
Reply
#4

I'd like to know how to make it "every 24 hours"
Reply
#5

Quote:
Originally Posted by Rockyyy
Посмотреть сообщение
I'd like to know how to make it "every 24 hours"
Change the interval to 86400000.
Reply
#6

Uhm not sure if this is a good idea, since this may can cause lag...
I think its better to just create a timer that executes each minute, and then check the time.
If it is like 12 a clock you restart the gamemode.

Not sure if it matters lol.
Reply
#7

Quote:
Originally Posted by Roel
Посмотреть сообщение
Uhm not sure if this is a good idea, since this may can cause lag...
I think its better to just create a timer that executes each minute, and then check the time.
If it is like 12 a clock you restart the gamemode.

Not sure if it matters lol.
Calling a timer once after 8 or 24 hours since the gamemode has started seems to be the best option. A repeated timer that checks every minute the time is indeed going to be called more times. The less it gets called, the better!
Reply
#8

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Calling a timer once after 8 or 24 hours since the gamemode has started seems to be the best option. A repeated timer that checks every minute the time is indeed going to be called more times. The less it gets called, the better!
Ye I was thinking about that after I posted lol, seems you are right.
Reply
#9

you must set another timer into your function to tell the players that server will restart in next maybe 5 or 10 minuets ... and also increase the time to more than 12 hours ... bcoz it can be harmful and first your players will get angry ... second there is less data loss
Reply
#10

Quote:
Originally Posted by lonalovegood1
Посмотреть сообщение
you must set another timer into your function to tell the players that server will restart in next maybe 5 or 10 minuets ... and also increase the time to more than 12 hours ... bcoz it can be harmful and first your players will get angry ... second there is less data loss
Here, I made this..! Not sure if it'll work though!

Restarts the server every 24 hours.
and every five minutes, it'll tell the players how much time is remaining..
pawn Код:
new hours,minutes;
forward restartGameMode();
public restartGameMode()
{
    minutes++;
    new string[100];
    if(minutes == 60){
        minutes = 0;
        hours++;
    }
    if(hours == 24){
        SendRconCommand("gmx");
        hours = 0;
    }
    if((minutes % 5) == 0){
        format(string,sizeof(string),"%d minutes remaining in the restart!",1440-minutes);
        SendClientMessageToAll(0xFF8800,string);
    }
}
SetTimer("restartGameMode",1000*60,1);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)