MySQL Data Issue - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL Data Issue (
/showthread.php?tid=318416)
MySQL Data Issue -
Abreezy - 15.02.2012
On my database, I have the following information:
pawn Код:
ID Name Type FBank
1 Los Angeles Police 0 0
2 Fire Department 3 5
And on the server/server process, it shows:
pawn Код:
[23:16:44] Faction : Los Angeles Police Faction Type : 111 Faction Bank : 115
[23:16:44] Faction : Fire Department Faction Type : 105 Faction Bank : 114
The code is:
pawn Код:
if(mysql_fetch_row_format(Query,"|"))
{
sscanf(Query, "p<|>e<is[30]dd>", FactionInfo[id]);
printf(" Faction : %s Faction Type : %d Faction Bank : %d", FactionInfo[id][Name],FactionInfo[id][Type],FactionInfo[id][FBank]);
}
How can I fix this, thank you in advance.
Re: MySQL Data Issue -
iggy1 - 15.02.2012
Put this in OnGameModeInit (or fs init)
Run your mode, then look at the debug file it creates (debug.txt in server root directory). See what values the database is returning. If its returning the correct values the sscanf line will be the culprit. I have never used sscanf with enums like that so i don't know if its valid or not. Posting the enum may help too.
Re: MySQL Data Issue -
Abreezy - 15.02.2012
Enum:
pawn Код:
enum finfo
{
ID,
Name[30],
Type,
FBank
};
And debug:
pawn Код:
[00:14:49] CMySQLHandler::Query(SELECT * FROM Factions WHERE ID= 1) - Successfully executed.
[00:14:49] >> mysql_store_result( Connection handle: 1 )
[00:14:49] CMySQLHandler::StoreResult() - Result was stored.
[00:14:49] >> mysql_num_rows( Connection handle: 1 )
[00:14:49] CMySQLHandler::NumRows() - Returned 1 row(s)
[00:14:49] >> mysql_fetch_row_format( Connection handle: 1 )
[00:14:49] CMySQLHandler::FetchRow() - Return: 1|Los Angeles Police|1|500000
[00:14:49] >> mysql_query( Connection handle: 1 )
[00:14:49] CMySQLHandler::Query(SELECT * FROM Factions WHERE ID= 2) - Successfully executed.
[00:14:49] >> mysql_store_result( Connection handle: 1 )
[00:14:49] CMySQLHandler::StoreResult() - Result was stored.
[00:14:49] >> mysql_num_rows( Connection handle: 1 )
[00:14:49] CMySQLHandler::NumRows() - Returned 1 row(s)
[00:14:49] >> mysql_fetch_row_format( Connection handle: 1 )
[00:14:49] CMySQLHandler::FetchRow() - Return: 2|Fire Department|3|5
Re: MySQL Data Issue -
iggy1 - 15.02.2012
Try this,
pawn Код:
sscanf(Query, "p<|>is[30]dd", FactionInfo[id][ID],FactionInfo[id][Name], FactionInfo[id][Type], FactionInfo[id][FBank]);
If that works, something is wrong either with your syntax or sscanf. Maybe post in sscanf thread for better help from ******.
EDIT: Since you select all in your query i don't know what order to put the variables in the sscanf line i posted, you will need to do that yourself.
EDIT2: fixed
Re: MySQL Data Issue -
Abreezy - 15.02.2012
With your edit, it now displays this:
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 :
Re: MySQL Data Issue -
Abreezy - 15.02.2012
Anyone Know why it's displaying Parts of the name now? Help is appreciated fully.
Re: MySQL Data Issue -
Abreezy - 15.02.2012
Bump. No one sees post on the second page :/
Re: MySQL Data Issue -
Abreezy - 16.02.2012
Delete this comment, was suppose to make topic not post :/