Saving stats problem
#1

Hey guys, I've got a problem with saving the players stats.
So, I've got a timer, which updates everyone's stats every 60 seconds.
But, when the player crashes, everything resets to 0.
It works on normal disconnect though.
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(GetPVarInt(playerid,"Authentication")==1)
    {

    SavePlayerAccount(playerid);

   }
    return 1;
}





stock SavePlayerAccount(playerid)
{
    if(GetPVarInt(playerid, "Authentication") == 1)
    {

      new name[MAX_PLAYER_NAME];
      GetPlayerName(playerid,name,sizeof(name));
       pStats[playerid][TotalTime] = ( (gettime() - pStats[playerid][ConnectTime]));
        format(Query, sizeof(Query), "UPDATE `Accounts` SET `AdminLevel` = '%d', `Money` = '%d', `Score` = '%d', `Skin` = '%d', `Warns` = '%d' WHERE `Username` = '%s'", pStats[playerid][pAdminLevel], GetPlayerMoney(playerid), GetPlayerScore(playerid), GetPlayerSkin(playerid), pStats[playerid][pWarns],GetEscName(playerid));
        mysql_query(Query);


        new IP[56];
       
        GetPlayerIp(playerid, IP, 56);
       new h,m,s,year,month,day,hour,minute,second;
        TotalGameTime(playerid,h,m,s);
        getdate(year,month,day);
        gettime(hour,minute,second);
        format(Query, sizeof(Query), "UPDATE `Accounts` SET  `Kills` = '%d', `Deaths` = '%d', `Logins` = '%d', `PM Status` = '%d',`h` = '%d',`m` = '%d',`s` = '%d' WHERE `Username` = '%s'", pStats[playerid][pKills], pStats[playerid][pDeaths], pStats[playerid][pLogins], pStats[playerid][pPMStatus],h,m,s, GetEscName(playerid));
        mysql_query(Query);
        mysql_store_result();
    }
    else print("[MySQL ERROR] SavePlayerAccount() was called, but to a non-connected ID.");
    return 1;
}
Thanks in advance!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)