Server not saving on restart?
#1

pawn Код:
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;
}
pawn Код:
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;
}
Nothing wrong with the code cause it sends the messages to players, just doesn't save accounts.
Reply
#2

My /restart command kicks the whole server so they can reconnect when it's done. I had the same problem of small datalosses when I just restarted "normally". My new command seems to work better but I haven't strictly tested it.
Reply
#3

I would suggest not to use
pawn Код:
SendRconCommand("gmx");
First kick the players not onebyone but all. Then you use /rcon gmx or if you want in a command, Make cmd.
Reply
#4

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..
Reply
#5

Quote:
Originally Posted by AphexCCFC
Посмотреть сообщение
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..
Alright you are correct too, But try it basic way. Instead of timers and this reasoning just use normal method. OnPlayerDisconnect some problem i am also not aware about it.

Remove your /restart command and forwards etc, Make one normal cmd using IsPlayerAdmin(playerid))** and then SendRconCommand("gmx"); then return thats it.

Test it, While playing and if doesn't works
then
Kick the player and then restart.
Reply
#6

I've done it this way:

pawn Код:
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;
}
pawn Код:
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;
}
I've realised that as long as the rcon gmx command isn't in the same public as anything else except prints it works.
Reply
#7

Here i want to check whether nothing is wrong with saving system buddy, Your way is correct too but you are not getting my point.

Remove everything like isplayeradminlevel, loggedin, adminduty. Just normal IsPlayerAdmin(playerid))** this means RCON admin.

Do it like that way remove all timers any taps making gaps, Just a simple normal easy restart cmd which uses only
pawn Код:
SendRconCommand("gmx");
Reply
#8

You're going to restart server 50 times if there are 50 players online. Please take this out from that foreach loop. Also, just make a command like saveallstats to save the player stats before restarting because, OnPlayerDisconnect causes issues while saving stats, so it's better to save the stats first, then restart.

pawn Код:
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;
}
Reply
#9

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

Quote:
Originally Posted by AphexCCFC
Посмотреть сообщение
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
Thats good my old friend helped.

Anyway, OnGameModeExit means when you shutdown your server or close, Change it.

I mean change your saving system under OnPlayerDisconnect.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)