SA-MP Forums Archive
OnPlayerSave don't work. - 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: OnPlayerSave don't work. (/showthread.php?tid=553947)



OnPlayerSave don't work. - alanhutch - 01.01.2015

HI all.
I have a function called OnPlayerSave, that saves players data with SQLite in the file Accounts.db.
When the funcion OnPlayerSave is called, nothing happens, all data remains 0.
Here's the code... (OnPlayerSave is called every 5 minutes and on OnPlayerDisconnect)
pawn Код:
stock OnPlayerSave(playerid)
{
    if (IsPlayerConnected(playerid) && !IsPlayerNPC(playerid))
    {
        if (gPlayerLogged[playerid] != 0 && gPlayerSpawned[playerid] == 1)
        {
            new playername[24];
            GetPlayerName(playerid, playername, sizeof(playername));
            if (SQL_AccountExists(playername))
            {
                if(gmx == 0)
                {
                    GetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
                    GetPlayerArmour(playerid, PlayerInfo[playerid][pArmor]);
                }
                PlayerInfo[playerid][pInt] = GetPlayerInterior(playerid);
                PlayerInfo[playerid][pVirtualWorld] = GetPlayerVirtualWorld(playerid);
                GetPlayerPos(playerid, PlayerInfo[playerid][pSPos_x], PlayerInfo[playerid][pSPos_y], PlayerInfo[playerid][pSPos_z]);
                GetPlayerFacingAngle(playerid, PlayerInfo[playerid][pSPos_r]);
                new index = SQL_PrepareUpdate(playername);
                if (index != -1)
                {
                    SQL_UpdateString(index, "NomePersonaggio1", PlayerInfo[playerid][pNomePersonaggio1]);
                    SQL_UpdateString(index, "NomePersonaggio2", PlayerInfo[playerid][pNomePersonaggio2]);
                    SQL_UpdateString(index, "NomePersonaggio3", PlayerInfo[playerid][pNomePersonaggio3]);
                    SQL_UpdateFloat(index, "UltimaX", PlayerInfo[playerid][pUltimaX]);
                    SQL_UpdateFloat(index, "UltimaY", PlayerInfo[playerid][pUltimaY]);
                    SQL_UpdateFloat(index, "UltimaZ", PlayerInfo[playerid][pUltimaZ]);
                    SQL_UpdateInt(index, "Occhiali", PlayerInfo[playerid][pOcchiali]);
                    SQL_UpdateInt(index, "Cappelli", PlayerInfo[playerid][pCappello]);
                    SQL_UpdateInt(index, "Level",PlayerInfo[playerid][pLevel]);
                    SQL_UpdateInt(index, "Test",PlayerInfo[playerid][pTest]);
                    SQL_UpdateInt(index, "AdminLevel",PlayerInfo[playerid][pAdmin]);
                    SQL_UpdateInt(index, "Tutorial",PlayerInfo[playerid][pTut]);
                    SQL_UpdateInt(index, "Band",PlayerInfo[playerid][pBand]);
                    SQL_UpdateInt(index, "PermBand",PlayerInfo[playerid][pPermBand]);
                    SQL_UpdateInt(index, "Warnings",PlayerInfo[playerid][pWarns]);
                    SQL_UpdateInt(index, "Disabled",PlayerInfo[playerid][pDisabled]);
                    SQL_UpdateInt(index, "Leader",PlayerInfo[playerid][pLeader]);
                    SQL_UpdateInt(index, "Member",PlayerInfo[playerid][pMember]);
                    SQL_UpdateInt(index, "FMember",PlayerInfo[playerid][pFMember]);
                    SQL_UpdateInt(index, "DonateRank",PlayerInfo[playerid][pDonateRank]);
                    SQL_UpdateInt(index, "FactionBanned",PlayerInfo[playerid][pFactionBanned]);
                    SQL_UpdateInt(index, "LaserOwner",PlayerInfo[playerid][pLaserOwner]);
                    SQL_UpdateInt(index, "FCard",PlayerInfo[playerid][pFcard]);
                    SQL_UpdateInt(index, "Inbuilding",PlayerInfo[playerid][Inbuilding]);
                    SQL_UpdateInt(index, "BanAppealer",PlayerInfo[playerid][pBanAppealer]);
                    SQL_UpdateInt(index, "GangMod",PlayerInfo[playerid][pGangMod]);
                    SQL_UpdateInt(index, "buildingInterior", PlayerInfo[playerid][buildingInterior]);
                    SQL_UpdateInt(index, "buildingExterior", PlayerInfo[playerid][buildingExterior]);
                    SQL_UpdateFloat(index, "cExtX", PlayerInfo[playerid][cExtX]);
                    SQL_UpdateFloat(index, "cExtY", PlayerInfo[playerid][cExtY]);
                    SQL_UpdateFloat(index, "cExtZ", PlayerInfo[playerid][cExtZ]);
                    SQL_UpdateFloat(index, "cIntX", PlayerInfo[playerid][cIntX]);
                    SQL_UpdateFloat(index, "cIntY", PlayerInfo[playerid][cIntY]);
                    SQL_UpdateFloat(index, "cIntZ", PlayerInfo[playerid][cIntZ]);
                    SQL_UpdateInt(index, "FactionMod",PlayerInfo[playerid][pFactionMod]);
                    SQL_UpdateInt(index, "UpgradePoints",PlayerInfo[playerid][gPupgrade]);
                    SQL_UpdateInt(index, "Inmotel",PlayerInfo[playerid][Inmotel]);
                    SQL_UpdateInt(index, "motelInterior", PlayerInfo[playerid][motelInterior]);
                    SQL_UpdateInt(index, "motelExterior", PlayerInfo[playerid][motelExterior]);
                    SQL_UpdateFloat(index, "mExtX", PlayerInfo[playerid][mExtX]);
                    SQL_UpdateFloat(index, "mExtY", PlayerInfo[playerid][mExtY]);
                    SQL_UpdateFloat(index, "mExtZ", PlayerInfo[playerid][mExtZ]);
                    SQL_UpdateFloat(index, "mIntX", PlayerInfo[playerid][mIntX]);
                    SQL_UpdateFloat(index, "mIntY", PlayerInfo[playerid][mIntY]);
                    SQL_UpdateFloat(index, "mIntZ", PlayerInfo[playerid][mIntZ]);
                    SQL_UpdateInt(index, "ConnectedTime",PlayerInfo[playerid][pConnectTime]);
                    SQL_UpdateFloat(index, "dExtX", PlayerInfo[playerid][dExtX]);
                    SQL_UpdateFloat(index, "dExtY", PlayerInfo[playerid][dExtY]);
                    SQL_UpdateFloat(index, "dExtZ", PlayerInfo[playerid][dExtZ]);
                    SQL_UpdateFloat(index, "dAngle", PlayerInfo[playerid][dAngle]);
                    SQL_UpdateInt(index, "Registered",PlayerInfo[playerid][pReg]);
                    SQL_UpdateInt(index, "Sex",PlayerInfo[playerid][pSex]);
                    new asd = GetPlayerMoney(playerid);
                    SQL_UpdateInt(index, "Money",asd);
                    SQL_UpdateInt(index, "Bank",PlayerInfo[playerid][pAccount]);
                    SQL_UpdateInt(index, "Developer",PlayerInfo[playerid][pDeveloper]);
                    SQL_UpdateInt(index, "Mapper",PlayerInfo[playerid][pMapper]);
                    SQL_UpdateInt(index, "Division",PlayerInfo[playerid][pDivision]);
                    SQL_UpdateInt(index, "Tester",PlayerInfo[playerid][pTester]);
                    SQL_UpdateInt(index, "Age",PlayerInfo[playerid][pAge]);
                    SQL_UpdateInt(index, "RPBoost",PlayerInfo[playerid][pRPBoost]);
                    SQL_UpdateInt(index, "Origin",PlayerInfo[playerid][pOrigin]);
                    SQL_UpdateInt(index, "ATMcard",PlayerInfo[playerid][pATMcard]);
                    SQL_UpdateInt(index, "Muted",PlayerInfo[playerid][pMuted]);
                    SQL_UpdateInt(index, "Respect",PlayerInfo[playerid][pExp]);
                    SQL_UpdateInt(index, "ATMExterior", PlayerInfo[playerid][ATMExterior]);
                    SQL_UpdateInt(index, "MAPBExterior", PlayerInfo[playerid][MAPBExterior]);
                    SQL_UpdateInt(index, "GSTATIONExterior", PlayerInfo[playerid][GSTATIONExterior]);
                    SQL_UpdateInt(index, "HSSignExterior", PlayerInfo[playerid][HSSignExterior]);
                    SQL_UpdateInt(index, "CasinoWinnings",PlayerInfo[playerid][pCasinoWinnings]);
                    SQL_UpdateInt(index, "Crimes",PlayerInfo[playerid][pCrimes]);
                    SQL_UpdateString(index, "Accent",Accent[playerid]);
                    SQL_UpdateInt(index, "ATMID",PlayerInfo[playerid][ATMID]);
                    SQL_UpdateInt(index, "Kills",PlayerInfo[playerid][pKills]);
                    SQL_UpdateInt(index, "Deaths",PlayerInfo[playerid][pDeaths]);
                    SQL_UpdateInt(index, "TrashSkill",PlayerInfo[playerid][pTrashSkill]); // Trashman
                    SQL_UpdateInt(index, "CHits",PlayerInfo[playerid][pCHits]);
                    SQL_UpdateInt(index, "BriefCase",PlayerInfo[playerid][pBriefCase]);
                    SQL_UpdateInt(index, "BCash",PlayerInfo[playerid][pBCash]);
                    SQL_Update(index);

                    index = SQL_PrepareUpdate(playername);
                    SQL_UpdateInt(index, "BCrack",PlayerInfo[playerid][pBCrack]);
                    SQL_UpdateInt(index, "BPot",PlayerInfo[playerid][pBPot]);
                    SQL_UpdateInt(index, "FHits",PlayerInfo[playerid][pFHits]);
                    SQL_UpdateInt(index, "Arrested",PlayerInfo[playerid][pArrested]);
                    SQL_UpdateInt(index, "Phonebook",PlayerInfo[playerid][pPhoneBook]);
                    SQL_UpdateInt(index, "HouseTicket",PlayerInfo[playerid][pHouseTicket]);
                    SQL_UpdateInt(index, "BusinessTicket",PlayerInfo[playerid][pBusinessTicket]);
                    SQL_UpdateInt(index, "VehicleTicket",PlayerInfo[playerid][pVehicleTicket]);
                    SQL_UpdateInt(index, "BoomBox",PlayerInfo[playerid][pBoomBox]);
                    SQL_UpdateInt(index, "LottoNr",PlayerInfo[playerid][pLottoNr]);
                    SQL_UpdateInt(index, "Fishes",PlayerInfo[playerid][pFishes]);
                    SQL_UpdateInt(index, "BiggestFish",PlayerInfo[playerid][pBiggestFish]);
                    SQL_UpdateInt(index, "Job",PlayerInfo[playerid][pJob]);
                    SQL_UpdateInt(index, "Job2",PlayerInfo[playerid][pJob2]);
                    SQL_UpdateInt(index, "Paycheck",PlayerInfo[playerid][pPayCheck]);
                    SQL_UpdateInt(index, "HeadValue",PlayerInfo[playerid][pHeadValue]);
                    SQL_UpdateInt(index, "BHHeadValue",PlayerInfo[playerid][pBHHeadValue]);
                    SQL_UpdateInt(index, "Jailed",PlayerInfo[playerid][pJailed]);
                    SQL_UpdateString(index, "JailedReason",PlayerInfo[playerid][pJailedReason]);
                    SQL_UpdateInt(index, "JailTime",PlayerInfo[playerid][pJailTime]);
                    SQL_UpdateInt(index, "Gun parts",PlayerInfo[playerid][pMats]);
                    SQL_UpdateInt(index, "Pot",PlayerInfo[playerid][pPot]);
                    SQL_UpdateInt(index, "Crack",PlayerInfo[playerid][pCrack]);
                    SQL_UpdateInt(index, "Rank",PlayerInfo[playerid][pRank]);
                    SQL_UpdateInt(index, "DetSkill",PlayerInfo[playerid][pDetSkill]);
                    SQL_UpdateInt(index, "SexSkill",PlayerInfo[playerid][pSexSkill]);
                    SQL_UpdateInt(index, "BoxSkill",PlayerInfo[playerid][pBoxSkill]);
                    SQL_UpdateInt(index, "LawSkill",PlayerInfo[playerid][pLawSkill]);
                    SQL_UpdateInt(index, "MechSkill",PlayerInfo[playerid][pMechSkill]);
                    SQL_UpdateInt(index, "JackSkill",PlayerInfo[playerid][pJackSkill]);
                    SQL_UpdateInt(index, "CarSkill",PlayerInfo[playerid][pCarSkill]);
                    SQL_UpdateInt(index, "NewsSkill",PlayerInfo[playerid][pNewsSkill]);
                    SQL_UpdateInt(index, "DrugsSkill",PlayerInfo[playerid][pDrugsSkill]);
                    SQL_UpdateInt(index, "ArmsSkill",PlayerInfo[playerid][pArmsSkill]);
                    SQL_UpdateInt(index, "House",PlayerInfo[playerid][pPhousekey]);
                    SQL_UpdateInt(index, "InGarage",PlayerInfo[playerid][InGarage]);
                    SQL_UpdateInt(index, "HouseExterior", PlayerInfo[playerid][HouseInterior]);
                    SQL_UpdateInt(index, "HouseInterior", PlayerInfo[playerid][HouseInterior]);
                    SQL_UpdateFloat(index, "hExtX", PlayerInfo[playerid][hExtX]);
                    SQL_UpdateFloat(index, "hExtY", PlayerInfo[playerid][hExtY]);
                    SQL_UpdateFloat(index, "hExtZ", PlayerInfo[playerid][hExtZ]);
                    SQL_UpdateFloat(index, "hIntX", PlayerInfo[playerid][hIntX]);
                    SQL_UpdateFloat(index, "hIntY", PlayerInfo[playerid][hIntY]);
                    SQL_UpdateFloat(index, "hIntZ", PlayerInfo[playerid][hIntZ]);
                    SQL_UpdateInt(index, "SmugglerSkill",PlayerInfo[playerid][pSmugglerSkill]);
                    SQL_UpdateInt(index, "FishSkill",PlayerInfo[playerid][pFishSkill]);
                    SQL_UpdateInt(index, "FightingStyle",PlayerInfo[playerid][pFightingStyle]);
                    SQL_UpdateFloat(index, "pHealth",PlayerInfo[playerid][pHealth]);
                    SQL_UpdateFloat(index, "pArmor",PlayerInfo[playerid][pArmor]);
                    SQL_UpdateInt(index, "pSHealth",PlayerInfo[playerid][pSHealth]);
                    SQL_UpdateInt(index, "Int",PlayerInfo[playerid][pInt]);
                    SQL_UpdateInt(index, "Local",PlayerInfo[playerid][pLocal]);
                    SQL_UpdateInt(index, "VirtualWorld",PlayerInfo[playerid][pVirtualWorld]);
                    SQL_UpdateInt(index, "Model",PlayerInfo[playerid][pModel]);
                    SQL_UpdateInt(index, "Tikis",PlayerInfo[playerid][pTikis]);
                    SQL_UpdateInt(index, "Clothes",PlayerInfo[playerid][pClothes]);
                    SQL_UpdateInt(index, "PhoneNr",PlayerInfo[playerid][pPnumber]);
                    SQL_UpdateInt(index, "Apartment",PlayerInfo[playerid][pPaptkey]);
                    SQL_UpdateInt(index, "CarLic",PlayerInfo[playerid][pCarLic]);
                    SQL_UpdateInt(index, "FlyLic",PlayerInfo[playerid][pFlyLic]);
                    SQL_UpdateInt(index, "BoatLic",PlayerInfo[playerid][pBoatLic]);
                    SQL_UpdateInt(index, "FishLic",PlayerInfo[playerid][pFishLic]);
                    SQL_UpdateInt(index, "GunLic",PlayerInfo[playerid][pGunLic]);
                    SQL_UpdateInt(index, "Gun0",PlayerInfo[playerid][pGun0]);
                    SQL_UpdateInt(index, "Gun1",PlayerInfo[playerid][pGun1]);
                    SQL_UpdateInt(index, "Gun2",PlayerInfo[playerid][pGun2]);
                    SQL_UpdateInt(index, "Gun3",PlayerInfo[playerid][pGun3]);
                    SQL_UpdateInt(index, "InBusiness",PlayerInfo[playerid][InBusiness]);
                    SQL_UpdateInt(index, "BusinessInterior", PlayerInfo[playerid][BusinessInterior]);
                    SQL_UpdateInt(index, "BusinessExterior", PlayerInfo[playerid][BusinessExterior]);
                    SQL_UpdateInt(index, "Bizz",PlayerInfo[playerid][pPbiskey]);
                    SQL_UpdateInt(index, "Garage",PlayerInfo[playerid][pGarageKey]);
                    SQL_UpdateInt(index, "GarageII",PlayerInfo[playerid][pGarageKey2]);
                    SQL_UpdateInt(index, "House",PlayerInfo[playerid][pPhousekey]);
                    SQL_UpdateInt(index, "GateKey",PlayerInfo[playerid][pGateKey]);
                    SQL_UpdateInt(index, "GateKeyIA",PlayerInfo[playerid][pGateKey2]);
                    SQL_Update(index);

                    index = SQL_PrepareUpdate(playername);
                    SQL_UpdateInt(index, "GateKeyIB",PlayerInfo[playerid][pGateKey3]);
                    SQL_UpdateInt(index, "GateKeyIC",PlayerInfo[playerid][pGateKey4]);
                    SQL_UpdateInt(index, "GateKeyID",PlayerInfo[playerid][pGateKey5]);
                    SQL_UpdateInt(index, "GateKeyIE",PlayerInfo[playerid][pGateKey6]);
                    SQL_UpdateInt(index, "GateKeyIF",PlayerInfo[playerid][pGateKey7]);
                    SQL_UpdateInt(index, "GateKeyIG",PlayerInfo[playerid][pGateKey8]);
                    SQL_UpdateInt(index, "GateKeyIH",PlayerInfo[playerid][pGateKey9]);
                    SQL_UpdateInt(index, "GateKeyII",PlayerInfo[playerid][pGateKey10]);
                    SQL_UpdateFloat(index, "bExtX", PlayerInfo[playerid][bExtX]);
                    SQL_UpdateFloat(index, "bExtY", PlayerInfo[playerid][bExtY]);
                    SQL_UpdateFloat(index, "bExtZ", PlayerInfo[playerid][bExtZ]);
                    SQL_UpdateFloat(index, "bIntX", PlayerInfo[playerid][bIntX]);
                    SQL_UpdateFloat(index, "bIntY", PlayerInfo[playerid][bIntY]);
                    SQL_UpdateFloat(index, "bIntZ", PlayerInfo[playerid][bIntZ]);
                    SQL_UpdateInt(index, "Gun4",PlayerInfo[playerid][pGun4]);
                    SQL_UpdateInt(index, "Gun5",PlayerInfo[playerid][pGun5]);
                    SQL_UpdateInt(index, "Gun6",PlayerInfo[playerid][pGun6]);
                    SQL_UpdateInt(index, "Gun7",PlayerInfo[playerid][pGun7]);
                    SQL_UpdateInt(index, "Gun8",PlayerInfo[playerid][pGun8]);
                    SQL_UpdateInt(index, "Gun9",PlayerInfo[playerid][pGun9]);
                    SQL_UpdateInt(index, "Gun10",PlayerInfo[playerid][pGun10]);
                    SQL_UpdateInt(index, "Gun11",PlayerInfo[playerid][pGun11]);
                    SQL_UpdateInt(index, "Gun12",PlayerInfo[playerid][pGun12]);
                    SQL_UpdateInt(index, "CarTime",PlayerInfo[playerid][pCarTime]);
                    SQL_UpdateInt(index, "DrugsTime",PlayerInfo[playerid][pDrugsTime]);
                    SQL_UpdateInt(index, "LawyerTime",PlayerInfo[playerid][pLawyerTime]);
                    SQL_UpdateInt(index, "LawyerFreeTime",PlayerInfo[playerid][pLawyerFreeTime]);
                    SQL_UpdateInt(index, "MechTime",PlayerInfo[playerid][pMechTime]);
                    SQL_UpdateInt(index, "SexTime",PlayerInfo[playerid][pSexTime]);
                    SQL_UpdateInt(index, "PayDay",PlayerInfo[playerid][pPayDay]);
                    SQL_UpdateInt(index, "PayDayHad",PlayerInfo[playerid][pPayDayHad]);
                    SQL_UpdateInt(index, "CDPlayer",PlayerInfo[playerid][pCDPlayer]);
                    SQL_UpdateInt(index, "Dice",PlayerInfo[playerid][pDice]);
                    SQL_UpdateInt(index, "Screw",PlayerInfo[playerid][pScrew]);
                    SQL_UpdateInt(index, "Rope",PlayerInfo[playerid][pRope]);
                    SQL_UpdateInt(index, "AKmagazine",PlayerInfo[playerid][pAKmagazine]);
                    SQL_UpdateInt(index, "CSGmagazine",PlayerInfo[playerid][pCSGmagazine]);
                    SQL_UpdateInt(index, "Demagazine",PlayerInfo[playerid][pDemagazine]);
                    SQL_UpdateInt(index, "Cigars",PlayerInfo[playerid][pCigars]);
                    SQL_UpdateInt(index, "GoldBars",PlayerInfo[playerid][pGoldBars]);
                    SQL_UpdateInt(index, "Sprunk",PlayerInfo[playerid][pSprunk]);
                    SQL_UpdateInt(index, "WT",PlayerInfo[playerid][pWT]);
                    SQL_UpdateInt(index, "WTc",PlayerInfo[playerid][pWTc]);
                    SQL_UpdateInt(index, "Bombs",PlayerInfo[playerid][pBombs]);
                    SQL_UpdateInt(index, "Scope",PlayerInfo[playerid][pScope]);
                    SQL_UpdateInt(index, "OwnsMask",PlayerInfo[playerid][pOwnsMask]);
                    SQL_UpdateInt(index, "Wins",PlayerInfo[playerid][pWins]);
                    SQL_UpdateInt(index, "Loses",PlayerInfo[playerid][pLoses]);
                    SQL_UpdateInt(index, "OnDuty",PlayerInfo[playerid][pOnDuty]);
                    SQL_UpdateInt(index, "Hospital",PlayerInfo[playerid][pHospital]);
                    SQL_UpdateInt(index, "Adjustable",PlayerInfo[playerid][pAdjustable]);
                    SQL_UpdateInt(index, "Married",PlayerInfo[playerid][pMarried]);
                    SQL_UpdateString(index, "MarriedTo",PlayerInfo[playerid][pMarriedTo]);
                    SQL_UpdateString(index, "NormalName",PlayerInfo[playerid][pNormalName]);
                    SQL_UpdateString(index, "AdminName",PlayerInfo[playerid][pAdminName]);
                    SQL_UpdateString(index, "HelperName",PlayerInfo[playerid][pHelperName]);
                    SQL_UpdateInt(index, "AdminDuty",PlayerInfo[playerid][pAdminDuty]);
                    SQL_UpdateString(index, "ContractBy",PlayerInfo[playerid][pContractBy]);
                    SQL_UpdateString(index, "IP",PlayerInfo[playerid][pIP]);
                    SQL_UpdateInt(index, "WantedLevel",PlayerInfo[playerid][pWantedLevel]);
                    SQL_UpdateInt(index, "NewbieMuted",PlayerInfo[playerid][pNewbieMuted]);
                    SQL_UpdateInt(index, "RHmuted",PlayerInfo[playerid][prhmuted]);
                    SQL_UpdateInt(index, "ReportMuted",PlayerInfo[playerid][pReportMuted]);
                    SQL_UpdateInt(index, "AdvertiseMuted",PlayerInfo[playerid][pAdvertiseMuted]);
                    SQL_UpdateInt(index, "SafeSpawn",PlayerInfo[playerid][pSafeSpawn]);
                    SQL_UpdateFloat(index, "SPos_x",PlayerInfo[playerid][pSPos_x]);
                    SQL_UpdateFloat(index, "SPos_y",PlayerInfo[playerid][pSPos_y]);
                    SQL_UpdateFloat(index, "SPos_z",PlayerInfo[playerid][pSPos_z]);
                    SQL_UpdateFloat(index, "SPos_r",PlayerInfo[playerid][pSPos_r]);
                    SQL_UpdateInt(index, "AidKit",PlayerInfo[playerid][pAidKit]);
                    SQL_UpdateInt(index, "HelperLevel",PlayerInfo[playerid][pHelper]);
                    SQL_UpdateInt(index, "Mask",HasBoughtMask[playerid]);
                    SQL_UpdateInt(index, "Blindfolds",PlayerInfo[playerid][pBlindfolds]);
                    SQL_UpdateInt(index, "Speedo",gSpeedo[playerid]);
                    SQL_UpdateInt(index, "Seeds",PlayerInfo[playerid][pSeeds]);
                    SQL_UpdateInt(index, "Famed", PlayerInfo[playerid][pFamed]);
                    SQL_Update(index);
                }
                else printf("Warning: Could not update '%s'.", PlayerName(playerid));
            }
        }
    }
    return 1;
}
Help me please!


