AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Decimal places...removable? (https://forums.alliedmods.net/showthread.php?t=9098)

n04d 01-05-2005 17:00

Decimal places...removable?
 
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....

Nick 01-05-2005 18:42

You define money as a floating number thats why.

Twilight Suzuka 01-05-2005 18:50

Oh you basterd.

Floats are used to display cents. If you just want dollars, use an int.

XxAvalanchexX 01-05-2005 21:59

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.

n04d 01-05-2005 23:20

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.

Twilight Suzuka 01-06-2005 12:51

The only reason you would want floats is for cents, and you just....removed the cents, so just use a damn integer.

Geesu 01-06-2005 21:15

here:

Code:
show_hudmessage(id,"Current amount of money: %0.0f",money[id]);


All times are GMT -4. The time now is 19:18.

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