SA-MP Forums Archive
Auto Restart - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: Auto Restart (/showthread.php?tid=218225)



Auto Restart - IvanCroatiaCopy - 29.01.2011

How to make auto-restart server (gmx) in 00:00 clock? Or after 24 hours?


Re: Auto Restart - legodude - 29.01.2011

Код:
forward restart();
public restart()
{
SendRconCommand("gmx");
return 1;
}
 
public OnGameModeInit()
{
SetTimer("restart",100*60*60*24,1);
return 1;
}



Re: Auto Restart - alpha500delta - 29.01.2011

I guess that code only works when you activate the timer at 00:00... You may wanna use GetTime


Re: Auto Restart - hipy - 31.01.2011

If you are on linux u could make a CRON, thats what i did


Re: Auto Restart - sergio_xd - 31.01.2011

try this:

pawn Код:
//
public OnPlayerUpdate(playerid)
{
    new Hour, Min, Second;
    gettime(Hour, Min, Second);
    if(Hour == 23 && Min == 59)
    {
        SendRconCommand("gmx");
        SendClientMessageToAll(0xDEEE20FF, "24 hours have passed, the server is restarted.");
    }
    return 1;
}



Re: Auto Restart - Mike Garber - 31.01.2011

NO, do NOT use that god damnit OnPlayerUpdate is called like god knows how many times per second.

pawn Код:
SetTimer("AutoRestart",30000,0);

forward AutoRestart();
public AutoRestart()
{
    new h,m,s;
    gettime(h,m,s);
    if(h == 23 && m == 59)
    {  
        print("Auto Restarting..");
        SendRconCommand("gmx");
    }
    return 1;
}