SA-MP Forums Archive
Help at Gmx timer - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help at Gmx timer (/showthread.php?tid=508890)



Help at Gmx timer - KillerStrike23 - 24.04.2014

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 ?


Re : Help at Gmx timer - S4t3K - 24.04.2014

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.


Re: Help at Gmx timer - KillerStrike23 - 24.04.2014

ah ty brother


Re: Help at Gmx timer - Rockyyy - 24.04.2014

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


Re: Help at Gmx timer - Konstantinos - 24.04.2014

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


Re: Help at Gmx timer - Roel - 24.04.2014

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.


Re: Help at Gmx timer - Konstantinos - 24.04.2014

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!


Re: Help at Gmx timer - Roel - 24.04.2014

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.


Re: Help at Gmx timer - lonalovegood1 - 25.04.2014

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


Re: Help at Gmx timer - Tayab - 25.04.2014

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);