12.02.2013, 16:22
Hello,
I am scripting a gamemode from scratch using the new MySQL R7 include. My issue is, when I login to the server, it registers my account properly, and I can login properly. However, it does not load my statistics. This is where the issue resides:
It performs the query, and prints "Works" in the console, so I know it is being called successfully. However, the cache_get_row is not storing the statistics into the player variables. When I do /stats, it returns PlayerInfo[playerid][pCash] as $0, when it should be $10,000.
Thank you for taking a look at this, if you need more information let me know.
I am scripting a gamemode from scratch using the new MySQL R7 include. My issue is, when I login to the server, it registers my account properly, and I can login properly. However, it does not load my statistics. This is where the issue resides:
pawn Код:
stock LoadAccount(playerid)
{
format(Query, sizeof(Query), "SELECT * FROM `Accounts` WHERE `AccountID` = %d", PlayerInfo[playerid][AccountID]);
mysql_function_query(MySQL, Query, true, "AccountLoad", "d", playerid);
#if defined DEBUG
printf("[DEBUG] Loading Account For %s",GetPName(playerid));
#endif
return 1;
}
forward AccountLoad(playerid);
public AccountLoad(playerid)
{
#if defined DEBUG
print("[DEBUG] Account Load 1");
#endif
new rows, fields;
cache_get_data(rows, fields, MySQL);
if(rows)
{
new temp[11];
cache_get_row(0, 6, temp); PlayerInfo[playerid][pCash] = strval(temp);
cache_get_row(0, 7, temp); PlayerInfo[playerid][pScore] = strval(temp);
cache_get_row(0, 8, temp); PlayerInfo[playerid][pRank] = strval(temp);
cache_get_row(0, 9, temp); PlayerInfo[playerid][pKills] = strval(temp);
cache_get_row(0, 10, temp); PlayerInfo[playerid][pDeaths] = strval(temp);
cache_get_row(0, 11, temp); PlayerInfo[playerid][pAdmin] = strval(temp);
cache_get_row(0, 12, temp); PlayerInfo[playerid][pWarns] = strval(temp);
cache_get_row(0, 13, temp); PlayerInfo[playerid][pMuted] = strval(temp);
cache_get_row(0, 14, temp); PlayerInfo[playerid][pJail] = strval(temp);
print("Works");
}
#if defined DEBUG
printf("[DEBUG] Loading Stats For %s",GetPName(playerid));
#endif
return 1;
}
Thank you for taking a look at this, if you need more information let me know.