AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Float stuff (https://forums.alliedmods.net/showthread.php?t=26490)

v3x 04-03-2006 07:06

Float stuff
 
Code:
stock Float:cs_get_user_ratio(id) {     new deaths = cs_get_user_deaths(id);     new frags = get_user_frags(id);     new Float:ratio = float(frags) / float(deaths);     //gaben_to_float(ratio);     return ratio; } stock Float:gaben_to_float(Float:fnum) {     new buffer[21];     format(buffer , 20 , "%.2f" , fnum);     str_to_float(buffer);     return; }

I'm trying to turn a number like 1.000000000 into 1.00 and that doesn't seem to be working too well.

Maybe I could put letter or something after it like this?
Code:
format(buffer , 20 , "%.2f+" , fnum);

Help would be appreciated. Thanks.

Edit: Here's the function I'm working with now.
Code:
stock Float:cs_get_user_ratio(id) {     new deaths = cs_get_user_deaths(id);     new frags = get_user_frags(id);     new Float:ratio = float(frags) / float(deaths);     new buffer[21];     format(buffer , 20 , "%.2f" , ratio);     str_to_float(buffer);     return Float:buffer; }

T(+)rget 04-03-2006 07:26

%0.2f


All times are GMT -4. The time now is 16:37.

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