Mysql PVars reset when server restart:s
#1

Heey all,

I have a problem with my mysql script.
When i restart the server with a command all the pvars will be resetted and saved.
If i disconnect from the server it doesnt reset the pvars and will be saved good.
Command:
pawn Код:
dcmd_restart(playerid,params[])
{
    #pragma unused params
    if(PlayerInfo[playerid][AdminLevel] >= ADMIN_RESTART)
    {
        foreach(Player,i)
        {
            if(PlayerInfo[i][Logged] == true)
            {
                SavePlayer(i);
                LogPlayerOut(i);
            }
        }
        SetTimer("ServerGMX",2000,0);//2 seconds with no repeat
        GameTextForAll("Server is restarting - Please Wait.",30000,5);
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, NO_PERM);
    }
    return 1;
}
SavePlayer:
pawn Код:
stock SavePlayer(playerid)
{
    new h, m, s, Float:health, Float:armour, Float:POS[3];
    TotalGameTime(playerid, h, m, s);
    GetPlayerPos(playerid, POS[0], POS[1], POS[2]);
    GetPlayerHealth(playerid, health);
    GetPlayerArmour(playerid, armour);
    new query[1000];
    new query2[1000];
    format(query, sizeof(query), "UPDATE `"#MYSQL_TABLE"` SET `XPos` = %.2f, `YPos` = %.2f, `ZPos` = %.2f, `AdminLevel` = %d, `VIPLevel` = %d, `WantedLevel` = %d, \
    `Kills` = %d, `Deaths` = %d, `Money` = %d, `Score` = %d, `Health` = %.2f, `Armour` = %.2f, `Hours` = %d, `Minutes` = %d, `Seconds` = %d,",
        POS[0],
        POS[1],
        POS[2],
        PlayerInfo[playerid][AdminLevel],
        PlayerInfo[playerid][VIPLevel],
        GetPlayerWantedLevel(playerid),
        PlayerInfo[playerid][Kills],
        PlayerInfo[playerid][Deaths],
        GetPlayerMoney(playerid),
        GetPlayerScore(playerid),
        health,
        armour,
        h,
        m,
        s);
    format(query2, sizeof(query2), "
`LastSkin` = %d, `KickCount` = %d,`SpawnCount` = %d, `ReportCount` = %d, `Bank` = %d,`Interior` = %d,`World` = %d,`Class` = %d,`Skill` = %d,\
    `FightingStyle` = %d,`Speedo` = %d,`AllowPMS` = %d,`JailTime` = %d,`WantedLevel` = %d,`House` = %d,`SavePos` = %d WHERE `PlayerName` = '%s'",
        PlayerInfo[playerid][LastSkin],
        PlayerInfo[playerid][KickCount],
        PlayerInfo[playerid][SpawnCount],
        PlayerInfo[playerid][ReportCount],
        PlayerInfo[playerid][pBank],
        GetPlayerInterior(playerid),
        GetPlayerVirtualWorld(playerid),
        GetPVarInt(playerid,"
Class"),
        GetPVarInt(playerid,"
Skill"),
        GetPlayerFightingStyle(playerid),
        GetPVarInt(playerid,"
Speedo"),
        GetPVarInt(playerid,"
AllowsPMS"),
        PlayerInfo[playerid][pJailTime],
        GetPVarInt(playerid,"
WantedLevel"),
        GetPVarInt(playerid,"
House"),
        PlayerInfo[playerid][pSavePos],
        GetName(playerid));
    strcat(query,query2);

    if(mysql_ping(gSQL))
    {
        mysql_query(query, _THREAD_SAVE_PLAYER, 0, gSQL);//query
    }
}
LogPlayerOut:
pawn Код:
stock LogPlayerOut(playerid)
{
    new query[128];
    format(query, sizeof(query), "UPDATE `"#MYSQL_TABLE"` SET `LastSkin` = %d, `Status` = 0 WHERE `PlayerName` = '%s'", GetPlayerSkin(playerid), GetName(playerid));
    if(mysql_ping(gSQL))
    {
        mysql_query(query, _THREAD_PLAYER_LOGOUT, playerid, gSQL);
    }

    return 1;
}
pawn Код:
forward ServerGMX();
public ServerGMX()
{
    SendRconCommand("gmx");
    return 1;
}
I use the same code as onplayerdisconnect to save the stats.
Only the PVars will be resetted. Money,score,fightingstyle and others works fine.
How can i fix this?

Admigo
Reply
#2

ServerGMX callback?
Reply
#3

Quote:
Originally Posted by Harti
Посмотреть сообщение
ServerGMX callback?
pawn Код:
forward ServerGMX();
public ServerGMX()
{
    SendRconCommand("gmx");
    return 1;
}
Reply
#4

Anyone can help me?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)