Restart Script
#1

Hi folks,

I have a restart script on my gamemode. The problem is when i use /restartserver [reason] command it restarts server but without filterscripts.

pawn Код:
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;
        }
pawn Код:
public RestartServer()
{
    SendRconCommand("gmx");
    return 1;
}
Reply
#2

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
Reply
#3

Did you try to make it unload your filterscripts first? When the server restarts, does the server work normal or buggy?
Reply
#4

Quote:
Originally Posted by Aerotactics
Посмотреть сообщение
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
I'm already aware about it. I'm just looking about is it possible to make my script work with filterscripts too?

Quote:
Originally Posted by AF1_CLAN
Посмотреть сообщение
Did you try to make it unload your filterscripts first? When the server restarts, does the server work normal or buggy?
No, when i restart server with using this command it works normally but my filterscripts doesn't starts. No bugs or something just filterscripts doesnt starts.

EDIT: I did it. For people want to know how i did it;

pawn Код:
public reloadfs()
{
    SendRconCommand("reloadfs scriptname");
    return 1;
}
i added this codes under

pawn Код:
public RestartServer()
{
    SendRconCommand("gmx");
    return 1;
}
And changed my restart script to:

pawn Код:
}
    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 have 2 filterscript so i added public reloadfs() and public reloadfss() . It seems its working correctly now.
Reply
#5

Quote:

I'm already aware about it. I'm just looking about is it possible to make my script work with filterscripts too?

So, the way you did it was basically using the information I gave you, yet you disregarded my information in the first place =.= Not even a "Thank You" either.

And why did you create 3 publics for your FSs and server restart? That's a waste of code instead of just adding everything under 1 public and using 1 timer...
Reply
#6

You're making a public function for a single line of code? Do you not understand how stupid it is to call a function that simply calls a SINGLE other function...? What's the difference in doing this?

pawn Код:
public restartServer()
{
    SendRconCommand("gmx");
    return 1;
}
Compared to this:

pawn Код:
SendRconCommand("gmx"); // restarts the server
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)