SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 23/08/2011, 05:29 PM   #1
Willow
Big Clucker
 
Join Date: Jun 2010
Location: Latvija
Posts: 54
Reputation: 0
Default Sscanf and floats

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?
Willow is offline  
Old 23/08/2011, 05:31 PM   #2
Jeffry
High-roller
 
Jeffry's Avatar
 
Join Date: Oct 2009
Location: Germany
Posts: 1,598
Reputation: 69
Default Re: Sscanf and floats

Can you show the 'enum' of the Bizz please.
__________________
Jeffry is offline  
Old 23/08/2011, 05:39 PM   #3
Willow
Big Clucker
 
Join Date: Jun 2010
Location: Latvija
Posts: 54
Reputation: 0
Default Re: Sscanf and floats

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];
Willow is offline  
Old 23/08/2011, 05:41 PM   #4
Darnell
Gangsta
 
Darnell's Avatar
 
Join Date: Jul 2010
Posts: 824
Reputation: 35
Default Re: Sscanf and floats

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.
Darnell is offline  
Old 23/08/2011, 05:43 PM   #5
Willow
Big Clucker
 
Join Date: Jun 2010
Location: Latvija
Posts: 54
Reputation: 0
Default Re: Sscanf and floats

isn't that the same?
Willow is offline  
Old 23/08/2011, 05:53 PM   #6
[NoV]LaZ
High-roller
 
Join Date: May 2008
Posts: 1,417
Reputation: 90
Default Re: Sscanf and floats

pawn Code:
sscanf(query, ...
I assume you're using sscanf on the query itself ?
You should be using it on the data mysql_fetch_row_format yields.
__________________

Thank you for playing!

It is back online! 176.31.69.249:7799
[NoV]LaZ is offline  
Old 23/08/2011, 05:59 PM   #7
Willow
Big Clucker
 
Join Date: Jun 2010
Location: Latvija
Posts: 54
Reputation: 0
Default Re: Sscanf and floats

The rest of the info from enumeration loads, only coordinates are 0.000000 :/

edit: full code http://pastebin.com/qbuSFcAV
Willow is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sscanf floats in-accurate MP2 Help Archive 0 13/08/2011 08:10 PM
Floats BLAbla93 Help Archive 3 06/07/2011 04:15 AM
floats armyoftwo Help Archive 12 09/10/2010 02:09 PM
Got floats? -Rebel Son- Help Archive 4 27/04/2010 06:06 PM
sscanf and floats mprofitt Help Archive 14 21/11/2009 11:22 PM


All times are GMT. The time now is 05:58 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.