It updates the db but when a saving stock occurs it returns to 0
#1

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;
}
Reply
#2

Your query is wrong for starters. Remove the AND and replace it with a comma.
Reply
#3

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?
Reply
#4

Thanks, it worked, I just removed then AND thing and it worked, ty.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)