AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Problem with floats in hud [SOLVED] (https://forums.alliedmods.net/showthread.php?t=320111)

Ludak 12-04-2019 16:02

Problem with floats in hud [SOLVED]
 
Hello, I have level system fro ZM server.
I want to show the bonus speed and damage per level in the hud.

I have natives:
zp_get_hm_damage(player)
zp_get_hm_speed(player)
zp_get_zp_speed(player)

All of those natives return integers.
Now, in the level plugin, the speeds are divided by 100 and added to the current speed on spawn and the damage is divided by 10 and added for each bullet impact in (Ham_TakeDamage).

So per level player gets 1 / 10 = 0.1 damage bonus, and 1 / 100 = 0.01 speed bonus.
Now, since the values in natives are integers, I want to display them like floats in the hud.

When I try the following:
float(zp_get_hm_speed(player) / 100)
float(zp_get_zp_speed(player) / 100)
float(zp_get_hm_damage(player) / 10)

The format in the hud is: %.5f
The hud just displays 0.00000

I do not know why it is not working, can someone help me.

HamletEagle 12-04-2019 16:10

Re: Problem with floats in hud
 
float(native) / 100

Ludak 12-04-2019 16:43

Re: Problem with floats in hud
 
Quote:

Originally Posted by HamletEagle (Post 2675716)
float(native) / 100

Does not work for some reason.
Then I tried float(native) / 100.0 and it works.

Thanks.

HamletEagle 12-05-2019 08:38

Re: Problem with floats in hud [SOLVED]
 
Do not empty your post. Why do people still do that in 2019 is beyond my understanding.


All times are GMT -4. The time now is 02:41.

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