SA-MP Forums Archive
Disconnection & MySQL - 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: Disconnection & MySQL (/showthread.php?tid=546875)



Disconnection & MySQL - Partner - 18.11.2014

This is my script:

pawn Код:
stock SaveAccount(playerid) {
    if(gPlayerLogged[playerid] && AdminDuty[playerid] == 0) {
        new
            szPlayerName[MAX_PLAYER_NAME],
            szQuery[2048];
           
        GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
        printf("d - %s", PlayerInfo[playerid][pKey]);

        mysql_format(gMySQLConnection, szQuery, sizeof(szQuery), "UPDATE players SET Username = '%e', Password = '%e', Level = %d, AdminLevel = %d, Donator = %d, Banned = %d, LastIP = '%e', Registered = %d, \
        Sex = %d, Age = %d, Skin = %d, PosX = '%f', PosY = '%f', PosZ = '%f', PosR = '%f', ConnectTime = %d, Respect = %d, PhoneNumber = %d, Warnings = %d, Faction = %d, Leader = %d, Rank = %d WHERE ID = %d"
,
        szPlayerName, PlayerInfo[playerid][pKey], PlayerInfo[playerid][pLevel], PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pDonator], PlayerInfo[playerid][pBanned],
        PlayerInfo[playerid][pIP], PlayerInfo[playerid][pReg], PlayerInfo[playerid][pSex], PlayerInfo[playerid][pAge], PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pPos_x],
        PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z], PlayerInfo[playerid][pPos_r], PlayerInfo[playerid][pConnectTime], PlayerInfo[playerid][pRespect], PlayerInfo[playerid][pNumber], PlayerInfo[playerid][pWarns],
        PlayerInfo[playerid][pFaction], PlayerInfo[playerid][pLeader], PlayerInfo[playerid][pRank], PlayerInfo[playerid][pID]);
        mysql_pquery(gMySQLConnection, szQuery, "OnAccountFirstSave", "i", playerid);
    }
    return 1;
}
This callback is being called when a player registers and when a player disconnects.

It works perfectly when a player registers.
When a player disconnect, it just doesnt! The (hashed) password field is empty, the position of the player stays the same (doesn't save)

What's wrong?

EDIT: Yes, the whole script IS getting processed when a player logs, and so 'OnAccountFirstSave' - the query itself (and the data?) is not working


Re: Disconnection & MySQL - TheArrow - 18.11.2014

Place "mysql_debug(1);" in OnGameModeInit and show us the logs.


Re: Disconnection & MySQL - Runn3R - 18.11.2014

First you don't need to save passwords, player name on disconnect, I mean why would you do that? Remove those two because the data is saving by the SQLID. Second you probably didn't save the hashed string into the pKey. And yeah show us the logs.