It updates the db but when a saving stock occurs it returns to 0 - 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: It updates the db but when a saving stock occurs it returns to 0 (
/showthread.php?tid=538287)
It updates the db but when a saving stock occurs it returns to 0 -
Ox1gEN - 20.09.2014
So by the long title you can understand that I'm having an issue.
Well, bassicly I don't know how but when I raise deaths and kills by one they update in the database
but then when a player quits the game it goes back to zero.
It only happens on this thing, not sure why.
I assume because the player exits the game so it doesn't get to save it.. I don't really know.
Here's the code:
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
pInfo[playerid][Deaths]++;
if(killerid != INVALID_PLAYER_ID)
{
pInfo[killerid][Kills]++;
}
return 1;
}
stock MySQL_SAVE(playerid)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
mysql_format(g_Write, query, sizeof(query), "UPDATE accounts SET PosX = %f, PosY = %f, PosZ = %f, AdminLevel = %d, Kills = %d AND Deaths = %d WHERE Name = '%s'", x, y, z, pInfo[playerid][AdminLevel], pInfo[playerid][Kills], pInfo[playerid][Deaths], GetName(playerid));
mysql_pquery(g_Write, query);
pInfo[playerid][RconLogged] = false;
pInfo[playerid][LoggedIn] = false;
pInfo[playerid][Registered] = false;
return 1;
}
Re: It updates the db but when a saving stock occurs it returns to 0 -
Vince - 20.09.2014
Your query is wrong for starters. Remove the AND and replace it with a comma.
Re: It updates the db but when a saving stock occurs it returns to 0 -
Ox1gEN - 20.09.2014
Quote:
Originally Posted by Vince
Your query is wrong for starters. Remove the AND and replace it with a comma.
|
Why? Like I'll change it but is there a reason for it?
Isn't AND used for like the last thing in query?
Re: It updates the db but when a saving stock occurs it returns to 0 -
Ox1gEN - 20.09.2014
Thanks, it worked, I just removed then AND thing and it worked, ty.