db_get_field_assoc issue
#1

Hello i'm trying to load player data when his password was accepted however im getting this error in the server log:
Код:
[debug] #0 native db_get_field_assoc () from samp-server.exe
[debug] #1 001573d4 in public LoadPlayerAccount (0) from SAMP.amx
[debug] #2 001502cc in ?? (0, 667, 1, -1, 21274256) from SAMP.amx
[debug] #3 00008d54 in public OnDialogResponse (0, 667, 1, -1, 21274256) from SAMP.amx
I'm guessing the problem is with some db_get_field_assoc in LoadPlayerAccount public. I'll show the public, tell me if you see the issue:

pawn Код:
forward LoadPlayerAccount(playerid);
public LoadPlayerAccount(playerid)
{
    if(PlayerLogged[playerid] == true)
    {
        new DBResult:dbresult, szQuery[256];
        format(szQuery, sizeof(szQuery), "SELECT * FROM Accounts WHERE Username = '%s'", DB_Escape(PlayerInfo[playerid][Username]));
        dbresult = db_query(RP, szQuery);
        if(db_num_rows(dbresult) > 0)
        {
            new szValue[128];
            db_get_field_assoc(dbresult, "Age", szValue, sizeof(szValue));
            PlayerInfo[playerid][pAge] = strval(szValue);
            db_get_field_assoc(dbresult, "Cash", szValue, sizeof(szValue));
            PlayerInfo[playerid][pCash] = strval(szValue);
            db_get_field_assoc(dbresult, "Admin", szValue, sizeof(szValue));
            PlayerInfo[playerid][pAdmin] = strval(szValue);
            db_get_field_assoc(dbresult, "Kills", szValue, sizeof(szValue));
            PlayerInfo[playerid][pKills] = strval(szValue);
            db_get_field_assoc(dbresult, "Deaths", szValue, sizeof(szValue));
            PlayerInfo[playerid][pDeaths] = strval(szValue);
            db_get_field_assoc(dbresult, "dLSD", szValue, sizeof(szValue));
            PlayerInfo[playerid][dLSD] = strval(szValue);
            db_get_field_assoc(dbresult, "dCocaine", szValue, sizeof(szValue));
            PlayerInfo[playerid][dCocaine] = strval(szValue);
            db_get_field_assoc(dbresult, "dMarijuana", szValue, sizeof(szValue));
            PlayerInfo[playerid][dMarijuana] = strval(szValue);
            db_get_field_assoc(dbresult, "dMeth", szValue, sizeof(szValue));
            PlayerInfo[playerid][dMeth] = strval(szValue);
            db_get_field_assoc(dbresult, "dEcstasy", szValue, sizeof(szValue));
            PlayerInfo[playerid][dEcstasy] = strval(szValue);
            db_get_field_assoc(dbresult, "Respect", szValue, sizeof(szValue));
            PlayerInfo[playerid][pRespect] = strval(szValue);
            db_get_field_assoc(dbresult, "Cigarettes", szValue, sizeof(szValue));
            PlayerInfo[playerid][pCigarettes] = strval(szValue);
            db_get_field_assoc(dbresult, "BankAccount", szValue, sizeof(szValue));
            PlayerInfo[playerid][pBankAccount] = strval(szValue);
            db_get_field_assoc(dbresult, "AccountData", szValue, sizeof(szValue));
            PlayerInfo[playerid][pAccountdata] = strval(szValue);
            db_get_field_assoc(dbresult, "Beer", szValue, sizeof(szValue));
            PlayerInfo[playerid][pBeer] = strval(szValue);
            db_get_field_assoc(dbresult, "Mapper", szValue, sizeof(szValue));
            PlayerInfo[playerid][pMapper] = strval(szValue);
            db_get_field_assoc(dbresult, "Health", szValue, sizeof(szValue));
            PlayerInfo[playerid][pHealth] = floatstr(szValue);
            db_get_field_assoc(dbresult, "Armour", szValue, sizeof(szValue));
            PlayerInfo[playerid][pArmour] = floatstr(szValue);
            db_get_field_assoc(dbresult, "Number", szValue, sizeof(szValue));
            PlayerInfo[playerid][pNumber] = strval(szValue);
            db_get_field_assoc(dbresult, "Skin", szValue, sizeof(szValue));
            PlayerInfo[playerid][pSkin] = strval(szValue);
            db_get_field_assoc(dbresult, "BizID", szValue, sizeof(szValue));
            PlayerInfo[playerid][BizID] = strval(szValue);
            db_get_field_assoc(dbresult, "HouseID", szValue, sizeof(szValue));
            PlayerInfo[playerid][HouseID] = strval(szValue);
            db_get_field_assoc(dbresult, "Level", szValue, sizeof(szValue));
            PlayerInfo[playerid][pLevel] = strval(szValue);
            db_get_field_assoc(dbresult, "BusinessMoney", szValue, sizeof(szValue));
            PlayerInfo[playerid][BusinessMoney] = strval(szValue);
            db_get_field_assoc(dbresult, "DriverLicense", szValue, sizeof(szValue));
            PlayerInfo[playerid][pDriverLicense] = strval(szValue);
            db_get_field_assoc(dbresult, "Gender", szValue, sizeof(szValue));
            PlayerInfo[playerid][pGender] = strval(szValue);
            db_get_field_assoc(dbresult, "InJail", szValue, sizeof(szValue));
            PlayerInfo[playerid][pInJail] = strval(szValue);
            db_get_field_assoc(dbresult, "InJailTime", szValue, sizeof(szValue));
            PlayerInfo[playerid][pInJailTime] = strval(szValue);
            db_get_field_assoc(dbresult, "BoomBox", szValue, sizeof(szValue));
            PlayerInfo[playerid][pBoombox] = strval(szValue);
            db_get_field_assoc(dbresult, "Mask", szValue, sizeof(szValue));
            PlayerInfo[playerid][pMask] = strval(szValue);
            db_get_field_assoc(dbresult, "FightingStyle", szValue, sizeof(szValue));
            PlayerInfo[playerid][pFightingStyle] = strval(szValue);
            db_get_field_assoc(dbresult, "XPos", szValue, sizeof(szValue));
            PlayerInfo[playerid][pXPos] = floatstr(szValue);
            db_get_field_assoc(dbresult, "YPos", szValue, sizeof(szValue));
            PlayerInfo[playerid][pYPos] = floatstr(szValue);
            db_get_field_assoc(dbresult, "ZPos", szValue, sizeof(szValue));
            PlayerInfo[playerid][pZPos] = floatstr(szValue);
            db_get_field_assoc(dbresult, "VirtualWorld", szValue, sizeof(szValue));
            PlayerInfo[playerid][pVirtualWorld] = strval(szValue);
            db_get_field_assoc(dbresult, "Banned", szValue, sizeof(szValue));
            PlayerInfo[playerid][pBanned] = strval(szValue);
            db_get_field_assoc(dbresult, "BannedReason", PlayerInfo[playerid][pBanReason], 64);
            db_get_field_assoc(dbresult, "BannedBy", PlayerInfo[playerid][pBannedBy], 24);
            db_get_field_assoc(dbresult, "BannedIP", PlayerInfo[playerid][BannedIP], 16);
            db_get_field_assoc(dbresult, "Origin", PlayerInfo[playerid][pOrigin], 24);
            db_get_field_assoc(dbresult, "Experience", szValue, sizeof(szValue));
            PlayerInfo[playerid][pExperience] = strval(szValue);
            db_get_field_assoc(dbresult, "dSeeds", szValue, sizeof(szValue));
            PlayerInfo[playerid][dSeeds] = strval(szValue);
            db_get_field_assoc(dbresult, "dWater", szValue, sizeof(szValue));
            PlayerInfo[playerid][dWater] = strval(szValue);
            db_get_field_assoc(dbresult, "Crashed", szValue, sizeof(szValue));
            PlayerInfo[playerid][pCrashed] = strval(szValue);
            db_get_field_assoc(dbresult, "CrashX", szValue, sizeof(szValue));
            PlayerInfo[playerid][pCrashX] = floatstr(szValue);
            db_get_field_assoc(dbresult, "CrashY", szValue, sizeof(szValue));
            PlayerInfo[playerid][pCrashY] = floatstr(szValue);
            db_get_field_assoc(dbresult, "CrashZ", szValue, sizeof(szValue));
            PlayerInfo[playerid][pCrashZ] = floatstr(szValue);
            db_get_field_assoc(dbresult, "CrashedInt", szValue, sizeof(szValue));
            PlayerInfo[playerid][pCrashInt] = strval(szValue);
            db_get_field_assoc(dbresult, "CrashedWorld", szValue, sizeof(szValue));
            PlayerInfo[playerid][pCrashWorld] = strval(szValue);
            db_get_field_assoc(dbresult, "PlayerOwnsHouse", szValue, sizeof(szValue));
            PlayerInfo[playerid][pPlayerOwnsHouse] = strval(szValue);
            db_get_field_assoc(dbresult, "fRank", szValue, sizeof(szValue));
            PlayerInfo[playerid][fRank] = strval(szValue);
            db_get_field_assoc(dbresult, "WepLicense", szValue, sizeof(szValue));
            PlayerInfo[playerid][pWepLicense] = strval(szValue);
            db_get_field_assoc(dbresult, "Phone", szValue, sizeof(szValue));
            PlayerInfo[playerid][pPhone] = strval(szValue);
            db_get_field_assoc(dbresult, "Faction", szValue, sizeof(szValue));
            PlayerInfo[playerid][pFaction] = strval(szValue);
            db_get_field_assoc(dbresult, "FishingRod", szValue, sizeof(szValue));
            PlayerInfo[playerid][pFishingRod] = strval(szValue);
            db_get_field_assoc(dbresult, "Worms", szValue, sizeof(szValue));
            PlayerInfo[playerid][pWorms] = strval(szValue);
            db_get_field_assoc(dbresult, "Fishes", szValue, sizeof(szValue));
            PlayerInfo[playerid][pHealth] = strval(szValue);
            db_get_field_assoc(dbresult, "PlayingHours", szValue, sizeof(szValue));
            PlayerInfo[playerid][pPlayingHours] = strval(szValue);
            db_get_field_assoc(dbresult, "PlayTime", szValue, sizeof(szValue));
            PlayerInfo[playerid][pPlayTime] = strval(szValue);
            db_get_field_assoc(dbresult, "Job", szValue, sizeof(szValue));
            PlayerInfo[playerid][pJob] = strval(szValue);
            db_get_field_assoc(dbresult, "JobCash", szValue, sizeof(szValue));
            PlayerInfo[playerid][pJobCash] = strval(szValue);
            db_get_field_assoc(dbresult, "TutorialDone", szValue, sizeof(szValue));
            PlayerInfo[playerid][pTutorialDone] = strval(szValue);
            db_get_field_assoc(dbresult, "Note1", PlayerInfo[playerid][pNote1], 128);
            db_get_field_assoc(dbresult, "Note2", PlayerInfo[playerid][pNote2], 128);
            db_get_field_assoc(dbresult, "Note3", PlayerInfo[playerid][pNote3], 128);
            db_get_field_assoc(dbresult, "Note4", PlayerInfo[playerid][pNote4], 128);
            db_get_field_assoc(dbresult, "GunRights", szValue, sizeof(szValue));
            PlayerInfo[playerid][pGunRights] = strval(szValue);
            db_get_field_assoc(dbresult, "Seeds", szValue, sizeof(szValue));
            PlayerInfo[playerid][pSeeds] = strval(szValue);
            db_get_field_assoc(dbresult, "Caller", szValue, sizeof(szValue));
            PlayerInfo[playerid][pCaller] = strval(szValue);
            db_get_field_assoc(dbresult, "RegisterDate", PlayerInfo[playerid][pDate], 32);
            db_get_field_assoc(dbresult, "Donator", szValue, sizeof(szValue));
            PlayerInfo[playerid][pDonator] = strval(szValue);
            db_get_field_assoc(dbresult, "BlockPM", szValue, sizeof(szValue));
            PlayerInfo[playerid][pBlockPM] = strval(szValue);
            db_get_field_assoc(dbresult, "ForumName", PlayerInfo[playerid][pForumName], 24);
            db_get_field_assoc(dbresult, "fName", szValue, sizeof(szValue));
            PlayerInfo[playerid][pFname] = strval(szValue);
            db_get_field_assoc(dbresult, "Jailed", szValue, sizeof(szValue));
            PlayerInfo[playerid][pJailed] = strval(szValue);
            db_get_field_assoc(dbresult, "VehicleKey", szValue, sizeof(szValue));
            PlayerInfo[playerid][pVehicleKey] = strval(szValue);
            db_get_field_assoc(dbresult, "dHeroin", szValue, sizeof(szValue));
            PlayerInfo[playerid][dHeroin] = strval(szValue);
            db_get_field_assoc(dbresult, "dCrack", szValue, sizeof(szValue));
            PlayerInfo[playerid][dCrack] = strval(szValue);
            db_get_field_assoc(dbresult, "ActiveOffenses", szValue, sizeof(szValue));
            PlayerInfo[playerid][pActiveOffenses] = strval(szValue);
            db_get_field_assoc(dbresult, "ActiveOffense", PlayerInfo[playerid][pActiveOffense], 128);
            db_get_field_assoc(dbresult, "UnActiveOffenses", szValue, sizeof(szValue));
            PlayerInfo[playerid][pUnActiveOffenses] = strval(szValue);
            db_get_field_assoc(dbresult, "Plate1", szValue, sizeof(szValue));
            PlayerInfo[playerid][pPlate1] = strval(szValue);
            db_get_field_assoc(dbresult, "Plate2", szValue, sizeof(szValue));
            PlayerInfo[playerid][pPlate2] = strval(szValue);
            db_get_field_assoc(dbresult, "Plate3", szValue, sizeof(szValue));
            PlayerInfo[playerid][pPlate3] = strval(szValue);
            db_get_field_assoc(dbresult, "pTicketReason1", PlayerInfo[playerid][pTicketReason1], 128);
            db_get_field_assoc(dbresult, "pTicketReason2", PlayerInfo[playerid][pTicketReason2], 128);
            db_get_field_assoc(dbresult, "Ticket1", szValue, sizeof(szValue));
            PlayerInfo[playerid][pTicket1] = strval(szValue);
            db_get_field_assoc(dbresult, "Ticket2", szValue, sizeof(szValue));
            PlayerInfo[playerid][pTicket2] = strval(szValue);
            db_get_field_assoc(dbresult, "TicketPrice1", szValue, sizeof(szValue));
            PlayerInfo[playerid][pTicketPrice1] = strval(szValue);
            db_get_field_assoc(dbresult, "TicketPrice2", szValue, sizeof(szValue));
            PlayerInfo[playerid][pTicketPrice2] = strval(szValue);
            db_get_field_assoc(dbresult, "Welfare", szValue, sizeof(szValue));
            PlayerInfo[playerid][pWelfare] = strval(szValue);
            db_get_field_assoc(dbresult, "WalkStyle", szValue, sizeof(szValue));
            PlayerInfo[playerid][pWalkStyle] = strval(szValue);
            db_get_field_assoc(dbresult, "pWeapon1", szValue, sizeof(szValue));
            PlayerInfo[playerid][pWeapon1] = strval(szValue);
            db_get_field_assoc(dbresult, "Ammo1", szValue, sizeof(szValue));
            PlayerInfo[playerid][pAmmo1] = strval(szValue);
            db_get_field_assoc(dbresult, "Weapon2", szValue, sizeof(szValue));
            PlayerInfo[playerid][pWeapon2] = strval(szValue);
            db_get_field_assoc(dbresult, "Ammo2", szValue, sizeof(szValue));
            PlayerInfo[playerid][pAmmo2] = strval(szValue);
            db_get_field_assoc(dbresult, "Weapon3", szValue, sizeof(szValue));
            PlayerInfo[playerid][pWeapon3] = strval(szValue);
            db_get_field_assoc(dbresult, "Ammo3", szValue, sizeof(szValue));
            PlayerInfo[playerid][pAmmo3] = strval(szValue);
            db_get_field_assoc(dbresult, "Weapon4", szValue, sizeof(szValue));
            PlayerInfo[playerid][pWeapon4] = strval(szValue);
            db_get_field_assoc(dbresult, "Ammo4", szValue, sizeof(szValue));
            PlayerInfo[playerid][pAmmo4] = strval(szValue);
            db_get_field_assoc(dbresult, "Weapon5", szValue, sizeof(szValue));
            PlayerInfo[playerid][pWeapon5] = strval(szValue);
            db_get_field_assoc(dbresult, "Ammo5", szValue, sizeof(szValue));
            PlayerInfo[playerid][pAmmo5] = strval(szValue);
            db_get_field_assoc(dbresult, "Weapon6", szValue, sizeof(szValue));
            PlayerInfo[playerid][pWeapon6] = strval(szValue);
            db_get_field_assoc(dbresult, "Ammo6", szValue, sizeof(szValue));
            PlayerInfo[playerid][pAmmo6] = strval(szValue);
            db_get_field_assoc(dbresult, "Weapon7", szValue, sizeof(szValue));
            PlayerInfo[playerid][pWeapon7] = strval(szValue);
            db_get_field_assoc(dbresult, "Ammo7", szValue, sizeof(szValue));
            PlayerInfo[playerid][pAmmo7] = strval(szValue);
            db_get_field_assoc(dbresult, "Weapon8", szValue, sizeof(szValue));
            PlayerInfo[playerid][pWeapon8] = strval(szValue);
            db_get_field_assoc(dbresult, "Ammo8", szValue, sizeof(szValue));
            PlayerInfo[playerid][pAmmo8] = strval(szValue);
            db_get_field_assoc(dbresult, "Weapon9", szValue, sizeof(szValue));
            PlayerInfo[playerid][pWeapon9] = strval(szValue);
            db_get_field_assoc(dbresult, "Ammo9", szValue, sizeof(szValue));
            PlayerInfo[playerid][pAmmo9] = strval(szValue);
            db_get_field_assoc(dbresult, "Weapon10", szValue, sizeof(szValue));
            PlayerInfo[playerid][pWeapon10] = strval(szValue);
            db_get_field_assoc(dbresult, "Ammo10", szValue, sizeof(szValue));
            PlayerInfo[playerid][pAmmo10] = strval(szValue);
            db_get_field_assoc(dbresult, "Weapon11", szValue, sizeof(szValue));
            PlayerInfo[playerid][pWeapon11] = strval(szValue);
            db_get_field_assoc(dbresult, "Ammo11", szValue, sizeof(szValue));
            PlayerInfo[playerid][pAmmo11] = strval(szValue);
            db_get_field_assoc(dbresult, "Weapon12", szValue, sizeof(szValue));
            PlayerInfo[playerid][pWeapon12] = strval(szValue);
            db_get_field_assoc(dbresult, "Ammo12", szValue, sizeof(szValue));
            PlayerInfo[playerid][pAmmo12] = strval(szValue);
            db_get_field_assoc(dbresult, "Weapon13", szValue, sizeof(szValue));
            PlayerInfo[playerid][pWeapon13] = strval(szValue);
            db_get_field_assoc(dbresult, "Ammo13", szValue, sizeof(szValue));
            PlayerInfo[playerid][pAmmo13] = strval(szValue);
            db_get_field_assoc(dbresult, "Interior", szValue, sizeof(szValue));
            PlayerInfo[playerid][pInterior] = strval(szValue);
            db_get_field_assoc(dbresult, "CurrentDialog", szValue, sizeof(szValue));
            PlayerInfo[playerid][CurrentDialog] = strval(szValue);
            db_get_field_assoc(dbresult, "Gate1", szValue, sizeof(szValue));
            PlayerInfo[playerid][pGate][0] = strval(szValue);
            db_get_field_assoc(dbresult, "Gate2", szValue, sizeof(szValue));
            PlayerInfo[playerid][pGate][1] = strval(szValue);
            db_get_field_assoc(dbresult, "Gate3", szValue, sizeof(szValue));
            PlayerInfo[playerid][pGate][2] = strval(szValue);
            db_get_field_assoc(dbresult, "DynamicFac", szValue, sizeof(szValue));
            PlayerInfo[playerid][pDynamicFac] = strval(szValue);
        }
        db_free_result(dbresult);
        printf("%s has successfully loaded.", GetName(playerid));
    }
    return 1;
}
I can't figure out where is the problem! maybe its because the public looks very messy?
Reply
#2

