CMD:gmx(playerid, params[])
{
if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
new reason[128], time, query[128];
if(AdminLevel[playerid] < 3) return SendClientMessage(playerid, COLOUR_GREY, "You are not authorized to use this command.");
if(sscanf(params, "ds[128]", time, reason)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /gmx [time till restart] [reason]");
if(time < 1 ||time > 60) return SendClientMessage(playerid, COLOUR_GREY, "Time must be between 1 minute and 1 hour.");
format(reason, sizeof(reason), "Admin %s has scheduled a Server Restart in %d minute(s) [Reason: %s]", GetNameEx(playerid), time, reason);
SendClientMessageToAll(0x95FFB4FF, reason);
//kick all
for(new x = 1; x < GetVehiclePoolSize()+1; x++)
{
UpdateVehicleParts(x);
}
foreach(Player, i)
{
SavePlayerData(i);
}
for(new x = 1; x < MAX_BUSINESSES; x++)
{
if(BizEntX[x] != 0)
{
format(query, sizeof(query), "UPDATE `businesses` SET BizBank = %d WHERE id = %d", BizBank[x], x);
mysql_tquery(dbHandle, query,"", "");
}
}
GMXTIME = time;
return 1;
}
if(GMXTIME > 0)
{
GMXTIME --;
if(GMXTIME == 0)
{
SetPlayerName(p, MAName[p]);
SendClientMessage(p,COLOUR_WHITE, "Server Restart Initiated.");
GameModeExit();
}
else
{
new string1[128];
format(string1, sizeof(string1), "(( Reminder: Server will restart in %d minute(s). (Leave the server to avoid losing items.) ))", GMXTIME);
SendClientMessage(p, COLOUR_WHITE, string1);
}
}
forward GMXTIMER();
if(GMXTIME > 0)
{
SetTimer("GMXTIMER", GMXTIME*60000, false);
if(GMXTIME == 0)
{
SetPlayerName(p, MAName[p]);
SendClientMessage(p,COLOUR_WHITE, "Server Restart Initiated.");
GameModeExit();
}
else
{
new string1[128];
format(string1, sizeof(string1), "(( Reminder: Server will restart in %d minute(s). (Leave the server to avoid losing items.) ))", GMXTIME);
SendClientMessage(p, COLOUR_WHITE, string1);
}
}
public GMXTIMER()
{
GMXTIME = 0;
//Then call whatever the hell function you have that makes it exit the gamemode and save, etc.
}
Under a one minute timer. |
if(time < 1 ||time > 60) return SendClientMessage(playerid, COLOUR_GREY, "Time must be between 1 minute and 1 hour.");
"time" is just a variable, that code above it only allowing it to have a max of 60 minutes and a minimum of 1 minute. That doesn't actually wait for the timer to finish. If it does, he didn't provide that code.
|
Thanks for the replies, I think I had it under a foreach per-player loop, so it would decrease each time.
|
GMX is not a full server-restart therefore not that useful to have a command like that.
|
{
SetPlayerName(p, MAName[p]);
SendClientMessage(p,COLOUR_WHITE, "Server Restart Initiated.");
GameModeExit();
}