MySQL minor issue
#1

I'm having a small issue with my MySQL account system.

When I am loading an account, or create a new account in the script it sets the "pAdmin" variable to 50.

I have no idea why it's doing it, here is the loading (Everything else loads as it should)

pawn Код:
forward OnLoadAccount(playerid);
public OnLoadAccount(playerid){
    if(!cache_num_rows()){
        format(str, sizeof(str), "Welcome to Project Roleplay, %s.\n\nThis account exists; login by entering your password below:\n\n{FF0000}INVALID PASSWORD", PlayerRPName(playerid));
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "GTA - Project Roleplay: {FFFFFF}Login", str, "Login", "Quit");
        return 1;
    }
   
    DefaultPlayerValues(playerid);
   
   
    PlayerInfo[playerid][pID] = cache_get_field_content_int(0, "ID", sqlConnection);
    PlayerInfo[playerid][pAdmin] = cache_get_field_content_int(0, "Admin", sqlConnection);
   
   
    PlayerInfo[playerid][pSkin] = cache_get_field_content_int(0, "Skin", sqlConnection);
    PlayerInfo[playerid][pFaction] = cache_get_field_content_int(0, "Faction", sqlConnection);
    PlayerInfo[playerid][pRank] = cache_get_field_content_int(0, "Rank", sqlConnection);
   
    format(PlayerInfo[playerid][pIP], 20, "%s", PlayerIP(playerid));
   
    SendClientMessage(playerid, COLOR_YELLOW, "You have successfully logged into Project Roleplay. Enjoy your stay!");
   
    SetPlayerToSpawn(playerid, SPAWN_NEWB);
   
    LoggedIn[playerid] = true;
    return 1;
}
This is DefaultPlayerValues

pawn Код:
stock DefaultPlayerValues(playerid){
    PlayerInfo[playerid][pID] = 0; PlayerInfo[playerid][pAdmin] = 0; PlayerInfo[playerid][pSkin] = NEWB_SKIN; LoggedIn[playerid] = false; PlayerInfo[playerid][pFaction] = 0;
    PlayerInfo[playerid][pRank] = 0;
   
    return 1;
}

Here is a test command I created to check it, and it prints "50".

pawn Код:
CMD:test(playerid, params[]){
    format(str, sizeof(str), "Admin VAR: %d", PlayerInfo[playerid][pAdmin]);
    SendClientMessage(playerid, COLOR_WHITE, str);
    return 1;  
}
Any ideas?


EDIT: Here's my SQL config (table)

Reply
#2

I have but one possible explanation: that column is a text type column. If the character 2 is stored and you try to fetch it as an int you will get its numerical character code, which is 50. See: http://www.asciitable.com/
Reply
#3

I've checked that Vince and it's stored as an integer, here's an image of the Admin defined in the table:

Reply
#4

Just done a test in game and the following information is printed from this command:

pawn Код:
CMD:test(playerid, params[]){
    format(str, sizeof(str), "Admin VAR: %d | Skin Var: %d | Faction Var: %d | Rank Var: %d", PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pFaction], PlayerInfo[playerid][pRank]);
    SendClientMessage(playerid, COLOR_WHITE, str);
    return 1;  
}


< The actual values


When logging in and printing straight after, it displays:

Though when doing /test ingame, it displays the above.
Reply
#5

Figured out the issue.

It was regarding the following code:

pawn Код:
format(PlayerInfo[playerid][pIP], 20, "%s", PlayerIP(playerid));

stock PlayerIP(playerid){
    new IP[20];
    GetPlayerIp(playerid, IP, sizeof(IP));
    return IP;
}
Somehow, it was setting different settings than it should have been
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)