help with sscanf -.-
#1

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).
Reply
#2

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();
Reply
#3

undefined symbol "mysql_fetch_row_format"

what's the code with Strickens' plugin?
Reply
#4

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();
Reply
#5

thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)