Try the divide and conquer approach comment out half the code and see if it happens if it does then comment out half again until it doesn't then you can narrow down the problem line quickly or you can put a print() after each line until you see where it stops.
Reply
#3

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Try the divide and conquer approach comment out half the code and see if it happens if it does then comment out half again until it doesn't then you can narrow down the problem line quickly or you can put a print() after each line until you see where it stops.
The problem seems to come from those lines:
Код:
db_get_field_assoc(dbresult, "BannedReason", PlayerInfo[playerid][pBanReason], 64);
db_get_field_assoc(dbresult, "BannedBy", PlayerInfo[playerid][pBannedBy], 24);
db_get_field_assoc(dbresult, "BannedIP", PlayerInfo[playerid][BannedIP], 16);
db_get_field_assoc(dbresult, "Origin", PlayerInfo[playerid][pOrigin], 24);
I still can't figure out the problem (Its 4 strings which im loadings into the variables..everything is currect)
Reply
#4

made something like this:
Код:
if(PlayerInfo[playerid][pBanned] == 1)
{
        db_get_field_assoc(dbresult, "BannedReason", PlayerInfo[playerid][pBanReason], 64);
	db_get_field_assoc(dbresult, "BannedBy", PlayerInfo[playerid][pBannedBy], 24);
	db_get_field_assoc(dbresult, "BannedIP", PlayerInfo[playerid][BannedIP], 16);
}
And its fixed now! Thanks Pottus for the advice
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)