Saving to DB from Player enum. Possible cause of fault?
#4

I messed up, it's mysql_insert_id(). There's an extremely simple example here that should help. I would do something like this:

pawn Код:
stock SavePlayerAccount(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        new EscapedName[MAX_PLAYER_NAME];
        mysql_real_escape_string(GetName(playerid), EscapedName);
        //UpdatePlayerVariables(playerid);
        if(CheckExist(playerid) == 0)
        {
            format(query, sizeof(query), "INSERT INTO `Accounts` (Username, Password) VALUES('%s', '%s')",EscapedName, Player[playerid][pPassword]);
            mysql_query(query);
            Player[playerid][pAccountID] = mysql_insert_id();
        }
        format(query, sizeof(query), "UPDATE Accounts SET AccountID=%d, Username='%s', Password='%s', Money=%d, Level=%d, Skin=%d, Health=%f, Armour=%f, PosX=%f, PosY=%f, PosZ=%f, Angle=%f, Ethnicity=%d, Gender=%d, Age=%d, DefaultSpawn=%d, PhoneType=%d, PhoneNumber=%d, World=%d, Interior=%d, VehSlots=%d, Admin=%d WHERE AccountID=%d",
        Player[playerid][pAccountID],Player[playerid][pUsername],Player[playerid][pPassword],Player[playerid][pMoney],Player[playerid][pLevel],Player[playerid][pSkin],Player[playerid][pHealth],Player[playerid][pArmour],
        Player[playerid][pPosX],Player[playerid][pPosY],Player[playerid][pPosZ],Player[playerid][pAngle],Player[playerid][pEthnicity],Player[playerid][pGender],Player[playerid][pAge],Player[playerid][pDefaultSpawn],Player[playerid][pPhoneType],
        Player[playerid][pPhoneNumber],Player[playerid][pWorld], Player[playerid][pInterior],Player[playerid][pVehSlots],Player[playerid][pAdmin],Player[playerid][pAccountID]);
        mysql_query(query);
        SaveContacts(playerid);
    }
}
Disclaimer: doing unthreaded MySQL queries will make your gamemode hang while it waits for your mysql server to respond. This is not the most optimal way of using MySQL.

Also, about the server log, on Linux I use this command:

Код:
tail -f server_log.txt
to monitor mine.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)