not loading stats
#1

pawn Код:
stock LoadStats(playerid)
{
    new pName[24],Query[200];
    GetPlayerName(playerid,pName,24);
    format(Query, sizeof(Query), "SELECT * FROM `users` WHERE `username` = '%s' ", pName);
    mysql_query(Query);
    mysql_store_result();
    mysql_fetch_row_format(Query, "|");
    sscanf(Query, "e<p<|>s[24]s[23]i>", PlayerInfo[playerid]);
    mysql_free_result();
    GivePlayerMoney(playerid,PlayerInfo[playerid][Pmoney]);
    return 1;
}
this wont load my stats well it loads my admin level etc but doesn't load my money and most prob some other things (only tested money)
Reply
#2

pawn Код:
sscanf(Query, "e<p<|>s[24]s[23]i>", PlayerInfo[playerid]);
This query is only setup to load 3 statistics, please show me your statistics enumerator.
Reply
#3

pawn Код:
enum PInfo
{
    Pusername[25],
    Ppassword[24],
    Pscore,
    Pmoney,
    Pbank,
    Pstat,
    Parmy,
    Pswat,
    Padmin,
    Pcop,
    Pregdate,
    Pprison,
    Phelper,
    Pemail[255],
    Pvip,
    Ptime,
    Parrest,
    Psurender,
    Prob,
    Prape,                                        // here is what im saving
    Pheal,
    Phitman,
    Psales,
    Pwep,
    Pdrug,
    Ptaze,
    Ptruck
}
Reply
#4

Replace the query with this:
pawn Код:
sscanf(Query, "e<p<|>s[24]s[23]iiiiiiiiiiis[255]iiiiiiiiiiiii>", PlayerInfo[playerid]);
Let me know if that works.
Reply
#5

im still not getting my money :/
Reply
#6

Try this:

pawn Код:
stock LoadStats(playerid)
{
    new pName[24],Query[500];
    GetPlayerName(playerid,pName,24);
    format(Query, sizeof(Query), "SELECT * FROM `users` WHERE `username` = '%s' ", pName);
    mysql_query(Query);
    mysql_store_result();
    mysql_fetch_row_format(Query, "|");
    sscanf(Query, "e<p<|>s[24]s[23]iiiiiiiiiiis[255]iiiiiiiiiiiii>", PlayerInfo[playerid]);
    GivePlayerMoney(playerid,PlayerInfo[playerid][Pmoney]);
    mysql_free_result();
    return 1;
}
Reply
#7

hmm for some reason no :/ im going to give you another stock thats connected to that one and maybe that will sort it out

pawn Код:
stock LoginPlayer(playerid,const password[])
{
    new EscapedText[60], Query[200];
    mysql_real_escape_string(password, EscapedText);
    format(Query,sizeof(Query),"SELECT * FROM `users` WHERE `username` = '%s' AND `password` = '%s'",PlayerName(playerid),EscapedText);
    mysql_query(Query);
    mysql_store_result();
    if(mysql_num_rows() != 0) {
        SendClientMessage(playerid,COLOR_GREEN,"You have been logged in!");
        LoadStats(playerid);
    }
    else {
        SendClientMessage(playerid,COLOR_RED,"Wrong password!");
        Kick(playerid);
    }
    mysql_free_result();
    return 1;
}
Reply
#8

Do you have mysql debugging enabled? If so, please paste the log.

If you don't know how to enable it, paste this OnGameModeInit:
Код:
mysql_debug(1); // MySQL Debugging - 0 = No, 1 = Yes //
And then restart the server and login.
Reply
#9

yup i always have it enabled

Код:
[21:55:25] ---------------------------

[21:55:25] MySQL Debugging activated (08/25/12)

[21:55:25] ---------------------------

[21:55:25]  

[21:55:25] >> mysql_connect( )

[21:55:25] CMySQLHandler::Connect() - Connection was successful.

[21:55:25] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.

[21:55:25] >> mysql_query( Connection handle: 1 )

[21:55:25] CMySQLHandler::Query(SELECT `Username` FROM `users` WHERE `username` = 'thefatshizms' LIMIT 1;) - Successfully executed.

[21:55:25] >> mysql_store_result( Connection handle: 1 )

[21:55:25] CMySQLHandler::StoreResult() - Result was stored.

[21:55:25] >> mysql_num_rows( Connection handle: 1 )

[21:55:25] CMySQLHandler::NumRows() - Returned 1 row(s)

[21:55:25] >> mysql_free_result( Connection handle: 1 )

[21:55:25] CMySQLHandler::FreeResult() - Result was successfully free'd.

[22:02:07] >> mysql_real_escape_string( Connection handle: 1 )

[22:02:07] CMySQLHandler::EscapeString(chelsea9723); - Escaped 11 characters to chelsea9723.

[22:02:07] >> mysql_query( Connection handle: 1 )

[22:02:07] CMySQLHandler::Query(SELECT * FROM `users` WHERE `username` = 'thefatshizms' AND `password` = 'chelsea9723') - Successfully executed.

[22:02:07] >> mysql_store_result( Connection handle: 1 )

[22:02:07] CMySQLHandler::StoreResult() - Result was stored.

[22:02:07] >> mysql_num_rows( Connection handle: 1 )

[22:02:07] CMySQLHandler::NumRows() - Returned 1 row(s)

[22:02:07] >> mysql_query( Connection handle: 1 )

[22:02:07] CMySQLHandler::Query(SELECT * FROM `users` WHERE `username` = 'thefatshizms' ) - Successfully executed.

[22:02:07] >> mysql_store_result( Connection handle: 1 )

[22:02:07] CMySQLHandler::StoreResult() - Result was stored.

[22:02:07] >> mysql_fetch_row_format( Connection handle: 1 )

[22:02:07] CMySQLHandler::FetchRow() - Return: thefatshizms|chelsea9723|0|52236|0|0|0|0|5|0|25/08/2012|0|0|0|0|0|0|0|0|0|0|0|0|0

[22:02:07] >> mysql_free_result( Connection handle: 1 )

[22:02:07] CMySQLHandler::FreeResult() - Result was successfully free'd.

[22:02:07] >> mysql_free_result( Connection handle: 1 )

[22:02:07] CMySQLHandler::FreeResult() - The result is already empty.
im guessing the 'The result is already empty.' is what's causing the problem
Reply
#10

Ok, it is successfully loading the statistics, make sure you aren't resetting the players cash OnPlayerSpawn or anywhere else.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)