Raised This Month: $ Target: $400
 0% 

Decimal places...removable?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
n04d
Junior Member
Join Date: Jan 2005
Old 01-05-2005 , 17:00   Decimal places...removable?
Reply With Quote #1

I am currently working on a simple money-mod plugin, and I am using set_hudmessage and show_hudmessage to show how much money the person has. I have successfully setup how to display the money when it is givin to the player, but it is in a decimal and the decimal places values are huge.

What I mean is, in the show_hudmessage, when it draws it's like, "Current amount of money: 5.000000"

I am just trying to get it so it just shows the "5" instead of the ".000000" after it...

Any ideas how I would go about doing this?

Here is how I'm doing the code...

Code:
public display(id){
set_hudmessage(255,255,255,0.015,0.015,0,6.0,999999.0,0.0,0.0,2);
show_hudmessage(id,"Current amount of money: %f",money[id]);
return 1;
}
I am defining money as a float also...

Code:
new Float:money[33] = 0
So that could be a problem....
n04d is offline
Nick
Senior Member
Join Date: Apr 2004
Location: Canada, Alberta, Cal
Old 01-05-2005 , 18:42  
Reply With Quote #2

You define money as a floating number thats why.
__________________
Nick is offline
Send a message via MSN to Nick
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 01-05-2005 , 18:50  
Reply With Quote #3

Oh you basterd.

Floats are used to display cents. If you just want dollars, use an int.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 01-05-2005 , 21:59  
Reply With Quote #4

Additionally, to convert a float to an integer you would use the floatround function, but I would just have the money variable be an integer in the first place unless you have a special reason that you need it as a float.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
n04d
Junior Member
Join Date: Jan 2005
Old 01-05-2005 , 23:20  
Reply With Quote #5

Alright so...

Code:
floatround ( Float:money[id], floatround_tozero )
is the syntax...?

I am calling it inside a public, so the array section has the ID.

Correct? Or would I just call it outside.
n04d is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 01-06-2005 , 12:51  
Reply With Quote #6

The only reason you would want floats is for cents, and you just....removed the cents, so just use a damn integer.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 01-06-2005 , 21:15  
Reply With Quote #7

here:

Code:
show_hudmessage(id,"Current amount of money: %0.0f",money[id]);
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
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 19:17.


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