Re: OnPlayerSave don't work. - Virtual1ty - 01.01.2015

It is said on the Wiki that some functions like GetPlayerPos might not return correct results when called under OnPlayerDisconnect, the reason for this is the player is already reported as disconnected, your problem therefore could be in the IsPlayerConnected check.
So, save your data to variables and update them when they should be then just write them when a player disconnects.


Re: OnPlayerSave don't work. - alanhutch - 01.01.2015

Quote:
Originally Posted by Virtual1ty
Посмотреть сообщение
It is said on the Wiki that some functions like GetPlayerPos might not return correct results when called under OnPlayerDisconnect, the reason for this is the player is already reported as disconnected, your problem therefore could be in the IsPlayerConnected check.
So, save your data to variables and update them when they should be then just write them when a player disconnects.
I'm using the enums... That's ok?
Can you explain me better the system? (Sorry I'm bad in english...)

EDIT:
I have created a /savechars command, the same thing happens.


Re: OnPlayerSave don't work. - Virtual1ty - 01.01.2015

I can't say what's wrong for sure - check that "index" isn't "-1", also shouldn't it have "DB:" tag since you mentioned you're using SQLite.
Try placing prints and see where it fails.


Re: OnPlayerSave don't work. - alanhutch - 01.01.2015

Quote:
Originally Posted by Virtual1ty
Посмотреть сообщение
I can't say what's wrong for sure - check that "index" isn't "-1", also shouldn't it have "DB:" tag since you mentioned you're using SQLite.
Try placing prints and see where it fails.
Okay, I'm trying.


Re: OnPlayerSave don't work. - alanhutch - 01.01.2015

I've tried this...
pawn Код:
new stringa[256];
format(stringa, sizeof(stringa), "%s", index);
print(stringa);
The result is:
Код:
<null>



Re: OnPlayerSave don't work. - Virtual1ty - 01.01.2015

I have no idea what SQL_PrepareUpdate returns as it's clearly a custom written function so show that, and if you must check for valid handles, if that's what index represents, do the check like this:
pawn Код:
if (DB:index > 0)
Why could it be NULL is either the database file doesn't exist, query has an error, or the user couldn't be found in the table and others...


Re: OnPlayerSave don't work. - alanhutch - 01.01.2015

The file Accounts.db in the Scriptfiles is perfectly there, all tables etc are there...
Here's the SQL_PrepareUpdate.
pawn Код:
stock SQL_PrepareUpdate(name[])
{
    new index = -1;
    for (new i = 0; i < MAX_UPDATED_QUERIES; i ++)
    {
        if (!E_QUERY_EXISTS[i])
        {
            index = i;
            break;
        }
    }
    if (index != -1)
    {
        format(E_QUERY_DATA[index], 2048, "UPDATE `Accounts` SET ");
        E_QUERY_POSITION[index] = strlen(E_QUERY_DATA[index]);
        E_QUERY_EXISTS[index] = true;
        strpack(E_QUERY_NAME[index], name);
    }
    return index;
}



Re: OnPlayerSave don't work. - alanhutch - 01.01.2015

UPDATEE!
I have restored the Accounts.db file, now in the console says at the /savechars command:
Код:
<null>
Warning: Could not update 'William Hutchinson'
@William Hutchison



Re: OnPlayerSave don't work. - Virtual1ty - 01.01.2015

What a strange function, oh then you don't need the "DB:" tag and you're doing it wrong on printing "index", it is an integer and not a string so use "%d" in your "format".
Have you tried using normal (default) SQLite functions? Just to test that it isn't those custom functions you use, as you've clearly not written them! Make one test case and see. Also one other thing that comes to mind is make sure your Accounts.db file isn't set to "read-only".