Raised This Month: $ Target: $400
 0% 

Floats Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ng1200
Member
Join Date: May 2005
Old 10-26-2007 , 14:49   Floats Help
Reply With Quote #1

Code:
    new Float:Ratio = float(g_CarMaxSpeed[id] / 1000)     g_Userspeed[id] = Ratio * g_PredefGears[g_CurrentGear[id]]     server_print("%f %f", Ratio, g_Userspeed[id])

Prints 0.0000000 0.00000000

Few notes:
g_CarMaxSpeed[id] is 485
g_PredefGears[g_CurrentGear[id]] is 1

What is the proper way to do this?

Thanks in advance, DF3.
ng1200 is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 10-26-2007 , 14:56   Re: Floats Help
Reply With Quote #2

Code:
new Float:Ratio = float(g_CarMaxSpeed[id]) / 1000.0;
g_Userspeed[id] = Ratio * float(g_PredefGears[g_CurrentGear[id]]);
server_print("%.1f | %.1f", Radio, g_Userspeed[id]);


Note: g_Userspeed[id] must be a float too :s
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
ng1200
Member
Join Date: May 2005
Old 10-26-2007 , 15:42   Re: Floats Help
Reply With Quote #3

Quote:
Originally Posted by Alka View Post
Code:
new Float:Ratio = float(g_CarMaxSpeed[id]) / 1000.0;
g_Userspeed[id] = Ratio * float(g_PredefGears[g_CurrentGear[id]]);
server_print("%.1f | %.1f", Radio, g_Userspeed[id]);


Note: g_Userspeed[id] must be a float too :s
g_Userspeed is already a float
Thanks for the help.
ng1200 is offline
kp_uparrow
Penalized Member
Join Date: Jun 2006
Location: 192.168.0.1
Old 10-27-2007 , 01:07   Re: Floats Help
Reply With Quote #4

whats the %.1f for?
__________________
I USED A SECOND ACCOUNT TO DO MORE KARMA UPS AND DOWNS UNTIL GREENTRYST CAUGHT ME
kp_uparrow is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 10-27-2007 , 01:33   Re: Floats Help
Reply With Quote #5

Quote:
Originally Posted by kp_uparrow View Post
whats the %.1f for?
Show's only 1 digit after . E.g 128.9
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
kp_uparrow
Penalized Member
Join Date: Jun 2006
Location: 192.168.0.1
Old 10-27-2007 , 03:06   Re: Floats Help
Reply With Quote #6

wow why was that not written in the scripting wiki s, been looking for that for ages
__________________
I USED A SECOND ACCOUNT TO DO MORE KARMA UPS AND DOWNS UNTIL GREENTRYST CAUGHT ME
kp_uparrow is offline
Greenberet
AMX Mod X Beta Tester
Join Date: Apr 2004
Location: Vienna
Old 10-27-2007 , 12:04   Re: Floats Help
Reply With Quote #7

Quote:
Originally Posted by kp_uparrow View Post
wow why was that not written in the scripting wiki s, been looking for that for ages
well it is...
http://www.amxmodx.org/funcwiki.php?go=func&id=49 points you to the c++ printf http://www.cplusplus.com/reference/c...io/printf.html and it is explained there.
__________________
Greenberet is offline
Send a message via ICQ to Greenberet Send a message via MSN to Greenberet
RaYden
Member
Join Date: Sep 2007
Old 10-27-2007 , 11:39   Re: Floats Help
Reply With Quote #8

lol
RaYden is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 01:20.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode