SA-MP Forums Archive
help with 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: help with sscanf -.- (/showthread.php?tid=213075)



help with sscanf -.- - Sascha - 18.01.2011

K... so I've got a little problem...
I'm not familar with sscanf at all and I also don't get it really when i read the tut...
so I tried:
pawn Код:
new dat[256], string[100], Float:x, Float:y, Float:z;
GetPlayerName(playerid, name, sizeof(name));
format(dat, sizeof(dat), "SELECT x, y, z FROM User WHERE `Name`='%s'", name);
mysql_query(dat),
mysql_store_result();
sscanf(dat, "p<|>fff",x, y, z);
format(string, sizeof(string), "%f,%f,%f", x, y, z);
SendClientMessage(playerid, GREY, string);
mysql_free_result();
however it always shows "0.000, 0.000, 0.000"... it shoud show some other floats (yes the floats in the db aren't 0,0,0).


Re: help with sscanf -.- - JaTochNietDan - 18.01.2011

Okay, the problem here is simple, think about what you're doing. You're using sscanf to split up the formatted string, that isn't going to work because the information isn't stored there, use mysql_fetch_row_format() to store the information you're looking for in the "dat" array, for example:

pawn Код:
new dat[256], string[100], Float:x, Float:y, Float:z;
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "SELECT x, y, z FROM User WHERE `Name`='%s'", name);
mysql_query(string),
mysql_store_result();
mysql_fetch_row_format(dat,"|");
sscanf(dat, "p<|>fff",x, y, z);
format(string, sizeof(string), "%f,%f,%f", x, y, z);
SendClientMessage(playerid, GREY, string);
mysql_free_result();



Re: help with sscanf -.- - Sascha - 18.01.2011

undefined symbol "mysql_fetch_row_format"

what's the code with Strickens' plugin?


Re: help with sscanf -.- - JaTochNietDan - 18.01.2011

Quote:
Originally Posted by Sascha
Посмотреть сообщение
undefined symbol "mysql_fetch_row_format"

what's the code with Strickens' plugin?
pawn Код:
new dat[256], string[100], Float:x, Float:y, Float:z;
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "SELECT x, y, z FROM User WHERE `Name`='%s'", name);
mysql_query(string),
mysql_store_result();
mysql_fetch_row(dat);
sscanf(dat, "p<|>fff",x, y, z);
format(string, sizeof(string), "%f,%f,%f", x, y, z);
SendClientMessage(playerid, GREY, string);
mysql_free_result();



Re: help with sscanf -.- - Sascha - 18.01.2011

thanks