mysql and sscanf - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: mysql and sscanf (
/showthread.php?tid=165873)
mysql and sscanf -
armyoftwo - 06.08.2010
If i use it like that it prints: "John Beer 0"
I want it to print: "Friend Nickname 1-10"
The field looks like:
Code:
Name: FriendName: RelationShip:
John Beer Johny Beer 2
Code:
printf("%s", line);
sscanf(line, "p<|>s[24]i", friendname, relation);
printf("%s %d", friendname, relation);
line string is perfectly printed but when it comes to string seperating it prints
JOHN BEER IS MY NICK, NOT MY FRIEND'S NICK!
Re: mysql and sscanf -
klavins21 - 06.08.2010
I didnt understand, you have trouble reading from mysql or what?
Re: mysql and sscanf -
armyoftwo - 06.08.2010
maybe it's hard to understand, but you should read twice
Re: mysql and sscanf -
woot - 06.08.2010
Show us the query
Re: mysql and sscanf -
armyoftwo - 06.08.2010
Quote:
Originally Posted by exora
Show us the query
|
Code:
format(string, sizeof(string), "SELECT * FROM `friends` WHERE `Name` = '%s'", GetUserName(playerid));
mysql_query(string);
mysql_store_result();
mysql_fetch_row(line);
there should be nothing wrong here cause it prints John Beer|Johny Beer|2
Re: mysql and sscanf -
Westie - 06.08.2010
I may be missing something, but where in your query do you relate to the relationship level, and the friends name?
Re: mysql and sscanf -
armyoftwo - 06.08.2010
Quote:
Originally Posted by Westie
I may be missing something, but where in your query do you relate to the relationship level, and the friends name?
|
i guess.. nowhere?
But with query there should be everything fine, explenation in previous post
Re: mysql and sscanf -
Westie - 06.08.2010
Your original posts explains appallingly your problem.
Try replacing playerid with the ID variable of your friend in the GetUserName function.
Re: mysql and sscanf -
MadeMan - 06.08.2010
You have to get all parameters.
pawn Code:
new nickname[24];
sscanf(line, "p<|>s[24]s[24]i", nickname, friendname, relation);
Re: mysql and sscanf -
armyoftwo - 06.08.2010
Quote:
Originally Posted by MadeMan
You have to get all parameters.
pawn Code:
new nickname[24]; sscanf(line, "p<|>s[24]s[24]i", nickname, friendname, relation);
|
That wasn't that problem, i was missing something important in query!
Re: mysql and sscanf -
Daren_Jacobson - 06.08.2010
your sscanf needs to grab name before friendname.
pawn Код:
sscanf(line, "p<|>s[24]s[24]i", playername, friendname, relation);