if(strcmp(cmd, "/restartserver", true) == 0)
{
if(PInfo[playerid][AdminLevel] > 3)
{
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_ERROR, "Syntax: /restartserver (reason)");
return 1;
}
if(ServerRestarting == 1)
{
SendClientMessage(playerid, COLOR_ERROR, "The server is already restarting!");
return 1;
}
new restartmsg[128];
ServerRestarting = 1;
format(restartmsg,sizeof(restartmsg),"Administrator {1B8AE4}%s(%d) {FFFFFF}has restarted the server • {1B8AE4}[Reason: %s]", PlayerName(playerid),playerid, result);
SendClientMessageToAll(COLOR_WHITE, restartmsg);
SendClientMessageToAll(COLOR_WHITE, "* Server restarting in {1B8AE4}30 {FFFFFF}seconds ...");
SetTimerEx("RestartServer", 30000, false, "i", playerid);
AdminLog(playerid, "/restartserver", result, "Everyone");
return 1;
}
public RestartServer()
{
SendRconCommand("gmx");
return 1;
}
Rcon command "gmx" only restarts the gamemode, not the server: https://sampwiki.blast.hk/wiki/SendRconCommand
For restarting the server, you'll need: /rcon gmx - Will load the next gamemode in server.cfg. /rcon reloadfs - Reloads the given filterscript (example: /rcon reloadfs adminfs). Source:https://sampwiki.blast.hk/wiki/Advanced_...#RCON_Commands I just did a ****** search for this. I am going to create my own as well ![]() |
Did you try to make it unload your filterscripts first? When the server restarts, does the server work normal or buggy?
|
public reloadfs()
{
SendRconCommand("reloadfs scriptname");
return 1;
}
public RestartServer()
{
SendRconCommand("gmx");
return 1;
}
}
if(strcmp(cmd, "/restartserver", true) == 0)
{
if(PInfo[playerid][AdminLevel] > 3)
{
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_ERROR, "Syntax: /restartserver (reason)");
return 1;
}
if(ServerRestarting == 1)
{
SendClientMessage(playerid, COLOR_ERROR, "The server is already restarting!");
return 1;
}
new restartmsg[128];
ServerRestarting = 1;
format(restartmsg,sizeof(restartmsg),"Administrator {1B8AE4}%s(%d) {FFFFFF}has restarted the server • {1B8AE4}[Reason: %s]", PlayerName(playerid),playerid, result);
SendClientMessageToAll(COLOR_WHITE, restartmsg);
SendClientMessageToAll(COLOR_WHITE, "* Server restarting in {1B8AE4}30 {FFFFFF}seconds ...");
SetTimerEx("RestartServer", 30000, false, "i", playerid);
SetTimerEx("reloadfs", 30000, false, "i", playerid);
SetTimerEx("reloadfss", 30000, false, "i", playerid);
AdminLog(playerid, "/restartserver", result, "Everyone");
return 1;
}
I'm already aware about it. I'm just looking about is it possible to make my script work with filterscripts too? |
public restartServer()
{
SendRconCommand("gmx");
return 1;
}
SendRconCommand("gmx"); // restarts the server