Stats not loading
#1

Hey, i'm using BlueG's plugin, but as soon as you login, it doesnt load your stats.
I hope someone knows what i'm doing wrong.
pawn Код:
stock MySQL_Login(playerid)
{
    new Query[500];
    mysql_real_escape_string(pInfo[playerid][Nick], pInfo[playerid][Nick]); // escaping the name of the player to avoid sql_injections.
    format(Query, sizeof(Query), "SELECT * FROM `playerdata` WHERE `nick` COLLATE latin1_general_cs = '%s' LIMIT 1", pInfo[playerid][Nick]);
    mysql_query(Query);
    mysql_store_result();
    if(mysql_num_rows() > 0)
    {
        new line[500];
        new data[42];
        mysql_fetch_row(line);
        sscanf(line, "p<|>iiiiii",
            data[0],
            data[1],
            data[2],
            data[3],
            data[4],
            data[5]);
        data[0] = pInfo[playerid][ID];
        data[1] = pInfo[playerid][pAdmin];
        data[2] = pInfo[playerid][pScore];
        SetPlayerScore(playerid, pInfo[playerid][pScore]);
        data[3] = pInfo[playerid][pMoney];
        GivePlayerMoney(playerid, pInfo[playerid][pMoney]);
        data[4] = pInfo[playerid][pKills];
        data[5] = pInfo[playerid][pDeaths];
    }
    mysql_free_result();
    pInfo[playerid][Logged] = 1;
}
Reply
#2

pawn Код:
stock MySQL_Login(playerid)
{
    new Query[500];
    mysql_real_escape_string(pInfo[playerid][Nick], pInfo[playerid][Nick]); // escaping the name of the player to avoid sql_injections.
    format(Query, sizeof(Query), "SELECT * FROM `playerdata` WHERE `nick` COLLATE latin1_general_cs = '%s' LIMIT 1", pInfo[playerid][Nick]);
    mysql_query(Query);
    mysql_store_result();
    while(mysql_fetch_row_format(Query,"|"))
    {
        mysql_fetch_field_row("id", pInfo[playerid][ID]);
        mysql_fetch_field_row("admin", pInfo[playerid][pAdmin]);
        mysql_fetch_field_row("score", pInfo[playerid][pScore]); SetPlayerScore(playerid, pInfo[playerid][pScore]);
        mysql_fetch_field_row("money", pInfo[playerid][pMoney]); GivePlayerMoney(playerid, pInfo[playerid][pMoney]);
        mysql_fetch_field_row("kills", pInfo[playerid][pKills]);
        mysql_fetch_field_row("deaths", pInfo[playerid][pDeaths]);
    }
    mysql_free_result();
    pInfo[playerid][Logged] = 1;
}
Reply
#3

Quote:
Originally Posted by Danyal
Посмотреть сообщение
pawn Код:
stock MySQL_Login(playerid)
{
    new Query[500];
    mysql_real_escape_string(pInfo[playerid][Nick], pInfo[playerid][Nick]); // escaping the name of the player to avoid sql_injections.
    format(Query, sizeof(Query), "SELECT * FROM `playerdata` WHERE `nick` COLLATE latin1_general_cs = '%s' LIMIT 1", pInfo[playerid][Nick]);
    mysql_query(Query);
    mysql_store_result();
    while(mysql_fetch_row_format(Query,"|"))
    {
        mysql_fetch_field_row("id", pInfo[playerid][ID]);
        mysql_fetch_field_row("admin", pInfo[playerid][pAdmin]);
        mysql_fetch_field_row("score", pInfo[playerid][pScore]); SetPlayerScore(playerid, pInfo[playerid][pScore]);
        mysql_fetch_field_row("money", pInfo[playerid][pMoney]); GivePlayerMoney(playerid, pInfo[playerid][pMoney]);
        mysql_fetch_field_row("kills", pInfo[playerid][pKills]);
        mysql_fetch_field_row("deaths", pInfo[playerid][pDeaths]);
    }
    mysql_free_result();
    pInfo[playerid][Logged] = 1;
}
That didnt work.
Reply
#4

I suggest you using sscanf to load something (MySQL R6 Below), it's faster and easier than mysql_fetch_field_row
Reply
#5

