Need help with ply:GetVelocity()


I am currently trying to develop my deathrun’s hud further and I decided I want to add a velocity bar to the hud as that is very helpful for Deathrun. I’ve been trying to figure out how to add another bar, below the hp but I can’t figure it out. Could someone help me with this, please?

Current HudPaint:

I know that it’s local velocity = ply:GetVelocity() as to

anyway, thanks for any help.

Read my comment in that thread…

ahh, thanks. Now I just have to figure out how to get the bar which acts upon the velocity.

[editline]16th November 2017[/editline]

So far

You hace to get max value, like 750 as example, then justo do (vel/maxVelocity)*maxWidth inside a drawRect

1,000 may be the max value if that is ok. So would it be:

velocity = ( hw - border*2 ) * math.Clamp(ply.GetVelocity(),0,1000)
draw.RoundedBox( 0, hx + border, ScrH() - 30, velocity, hh - border*2, Color( 80, 180, 60, 255 ) )

I’m sorry if I’m messing up, it’s just that I’m still learning the hudpaint structure and etc…

[editline]16th November 2017[/editline]

by the way, if you’re wondering where I got that from, I tried to copy it from health one and obviously make it compatible with the velocity.

[editline]16th November 2017[/editline]

Update: Now I just need to get the green rect moving depending on what velocity you are at.

So far:

draw.RoundedBox( 0, hx, ScrH() - 32, hw, hh, Color( 44, 44, 44, 175 ) )
draw.RoundedBox( 0, hx + border, ScrH() - 30, hw - border*2, hh - border*2, Color( 77, 77, 77, 255 ) )
surface.SetDrawColor( 80, 180, 60, 255 )
surface.DrawRect( hx + border, ScrH() - 30, hw - border*2, hh - border*2 )

[editline]16th November 2017[/editline]

Alright, well I found my way there, kinda.

Here is what I got:

surface.DrawRect( hx + border, ScrH() - 30, velocity, hh - border*2 )

My question is how do I put a max on that?

rectangle width = max width * (velocity / max velocity)

100 * (velocity / 750), that would be correct? if so, it works, however, if we reach the velocity of 1500+ it goes over the hud. anyway, it’s impossible to get to that velocity legit.

Set the max velocity to the actual max velocity.


Oh wow, I didn’t know such command even existed… Thank you anyway :slight_smile: It worked.

[editline]16th November 2017[/editline]

Thank you all for the help!