Mysql R38 Save/Load problem
#1

Hello all,

I recently converted my account system from mysql r15 to r38.
Now i have some problems with saving/loading.
When i register and i quit server its saving good.
But the problem is when i join server and i login with my account its changing some values in the mysql database and loading that values.
Like if i login its loading the Seconds field as Score field.
pawn Код:
stock LoadPlayer(playerid)
{
    #if LOAD_PLAYER_POS == true
    SetPVarInt(playerid, "1stSpawn", 1);
    #endif
    new query[500];
    mysql_format(gSQL, query, sizeof(query),"SELECT `XPos`,`YPos`,`ZPos`,`AdminLevel`,`VIPLevel`,`WantedLevel`,`Kills`,`Deaths`,`Money`,`Score`,`Health`,`Armour`,`Hours`,`Minutes`,`Seconds`,`KickCount`,`LastSkin`,`SpawnCount`,`ReportCount`,`RegDate`,`Bank`,`Interior`,`World`,`Class`,`Skill`,`FightingStyle`,`Speedo`,`AllowPMS`,`JailTime`,`House`,`ID`,`HasCars`,`CarSlots` FROM `"#MYSQL_ACCOUNT_TABLE"` WHERE `PlayerName` = '%s'", GetName(playerid));
    mysql_tquery(gSQL, query, "LoadPlayerMYSQL", "i", playerid);
    return 1;
}

forward LoadPlayerMYSQL(playerid);
public LoadPlayerMYSQL(playerid)
{
    //if(pQueryQueue[playerid]!= QueryQueue)return 1;
    new rows, fields;
    cache_get_data(rows, fields);
    if(rows)
    {
        //cache_get_row(0, 1, GetPlayeridName(playerid)); // Store the data from the name field into the name string.
        PlayerInfo[playerid][YPos]= cache_get_row_float(0, 5);
        PlayerInfo[playerid][YPos] = cache_get_row_float(0, 6);
        PlayerInfo[playerid][ZPos] = cache_get_row_float(0, 7);
        PlayerInfo[playerid][AdminLevel] = cache_get_row_int(0, 8);
        PlayerInfo[playerid][VIPLevel] = cache_get_row_int(0, 9);
        PlayerInfo[playerid][pWantedLevel] = cache_get_row_int(0, 10);
        PlayerInfo[playerid][Kills] = cache_get_row_int(0, 11);
        PlayerInfo[playerid][Deaths] = cache_get_row_int(0, 12);
        PlayerInfo[playerid][pMoney] = cache_get_row_int(0, 13);
        PlayerInfo[playerid][pScore] = cache_get_row_int(0, 14);//Gets loaded as Seconds field (field 19 while the score field is field 14)
        PlayerInfo[playerid][Health] = cache_get_row_float(0, 15);
        PlayerInfo[playerid][Armour] = cache_get_row_float(0, 16);
        PlayerInfo[playerid][Hours] = cache_get_row_int(0, 17);
        PlayerInfo[playerid][Minutes] = cache_get_row_int(0, 18);
        PlayerInfo[playerid][Seconds] = cache_get_row_int(0, 19);
        PlayerInfo[playerid][LastSkin] = cache_get_row_int(0, 20);
        PlayerInfo[playerid][KickCount] = cache_get_row_int(0, 21);
        PlayerInfo[playerid][SpawnCount] = cache_get_row_int(0, 22);
        PlayerInfo[playerid][ReportCount] = cache_get_row_int(0, 23);
        PlayerInfo[playerid][RegDate] = cache_get_row_int(0, 24);
        PlayerInfo[playerid][pBank] = cache_get_row_int(0, 28);
        PlayerInfo[playerid][pInterior] = cache_get_row_int(0, 29);
        PlayerInfo[playerid][pVirtualWorld] = cache_get_row_int(0, 30);
        PlayerInfo[playerid][pClass] = cache_get_row_int(0, 31);
        PlayerInfo[playerid][pSkill] = cache_get_row_int(0, 32);
        PlayerInfo[playerid][FightingStyle] = cache_get_row_int(0, 33);
        PlayerInfo[playerid][pSpeedo] = cache_get_row_int(0, 34);
        PlayerInfo[playerid][pAllowPMS] = cache_get_row_int(0, 35);
        PlayerInfo[playerid][pJailTime] = cache_get_row_int(0, 36);
        PlayerInfo[playerid][pHouse] = cache_get_row_int(0, 37);
        PlayerInfo[playerid][pPlayerID] = cache_get_row_int(0, 38);
        PlayerInfo[playerid][pHasCars] = cache_get_row_int(0, 39);
        PlayerInfo[playerid][pCarSlots] = cache_get_row_int(0, 40);
        SetPlayerServerMoney(playerid, PlayerInfo[playerid][pMoney]);
        SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
        PlayerInfo[playerid][Logged] = true;
        PlayerClass[playerid]=PlayerInfo[playerid][pClass];
        gTeam[playerid]=PlayerInfo[playerid][pSkill];
        PlayerSpeedo[playerid]=PlayerInfo[playerid][pSpeedo];
        PlayerAllowPMS[playerid]=PlayerInfo[playerid][pAllowPMS];
        PlayerJailTime[playerid]=PlayerInfo[playerid][pJailTime];
        PlayerHouse[playerid]=PlayerInfo[playerid][pHouse];
        PlayerWantedLevel[playerid]=PlayerInfo[playerid][pWantedLevel];
       
       
    }
    return 1;          
}
Can someone help me to fix this?
I really need to fix this.

Admigo
Reply
#2

You do: "`XPos`,`YPos`,`ZPos`,`AdminLevel`,`VIPLevel`"

So that means 'YPos' will be field 1, not field 7.

PlayerInfo[playerid][YPos]= cache_get_row_float(0, 1);

Same with X:

So that means 'XPos' will be field 0, not field 5.

PlayerInfo[playerid][YPos]= cache_get_row_float(0, 0);

If you did SELECT * - Then it would start from the real row IDs that appear in the database, but cause you selected specific data, the data starts at 0 incrementing.
Reply
#3

Quote:
Originally Posted by KyleSmith
Посмотреть сообщение
You do: "`XPos`,`YPos`,`ZPos`,`AdminLevel`,`VIPLevel`"

So that means 'YPos' will be field 1, not field 7.

PlayerInfo[playerid][YPos]= cache_get_row_float(0, 1);

Same with X:

So that means 'XPos' will be field 0, not field 5.

PlayerInfo[playerid][YPos]= cache_get_row_float(0, 0);

If you did SELECT * - Then it would start from the real row IDs that appear in the database, but cause you selected specific data, the data starts at 0 incrementing.
I didnt know this. Thanks. Fixed.
Reply
#4

what about this? it's more simple
pawn Код:
cache_get_field_content(0, "XPos");
Reply
#5

I have same problemas, how you did fix it?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)