Velocity meter

I would like to incorporate a velocity meter, similar to cl_showpos, into my bhop script.

I was wondering if anyone could help me out on how I would code that in exactly.

Here’s how I did it. Just mess around with it and see how it works to better understand it.


	
local pspeed = math.Clamp(self.ply:GetVelocity():Length2D(), 0, 10000)
if pspeed >= 0.1 then
	speedb = ( math.Clamp(pspeed,20,10000)/45)
	draw.RoundedBox( 0, 11, ScrH()- 34, speedb, 23, Color( r, g, b, 255 ) )
end


math.Clamp

:o Thank you I shall test this out~

[editline]3rd September 2015[/editline]

I get an “attempt to index global ‘self’ (a nil value)” error upon running my script. D:

[editline]3rd September 2015[/editline]

Thanks, coded it into the GUI of my bhop script so I can have a drop down box to turn it on and off. :3

self.ply = LocalPlayer()