SA-MP Forums Archive
Saving goes corrupt - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Saving goes corrupt (/showthread.php?tid=608289)



Saving goes corrupt - justjamie - 30.05.2016

Hello.
Sometimes when i save, i get someone elses name, as my age.
I have no clue where it's coming from, but it's really pissing me off.
This is the code:

PHP код:
savePlayer(playerid)
{
if(
PLAYERLIST_authed[playerid] == 0)
{
return 
1;
}
else
{
new 
query[500];
format(query,sizeof(query),
"UPDATE user SET level='%i',money='%i',skin='%i',forumname='%s',power='%i',helper='%i',radio='%i',freq1='%i',freq2='%i',freq3='%i',freq4='%i',freq5='%i',playerteam='%i',rpoints='%i',playertime='%i',bank='%i',accent='%s',age='%i',gotphone='%i',phonenumber='%i',jail='%i',jailtime='%i',bail='%i',jailreason='%s' WHERE id = '%i' ",PlayerInfo[playerid][playerlvl],PlayerTemp[playerid][sm],PlayerInfo[playerid][Skin],PlayerInfo[playerid][forumname],
PlayerInfo[playerid][power],PlayerInfo[playerid][helper],PlayerInfo[playerid][radio],PlayerInfo[playerid][freq1],PlayerInfo[playerid][freq2],PlayerInfo[playerid][freq3],PlayerInfo[playerid][freq4],PlayerInfo[playerid][freq5],PlayerInfo[playerid][playerteam]
,
PlayerInfo[playerid][rpoints],PlayerInfo[playerid][playertime],PlayerInfo[playerid][bank],PlayerInfo[playerid][accent],PlayerInfo[playerid][age],PlayerInfo[playerid][gotphone],PlayerInfo[playerid][phonenumber],PlayerInfo[playerid][jail],PlayerInfo[playerid][jailtime],PlayerInfo[playerid][bail],PlayerInfo[playerid][jailreason],PlayerInfo[playerid][dbid]);
mysql_function_query(dbhandle,query,false,"","");
       return 
1;
       }




Re: Saving goes corrupt - justjamie - 30.05.2016

Wtf it just randomly sets my level to 114, nowhere in the code to be found, LOL


Re: Saving goes corrupt - oMa37 - 30.05.2016

Try changing %i to %d?


Re: Saving goes corrupt - justjamie - 30.05.2016

Quote:
Originally Posted by oMa37
Посмотреть сообщение
Try changing %i to %d?
%i & %d are both integers, so that won't make a diffrence, right?


Re: Saving goes corrupt - cuzido - 30.05.2016

Make sure you clear the variables when players disconnect.
Example: Setting them all back to 0, so when someone else connects using that ID, it will all be fresh.


Re: Saving goes corrupt - justjamie - 30.05.2016

Quote:
Originally Posted by cuzido
Посмотреть сообщение
Make sure you clear the variables when players disconnect.
Example: Setting them all back to 0, so when someone else connects using that ID, it will all be fresh.
yez i already thought about that, i recoded all the variables to 0 OnPlayerDisconnect, seems to work now.
Thanks for the thinking