Sscanf and floats - 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: Sscanf and floats (
/showthread.php?tid=278730)
Sscanf and floats -
Willow - 23.08.2011
Hi, I am using sscanf2 and I have a problem with loading floats from mysql database:
Code:
sscanf(query,"p<|>ds[50]s[24]ddddffffffd",
i,
Bizz[i][name],
Bizz[i][owner],
Bizz[i][status],
Bizz[i][type],
Bizz[i][vault],
Bizz[i][interior],
Bizz[i][intx],
Bizz[i][inty],
Bizz[i][intz],
Bizz[i][outx],
Bizz[i][outy],
Bizz[i][outz],
Bizz[i][price]);
printf("x: %f y: %f z: %f",Bizz[i][outx],Bizz[i][outy],Bizz[i][outz]);
In console, it prints only 0.0000000 etc... but in mysql log it shows real coordinates.. What could be the froblem?
Re: Sscanf and floats -
Jeffry - 23.08.2011
Can you show the 'enum' of the Bizz please.
Re: Sscanf and floats -
Willow - 23.08.2011
Code:
enum
{
id,
name[50],
owner[24],
status,
type, // 0 - n/a | 1 - shop | 2 - bar
vault,
interior,
Float:intx,
Float:inty,
Float:intz,
Float:outx,
Float:outy,
Float:outz,
price
}
new Bizz[MAX_BIZZ][bizzinfo];
Re: Sscanf and floats -
Darnell - 23.08.2011
pawn Code:
sscanf(query,"p<|>ds[50]s[24]ddddffffffd",
i,
Bizz[i][name],
Bizz[i][owner],
Bizz[i][status],
Bizz[i][type],
Bizz[i][vault],
Bizz[i][interior],
Bizz[i][intx],
Bizz[i][inty],
Bizz[i][intz],
Bizz[i][outx],
Bizz[i][outy],
Bizz[i][outz],
Bizz[i][price]
);
printf("x: %f y: %f z: %f",Bizz[i][outx],Bizz[i][outy],Bizz[i][outz]);
I don't really think it's diffrent, but try.
Re: Sscanf and floats -
Willow - 23.08.2011
isn't that the same?
Re: Sscanf and floats -
[NoV]LaZ - 23.08.2011
I assume you're using sscanf on the query itself ?
You should be using it on the data mysql_fetch_row_format yields.
Re: Sscanf and floats -
Willow - 23.08.2011
The rest of the info from enumeration loads, only coordinates are 0.000000 :/
edit: full code
http://pastebin.com/qbuSFcAV