mysql_format(database,query,sizeof(query),"SELECT * FROM Accounts WHERE Nick = '%e'",escpname(playerid)); mysql_tquery(database,query,"OnAccountDataLoad","i","playerid"); forward public OnAccountDataLoad(playerid); public OnAccountDataLoad(playerid) { new rows,fields; cache_get_data(rows,fields,database); if(rows) { cache_get_field_content(0,"RegisterDate",PlayerInfo[playerid][RegisterDate],database, 40); cache_get_field_content(0,"LastOn",PlayerInfo[playerid][LastOn],database, 30); PlayerInfo[playerid][Level] = cache_get_field_content_int(0,"Admin"); PlayerInfo[playerid][Helper] = cache_get_field_content_int(0,"Helper"); PlayerInfo[playerid][dRank] = cache_get_field_content_int(0,"Donor"); PlayerInfo[playerid][Kills] = cache_get_field_content_int(0,"Kills"); PlayerInfo[playerid][Deaths] = cache_get_field_content_int(0,"Deaths"); PlayerInfo[playerid][Score] = cache_get_field_content_int(0,"Score"); PlayerInfo[playerid][Money] = cache_get_field_content_int(0,"Money"); } return 1; }
PlayerInfo[playerid][Level] = cache_get_field_content_int(0,"Admin");
PlayerInfo[playerid][Helper] = cache_get_field_content_int(1,"Helper");
You need to correctly put in the correct row index ID for each instance on the field. i.e if the first field on your MySQL database is 'Admin' then the index id = 0, if the next one on your list is 'level' then it would be 1 and so on, like this:
pawn Код:
|
printf("Data for ID %i: Admin: %i | Helper: %i | Donator: %i | Kills: %i | Deaths: %i | Score: %i | Money %i", playerid, PlayerInfo[playerid][Level], PlayerInfo[playerid][Helper], PlayerInfo[playerid][dRank], PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], PlayerInfo[playerid][Score], PlayerInfo[playerid][Money]);
public OnQueryError(errorid, error[], callback[], query[], connectionHandle)
{
new string[100];
printf("Error ID: %i", errorid);
printf("Error: %s", error);
printf("Callback: %s", callback);
printf("Query: %s", query);
return 1;
}
[14:44:55] [connection] 127.0.0.1:50864 requests connection cookie. [14:44:56] Incoming connection: 127.0.0.1:50864 id: 0 [14:44:56] [join] Humza has joined the server (0:127.0.0.1) [14:45:03] Data for ID 1: Admin: 1 | Helper: 0 | Donator: 4 | Kills: 555 | Deaths: 100 | Score: 2000 | Money 200000 [14:45:05] [part] Humza has left the server (0:1)
[14:45:03] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [14:45:03] [DEBUG] Calling callback "OnAccountDataLoad".. [14:45:03] [DEBUG] cache_get_data - connection: 1 [14:45:03] [DEBUG] cache_get_field_content_int - row: 0, field_name: "id", connection: 1 [14:45:03] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "id", data: "1" [14:45:03] [DEBUG] cache_get_field_content - row: 0, field_name: "RegisterDate", connection: 1, max_len: 40 [14:45:03] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "RegisterDate", data: "28/10/2015" [14:45:03] [DEBUG] cache_get_field_content - row: 0, field_name: "LastOn", connection: 1, max_len: 30 [14:45:03] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "LastOn", data: "29/10/2015" [14:45:03] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Admin", connection: 1 [14:45:03] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Admin", data: "1" [14:45:03] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Helper", connection: 1 [14:45:03] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Helper", data: "0" [14:45:03] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Donor", connection: 1 [14:45:03] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Donor", data: "4" [14:45:03] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Kills", connection: 1 [14:45:03] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Kills", data: "555" [14:45:03] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Deaths", connection: 1 [14:45:03] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Deaths", data: "100" [14:45:03] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Score", connection: 1 [14:45:03] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Score", data: "2000" [14:45:03] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Money", connection: 1 [14:45:03] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Money", data: "200000"