OnGameModeExit + saving player data
#1

I've debugged my script, and when server is restarting (GMX) player data is saving to the database, but not everything. Basically I am getting X, Y, Z, A etc.. and X, Y is not being saved but surprisingly Z position is being saved, skinid and other things. Should I make a seprate command for restart to save data and everything else before, and then when timer passed, just SendRconCommand to restart server?

I know that GMX is loading next gamemode from server.cfg, but it should do it (the thing I want), right?

pawn Код:
public OnGameModeExit()
{
    foreach(new playerid : Player)
    {
        OnPlayerDisconnectEx(playerid);
    }

        mysql_close();
        [...]
Debug:
pawn Код:
UPDATE `playerdata` SET `health` = 100.000000, `skinid` = 71, `volume` = 100, `online` = 0, `LastX` = 0.000000, `LastY` = 0.000000, `LastZ` = 0.000000, `LastA` = 0.000000, `LastINT` = 0, `LastVW` = 0 WHERE `UID` = 1
Well, it stopped saving Z pos, now. However, other data (skin, health) are being saved. Data is saving properly when server has been closed (close rcon command)

edit:\\
Seems like server is exiting first, so I just can't grab player's current data. Looks like I'll have to set a timer for GMX. If anyone has better solution, or I am wrong.. please say.
Reply
#2

If you have a command, something like /gmx that actually restarts your server, then simply add a timer to it. After the time defined in the timer runs out, it will trigger the OnGameModeExit function but it will give the gamemode time to actually save the details of the players. To illustrate:

Код:
foreach (new A : Player)
{
        OnPlayerUpdateStats(A);
}
SetTimer("OnGameModeExit", 10000, false);
Pozdro z Lancaster
Reply
#3

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
    {
        new query;
        format(query, sizeof(query),"UPDATE `playerdata` SET `health` = 100.000000, `skinid` = 71, `volume` = 100, `online` = 0, `LastX` = 0.000000, `LastY` = 0.000000, `LastZ` = 0.000000, `LastA` = 0.000000, `LastINT` = 0, `LastVW` = 0 WHERE `UID` = 1");
        mysql_query(query);
    }
Used your Debug stuff.

Edit:

Actully just seen that you ment GMX restart. I had the same problem. What I did was this:
pawn Код:
COMMAND:gmx(playerid)
{
    if(IsPlayerAdmin(playerid))
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            new query;
            format(query, sizeof(query),"UPDATE `playerdata` SET `health` = 100.000000, `skinid` = 71, `volume` = 100, `online` = 0, `LastX` = 0.000000, `LastY` = 0.000000, `LastZ` = 0.000000, `LastA` = 0.000000, `LastINT` = 0, `LastVW` = 0 WHERE `UID` = 1");
            mysql_query(query);
        }
        SendRconCommand("gmx");
    }
    else return 0;
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)