Money saving problem - 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: Money saving problem (
/showthread.php?tid=282719)
Money saving problem -
Sascha - 12.09.2011
Hi..
So I'm having a little problem when I save the player's money in a DB.
I have this at "OnPlayerDisconnect"
pawn Код:
format(string, sizeof(string), "UPDATE `user` SET `money`=%d AND `score`=%d WHERE `name`='%s'", GetPVarInt(playerid, "Money"), GetPlayerScore(playerid), name);
mysql_query(string);
However it always sets the player's money to "1" (while playing it is correct though)
Re: Money saving problem -
Haydz - 12.09.2011
When you're setting the data you just need to put a , when you wish to add something new.
pawn Код:
format(string, sizeof(string), "UPDATE `user` SET `money`= %d, `score`= %d WHERE `name`= '%s'", GetPVarInt(playerid, "Money"), GetPlayerScore(playerid), name);
mysql_query(string);
Something like that should work fine.
Re: Money saving problem -
Vince - 12.09.2011
You shouldn't need to use AND in any of your update queries. It is solely used in the WHERE clause of a query. Use commas instead.
Код:
`money`=%d,`score`=%d
Edit: 2slow
Re: Money saving problem -
Sascha - 12.09.2011
hm is this also the source of the actual problem?