CMD:restart(playerid, params[])
{
new string[156];
if(!IsPlayerLoggedIn(playerid))
{
SendClientMessage(playerid, -1, "You are restricted from using commands until you log in.");
return 1;
}
if(PlayerInfo[playerid][pAdminLevel] < 1)
{
SendClientMessage(playerid, -1, "You do not have the authority to use this command.");
return 1;
}
if(!AdminDuty[playerid])
{
SendClientMessage(playerid, -1, "You are not on duty as an Administrator (/aduty).");
return 1;
}
if(sscanf(params, "s[128]", params))
{
SendClientMessage(playerid, -1, "Usage: /restart <reason>");
return 1;
}
foreach(Player, i)
{
format(string, sizeof(string), "Administrator %s: Server restart (one minute) - %s", Player(playerid), params);
SendClientMessage(i, -1, string);
SetTimerEx("ServerRestart", 60000, false, "i", i);
}
return 1;
}
forward ServerRestart();
public ServerRestart()
{
foreach(Player, i)
{
SaveAccount(i);
SendClientMessage(i, -1, "Server restarting, please wait. All accounts have been saved successfully.");
}
printf("Server restart has been ordered.");
SendRconCommand("gmx");
return 1;
}
SendRconCommand("gmx");
I used the /restart command to kick the players then set a 10 second timer to restart the server and it works, only way it seems..
|
CMD:restart(playerid, params[])
{
new string[156];
if(!IsPlayerLoggedIn(playerid))
{
SendClientMessage(playerid, -1, "You are restricted from using commands until you log in.");
return 1;
}
if(PlayerInfo[playerid][pAdminLevel] < 1)
{
SendClientMessage(playerid, -1, "You do not have the authority to use this command.");
return 1;
}
if(!AdminDuty[playerid])
{
SendClientMessage(playerid, -1, "You are not on duty as an Administrator (/aduty).");
return 1;
}
foreach(Player, i)
{
format(string, sizeof(string), "Administrator %s has ordered a server restart in ten minutes - accounts will save.", Player(playerid));
SendClientMessage(i, -1, string);
SetTimer("ServerRestart", 60000, false);
}
return 1;
}
public ServerRestart()
{
foreach(Player, i)
{
Kick(i);
}
SetTimer("ServerRestartNow", 10000, false);
printf("Server restart has been ordered.");
return 1;
}
public ServerRestartNow()
{
printf("All accounts have been saved successfully.");
SendRconCommand("gmx");
return 1;
}
SendRconCommand("gmx");
CMD:restart(playerid, params[])
{
new string[156];
if(!IsPlayerLoggedIn(playerid))
{
SendClientMessage(playerid, -1, "You are restricted from using commands until you log in.");
return 1;
}
if(PlayerInfo[playerid][pAdminLevel] < 1)
{
SendClientMessage(playerid, -1, "You do not have the authority to use this command.");
return 1;
}
if(!AdminDuty[playerid])
{
SendClientMessage(playerid, -1, "You are not on duty as an Administrator (/aduty).");
return 1;
}
foreach(Player, i)
{
format(string, sizeof(string), "Administrator %s has ordered a server restart in ten minutes - accounts will save.", Player(playerid));
SendClientMessage(i, -1, string);
//SetTimer("ServerRestart", 60000, false); // TAKE THIS OUT
}
SetTimer("ServerRestart", 60000, false);
return 1;
}
Thanks iZN, didn't notice I kept the timer in the loop ha. I used SandBox and opened a few SA-MPs at a time to test and it works. On earlier versions, I was able to close the game mode by clicking the red X and it saved stats from OnGameModeExit but doesn't seem to work anymore
![]() |