MySQL dont load users items
#1

Hey, I got a problem with my MySQL account system. It refuses to give players their stats.
This is my loadstats:

pawn Код:
stock LoadStats(playerid)
{
    new Query[1024],result[200];
    format(Query, sizeof(Query), "SELECT * FROM `users` WHERE `Username` = '%s'", GetPName(playerid));
    mysql_query(Query);
    mysql_fetch_field("AdminLevel", result);
    PlayerInfo[playerid][pAdmin] = strval(result);
    PlayerInfo[playerid][Logged] = 1;
    gPlayerLogged[playerid] = 1;
    mysql_store_result();
    mysql_free_result();
    return 1;
}
Dont know why it refuses to give the players their admin
Reply
#2

It goes like that:

Executing query.
Storing result.
Assigning data somewhere.
Freeing result.
Reply
#3

So how should it be?
Reply
#4

pawn Код:
stock LoadStats(playerid)
{
    new Query[64],result[6]; // beware of the lenght - count to be sure!
    format(Query, sizeof(Query), "SELECT * FROM `users` WHERE `Username` = '%s'", GetPName(playerid));
    mysql_query(Query);
    mysql_store_result();
    if(mysql_num_rows() != 0) mysql_fetch_field("AdminLevel", result);
    PlayerInfo[playerid][pAdmin] = strval(result);
    PlayerInfo[playerid][Logged] = 1;
    gPlayerLogged[playerid] = 1; // double ??
    mysql_free_result();
    return 1;
}
Reply
#5

oh okey! thank you

And I was going to add more stats, it was just for testing with the admin lvl
Reply
#6

still dosent work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)