Mysql Load Information/Server Console
#1

I have this code:

pawn Код:
sscanf(Query, "p<|>is[30]dd", FactionInfo[id][ID],FactionInfo[id][Name], FactionInfo[id][Type], FactionInfo[id][FBank]);
            printf(" Faction : %s  Faction Type : %d  Faction Bank : %d", FactionInfo[id][Name],FactionInfo[id][Type],FactionInfo[id][FBank]);
Which displays this in the server console:

pawn Код:
[08:03:24]  Faction : L  Angeles Police  Faction Type : 1  Faction Bank : 500000
[08:03:24]  Faction : Fe Department  Faction Type : 3  Faction Bank :
And in debug file:

pawn Код:
08:03:24] CMySQLHandler::NumRows() - Returned 1 row(s)

[08:03:24] >> mysql_fetch_row_format( Connection handle: 1 )

[08:03:24] CMySQLHandler::FetchRow() - Return: 1|Los Angeles Police|1|500000

[08:03:24] >> mysql_query( Connection handle: 1 )

[08:03:24] CMySQLHandler::Query(SELECT ID,Name,Type,FBank FROM Factions WHERE ID= 2) - Successfully executed.

[08:03:24] >> mysql_store_result( Connection handle: 1 )

[08:03:24] CMySQLHandler::StoreResult() - Result was stored.

[08:03:24] >> mysql_num_rows( Connection handle: 1 )

[08:03:24] CMySQLHandler::NumRows() - Returned 1 row(s)

[08:03:24] >> mysql_fetch_row_format( Connection handle: 1 )

[08:03:24] CMySQLHandler::FetchRow() - Return: 2|Fire Department|3|5

[08:03:24] >> mysql_query( Connection handle: 1 )
How can I make it display the correct information?
Reply
#2

Also, I ran a test In Game:
pawn Код:
CMD:factionstats(playerid, params[])
{
    new id, string[128];
    if(sscanf(params, "i",id)) return SendClientMessage(playerid,-1,"You need to enter an id");
   
    format(string,sizeof(string),"Faction ID: %i",FactionInfo[id][ID]);
    SendClientMessage(playerid, -1, string);
   
    format(string, sizeof(string),"Faction Name: %s",FactionInfo[id][Name]);
    SendClientMessage(playerid, -1, string);
   
    format(string, sizeof(string),"Faction Type: %d",FactionInfo[id][Type]);
    SendClientMessage(playerid, -1, string);
   
    format(string, sizeof(string),"Faction Bank: %d",FactionInfo[id][FBank]);
    SendClientMessage(playerid, -1, string);
    return 1;
}
I noticed, instead of saying "Los Angeles Police" It says like Los F Department. How do I fix this guys, it's annoying and holding me back, thanks in advance!
Reply
#3

Bump
Reply
#4

I had the same problem, problem is in sscanf, I don't know why he doesn't load variables properly but this is the way how I load values from MySQL

pawn Код:
mysql_fetch_field_row(largestring, "EnterX"); HouseInfo[h][hEnterX] = floatstr(largestring);
that's just example, you need few more things, you can see how I done that in my house script
Reply
#5

I followed your example, and it's still the same issue, check this image out guys to see my error..:




You see how there is images in the words?

Code:

pawn Код:
mysql_get_field("ID", loadstr); FactionInfo[id][ID] = strval(loadstr);
            mysql_get_field("Name", FactionInfo[id][Name]);
            mysql_get_field("Type", loadstr); FactionInfo[id][Type] = strval(loadstr);
            mysql_get_field("FBank", loadstr); FactionInfo[id][FBank] = strval(loadstr);

Please help someone, this is urgent, has been an issue for past 3 days. Thanks in advance!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)