Raised This Month: $ Target: $400
 0% 

Fload display


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EDUTz
Senior Member
Join Date: Jun 2010
Location: Dracula's Homeland
Old 02-10-2013 , 11:30   Fload display
Reply With Quote #1

How to display a float with only 2 decimals ?
Code:
new const XDAMAGE[11][] = {
	"1.0",
	"1.1",
	"1.2",
	"1.3",
	"1.4",
	"1.5",
	"1.6",
	"1.7",
	"1.8",
	"1.9",
	"2.0"
}
new Float: xdmg = str_to_float(XDAMAGE[g_level[id]])
ShowSyncHudMsg(id, g_HudMsgr, "Damage x %f", xdmg)
This will display: Damage x 1.2999999 (just an example)
EDUTz is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-10-2013 , 11:39   Re: Fload display
Reply With Quote #2

I think you are the first person who has ever asked this, so it would be useless trying to search.
I hope someone has the answer though.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-10-2013 , 11:41   Re: Fload display
Reply With Quote #3

If you want to show value from your array, you don't need to convert to float.

ShowSyncHudMsg(id, g_HudMsgr, "Damage x %s", XDAMAGE[g_level[id]])
__________________
Arkshine is offline
EDUTz
Senior Member
Join Date: Jun 2010
Location: Dracula's Homeland
Old 02-10-2013 , 12:04   Re: Fload display
Reply With Quote #4

10x arkshine, yes it was just a matter of display and that does the trick. Simple solutions are the best )
EDUTz is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 02-10-2013 , 12:19   Re: Fload display
Reply With Quote #5

You call that simple solution? Storing float damage multipliers as strings? lol
PHP Code:
new Floatxdmg 1.0 0.1*g_level[id]
ShowSyncHudMsg(idg_HudMsgr"Damage x %.1f"xdmg
__________________
Impossible is Nothing

Last edited by Sylwester; 02-10-2013 at 12:20.
Sylwester is offline
EDUTz
Senior Member
Join Date: Jun 2010
Location: Dracula's Homeland
Old 02-10-2013 , 13:01   Re: Fload display
Reply With Quote #6

what's wrong with that ? It's just for displaying that float as a string.
why should i do an extra calculation when it's just as simple as that ?
EDUTz is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 02-10-2013 , 13:18   Re: Fload display
Reply With Quote #7

Redundant code. Although you say it's just for displaying, aren't you using float multiplier to change damage in your plugin? Then why do you add unnecessary array of strings when you can use the same thing for multiplying damage and displaying multiplier value? Also imagine you want to edit the multipliers (you would have to edit every value in array to match actual multiplier - waste of time).
__________________
Impossible is Nothing
Sylwester is offline
EDUTz
Senior Member
Join Date: Jun 2010
Location: Dracula's Homeland
Old 02-10-2013 , 16:02   Re: Fload display
Reply With Quote #8

Oh, i see what you mean. Thanks for helping !
EDUTz 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 20:37.


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