Issue with MySQL saving
#1

Hi all.

Under OnPlayerDisconnect I call the function
pawn Код:
SavePlayer(playerid);
This is the SavePlayer function.

pawn Код:
SavePlayer(playerid)
{
    new DB_Query[256];

    mysql_format(Database, DB_Query, sizeof(DB_Query), "UPDATE `PLAYERS` SET `SCORE` = %d, `KILLS` = %d, `CASH` = %d, `DEATHS` = %d, `ADMIN` = %d, `SKIN` = %d, `TOKENS` = %d, `DONATOR` = %d, `NAMECHANGES` = %d, `HEADSHOTS`= %d WHERE `ID` = %d LIMIT 1",
    pInfo[playerid][Score], pInfo[playerid][Kills], pInfo[playerid][Cash], pInfo[playerid][Deaths], pInfo[playerid][Admin], pInfo[playerid][Skin], pInfo[playerid][Tokens], pInfo[playerid][Donator], pInfo[playerid][Namechanges], pInfo[playerid][Headshots], pInfo[playerid][ID]);
    mysql_tquery(Database, DB_Query);
    return 1;

}
Often it saves, but randomly on restarts and at other times it will wipe my statistics. Any ideas?
Reply
#2

Loop through every player and save their statistics under OnGameModeExit. You will inevitably lose data if you don't save the players' statistics periodically.
Reply
#3

Quote:
Originally Posted by GRiMMREAPER
Посмотреть сообщение
Loop through every player and save their statistics under OnGameModeExit. You will inevitably lose data if you don't save the players' statistics periodically.
I've added SavePlayer(i); beneath OnGameModeExit, hopefully that'll work.
Reply
#4

Its better to save player stats when they change. I guess admin or other stats doesnt update so often so why dont you save them when they change? Far better then save all of them in a query
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)