Quote:
Originally Posted by pds2k12
Посмотреть сообщение
I suggest you using sscanf to load something (MySQL R6 Below), it's faster and easier than mysql_fetch_field_row
Yea, my friend has suggested this code:
pawn Код:
stock MySQL_Login(playerid)
{
    new Query[500];
    mysql_real_escape_string(pInfo[playerid][Nick], pInfo[playerid][Nick]); // escaping the name of the player to avoid sql_injections.
    format(Query, sizeof(Query), "SELECT * FROM `playerdata` WHERE `nick` COLLATE latin1_general_cs = '%s' LIMIT 1", pInfo[playerid][Nick]);
    mysql_query(Query);
    mysql_store_result();
    if(mysql_num_rows() > 0)
    {
        new line[500];
        new data[42];
        mysql_fetch_row(line);
        sscanf(line, "p<|>iiiiii",
            data[0],
            data[1],
            data[2],
            data[3],
            data[4],
            data[5]);
        data[0] = pInfo[playerid][ID];
        data[1] = pInfo[playerid][pAdmin];
        data[2] = pInfo[playerid][pScore];
        SetPlayerScore(playerid, pInfo[playerid][pScore]);
        data[3] = pInfo[playerid][pMoney];
        GivePlayerMoney(playerid, pInfo[playerid][pMoney]);
        data[4] = pInfo[playerid][pKills];
        data[5] = pInfo[playerid][pDeaths];
    }
    mysql_free_result();
    pInfo[playerid][Logged] = 1;
}
But it didnt work either, i'm willing to work with the above script, so main post updated.
Reply
#6

Quote:
Originally Posted by Jimmy0wns
Посмотреть сообщение
Yea, my friend has suggested this code:
pawn Код:
//code
But it didnt work either, i'm willing to work with the above script, so main post updated.
What the fuck are you doing? your code is totally WRONG! where did you learn that from? *lol'ing* - the code below should work, 99.9% positive.


pawn Код:
stock MySQL_Login(playerid)
{
    new Query[ 500 ];

    new EscapedName[ MAX_PLAYER_NAME ];
    mysql_escape_string( pInfo[playerid][Nick], EscapedName );

    format( Query, sizeof( Query ), "SELECT * FROM `playerdata` WHERE `nick` COLLATE latin1_general_cs = '%s'", EscapedName );
    mysql_query( Query );

    mysql_store_result( );
    if( mysql_num_rows( ) )
    {
        if( mysql_fetch_row_format( Query, "|" ) )
        {
            sscanf(Query, "p<|>iiiiii", pInfo[playerid][ID], pInfo[playerid][pAdmin], pInfo[playerid][pScore], pInfo[playerid][pMoney], pInfo[playerid][pKills], pInfo[playerid][pDeaths]);
        }
    }
    mysql_free_result( );  
    return pInfo[playerid][Logged] = 1;
}
Reply
#7

Quote:
Originally Posted by pds2k12
Посмотреть сообщение
What the fuck are you doing? your code is totally WRONG! where did you learn that from? *lol'ing* - the code below should work, 99.9% positive.


pawn Код:
stock MySQL_Login(playerid)
{
    new Query[ 500 ];

    new EscapedName[ MAX_PLAYER_NAME ];
    mysql_escape_string( pInfo[playerid][Nick], EscapedName );

    format( Query, sizeof( Query ), "SELECT * FROM `playerdata` WHERE `nick` COLLATE latin1_general_cs = '%s'", EscapedName );
    mysql_query( Query );

    mysql_store_result( );
    if( mysql_num_rows( ) )
    {
        if( mysql_fetch_row_format( Query, "|" ) )
        {
            sscanf(Query, "p<|>iiiiii", pInfo[playerid][ID], pInfo[playerid][pAdmin], pInfo[playerid][pScore], pInfo[playerid][pMoney], pInfo[playerid][pKills], pInfo[playerid][pDeaths]);
        }
    }
    mysql_free_result( );  
    return pInfo[playerid][Logged] = 1;
}
I think the problem is my script itself, because this aint working either or i just forgot something.
Once i login i should be admin level 5 which i'm not. While i am on the database.
Reply
#8

Debug your loading Variables and Check out if they are loading correctly
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)