06.12.2015, 22:16
Hey guys, im having an issue with data.
Im saving data with the following code and executing this ingame on command /savestats
however, sometimes a player logs in to find his EXPE set to 0, meaning it did not load, or it did not save.
this is the stock for saving
Then again, i have another problem with the /stats command, its showing everything, exept for the players score.
And ofcourse the Load data code.
The Database fields look like : http://prntscr.com/9b5zou
So i wonder what i have been doing wrong, am i placing %i and %d wrong because i thought they meant the same thing.
Im saving data with the following code and executing this ingame on command /savestats
however, sometimes a player logs in to find his EXPE set to 0, meaning it did not load, or it did not save.
this is the stock for saving
Code:
stock SavePlayerData(playerid) { new query[512]; mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `IP`='%s', `Admin`=%i, `VIP`=%i, `EXPE`=%i, `Kills`=%i, `Deaths`=%i, `Score`=%i, `Wanted`=%i, `Money`=%i WHERE `ID`=%d", IP[playerid], pData[playerid][Admin], pData[playerid][VIP], pData[playerid][EXPE], pData[playerid][Kills], pData[playerid][Deaths], GetPlayerScore(playerid), GetPlayerWantedLevel(playerid), pData[playerid][Money], pData[playerid][ID]); mysql_tquery(mysql, query, "", ""); }
Code:
CMD:stats(playerid, params[]) { new str[254]; new deaths = pData[playerid][Deaths]; if(!deaths) deaths = 1; new Float:kd = floatdiv(pData[playerid][Kills], deaths); format(str, sizeof(str),"Your Stats\nScore: %d\nKills: %i\nDeaths: %i\nKD-Ratio: %0.2f\nMoney: %i\nXP: %i\nVIP Level: %i",pData[playerid][Score],pData[playerid][Kills],pData[playerid][Deaths],kd,pData[playerid][Money],pData[playerid][EXPE],pData[playerid][VIP]); ShowPlayerDialog(playerid, dSTATS,DIALOG_STYLE_MSGBOX,"Account stats",str, "Close",""); return 1; }
Code:
public OnAccountLoad(playerid) { new score; new wantedl; new XPl; pData[playerid][Admin] = cache_get_field_content_int(0, "Admin"); pData[playerid][VIP] = cache_get_field_content_int(0, "VIP"); pData[playerid][Money] = cache_get_field_content_int(0, "Money"); pData[playerid][Kills] = cache_get_field_content_int(0,"Kills"); pData[playerid][Deaths] = cache_get_field_content_int(0, "Deaths"); score = cache_get_field_content_int(0, "Score"); SetPlayerScore(playerid, score); wantedl = cache_get_field_content_int(0, "Wanted"); SetPlayerWantedLevel(playerid, wantedl); XPl = cache_get_field_content_int(0, "EXPE"); SetPlayerXP(playerid, XPl); GivePlayerMoney(playerid, pData[playerid][Money]); SendClientMessage(playerid, COLOR_WHITE, "{ff387a}[Server]:{ffffff} You have successfully logged in!"); return 1; }
So i wonder what i have been doing wrong, am i placing %i and %d wrong because i thought they meant the same thing.