28.08.2014, 12:26
all of the sudden, when a player disconnects( to get his stats saved ), random stuff gets written.
Score, Money etc. is all fine, but enums(Admin level, kills, deaths ...) get random values( 46, 48, 46, 48, 49 ... )
I use this at OnPlayerDisconnect
And I use this for a timer/"saveallstats" command
I've done tests(debugging and stuff), to see where it bugs.
It's not at OnPlayerConnect, Registering or Loginning, but at "OnPlayerDisconnect".
Is there way to fix it? :l
Score, Money etc. is all fine, but enums(Admin level, kills, deaths ...) get random values( 46, 48, 46, 48, 49 ... )
I use this at OnPlayerDisconnect
pawn Код:
new Query[392], DBResult:result;
format(Query, sizeof(Query), "UPDATE `USERS` SET `NAME` = '%s', `EMAIL` = '%s', `MONEY` = '%d', `SCORE` = '%d', `KILLS` = '%d', `DEATHS` = '%d', `ADMINLEVEL` = '%d', `JAILED` = '%d', `MUTED` = '%d', `HOURS` = '%d', `MINUTES` = '%d' WHERE `ID` = '%d'",
DB_Escape(GetName(playerid)), DB_Escape(Email[playerid]), GetPlayerCash(playerid), GetPlayerScore(playerid), PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], PlayerInfo[playerid][AdminLevel], PlayerInfo[playerid][IsJailed], PlayerInfo[playerid][IsMuted], PlayerInfo[playerid][HoursOnline], PlayerInfo[playerid][MinutesOnline], PlayerInfo[playerid][ID]);
result = db_query(HDF, Query);
if(result) printf("[sqlite] %s's stats have been saved successfully", GetName(playerid)), SendClientMessage(playerid, COLOR_YELLOW, "INFO: Stats successfully saved!");
else if(!result) printf("[sqlite] %s's stats have not been saved", GetName(playerid)), SendClientMessage(playerid, COLOR_YELLOW, "INFO: Couldn't save your stats..");
db_free_result(result), Query = "\0";
pawn Код:
stock SaveStats(playerid)
{
new Query[392], DBResult:result;
format(Query, sizeof(Query), "UPDATE `USERS` SET `NAME` = '%s', `EMAIL` = '%s', `IP` = '%s', `MONEY` = '%d', `SCORE` = '%d', `KILLS` = '%d', `DEATHS` = '%d', `ADMINLEVEL` = '%d', `JAILED` = '%d', `MUTED` = '%d', `HOURS` = '%d', `MINUTES` = '%d' WHERE `ID` = '%d'",
DB_Escape(GetName(playerid)), DB_Escape(Email[playerid]), DB_Escape(PlayerIP(playerid)), GetPlayerCash(playerid), GetPlayerScore(playerid), PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], PlayerInfo[playerid][AdminLevel], PlayerInfo[playerid][IsJailed], PlayerInfo[playerid][IsMuted], PlayerInfo[playerid][HoursOnline], PlayerInfo[playerid][MinutesOnline], PlayerInfo[playerid][ID]);
result = db_query(HDF, Query);
if(result) printf("[sqlite] %s's stats have been saved successfully", GetName(playerid)), SendClientMessage(playerid, COLOR_YELLOW, "INFO: Stats successfully saved!");
else if(!result) printf("[sqlite] %s's stats have not been saved", GetName(playerid)), SendClientMessage(playerid, COLOR_YELLOW, "INFO: Couldn't save your stats..");
db_free_result(result), Query = "\0";
}
It's not at OnPlayerConnect, Registering or Loginning, but at "OnPlayerDisconnect".
Is there way to fix it? :l