MySQL HELP
#1

Hey Members,

I need ur small help regarding my code


my code
Код:
	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;
}
It saving and updating perfectly but not getting the data. in log i can't see anything wrong.

in log it show it load but that stats isn't giving to and it set his stat reset.
Reply
#2

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 Код:
PlayerInfo[playerid][Level] = cache_get_field_content_int(0,"Admin");
        PlayerInfo[playerid][Helper] = cache_get_field_content_int(1,"Helper");
Reply
#3

Quote:
Originally Posted by Dokins
Посмотреть сообщение
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 Код:
PlayerInfo[playerid][Level] = cache_get_field_content_int(0,"Admin");
        PlayerInfo[playerid][Helper] = cache_get_field_content_int(1,"Helper");
It didn't work.
Reply
#4

What does it say when you print under catching the data?

PHP код:
printf("Data for ID %i: Admin: %i | Helper: %i | Donator: %i | Kills: %i | Deaths: %i | Score: %i | Money %i"playeridPlayerInfo[playerid][Level], PlayerInfo[playerid][Helper], PlayerInfo[playerid][dRank], PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], PlayerInfo[playerid][Score], PlayerInfo[playerid][Money]); 
If it's all 0's and doesn't return anything check your mysql logs for any errors. And if you don't have it place this in your gamemode.

PHP код:
public OnQueryError(erroriderror[], 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;

I don't know which mysql plugin you're using so im hoping that callback will work
Reply
#5

Код:
[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)
it print okay but that stuff isn't giving to me it just reset the stuffs

Mysql log seems to okay

Код:
[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"
Reply
#6

Must be something else with setting the variables, it loads but you don't get the stats
Reply
#7

may you're resting the stats later in your gamemode, try to print the level when player spawn to see if it resting or not. if yes then search when it being = 0; .-. i think that gonna help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)