Math.Clamp() with DProgressBars

Hello, I wanted to know if Math.Clamp() works on DProgressBars, like as example lets take the players health, a ProgressBar can only go from 0 to 1, if I clamp the player health to these numbers, would it be like for the progressbar then like this:

player HP: 100 = Progressbar 1(100%)
player HP: 99 = Progressbar 0.99(99%)
player HP: 50 = Progressbar 0.50(50%)

or will it be like

player HP: 100 = Progressbar 1(100%)
player HP: 1 = Progressbar 1(100%)
Player HP: 0 = Progressbar 0(0%)

I dont know if you kinda get what I mean, I just hope you do…

Why don’t you try it?

Because I currently cant since I aint at my PC until 8PM GMT 1, plus if its a “kind of” stupid question, it would stop others from asking it, right?

PS: Playerhealth / 100 clamped from 0 to 1 would do what you want, I think

That’s a shit excuse. Just want until you get to your PC and try it. There’s no need to ask such questions as “what will happen if”. Just go and try it yourself. If it doesn’t do what you want it to do - come and ask your questions.

Okay, the progressbar doesnt work as I wanted it to. it doesnt count the health as it should, means 1HP is still 100%, how can I make 1HP be 1%?

[editline]23rd June 2015[/editline]

What if health is over 100? :stuck_out_tongue:

player:Health() / player:GetMaxHealth()

[editline]23rd June 2015[/editline]

If you use DProgressBar, 10000% hp will be shown as 100%

first, thanks. second, when the player dies, theres still a bit of the progressbar filled, some huds “bypassed” this way with “if blah < 0 then blah = 0” and stuff, dont know if that applies for DProgress though, and the health was just an example, what if I want stuff like an XP system, how would I make the percentage of the total value?

Why are you using Derma elements for HUD?

The progress bar has a bug:

I dont use DProgress on the hud directly, I use it in a DFrame with concommand, because the HUDPaint hook is a think hook.

I use derma for HUD elements to take advantage of docking and all the other features.

Derma is great for huds

Depends, since HUDPaint is a think hook, the game would lag like hell if you’d use DProgress in that hook.

I could submit pull request, but garry banned me.

You don’t use it in the hook, you simply create it and update it in it’s own Think hook. You can use SetPaintedManually/PaintManual to force your HUD Panel to paint in HUDPaint. It doesn’t cause any performance impact at all.