Healthbar

Hello,

I got a question. How do i set the healthbar to a rounding shape? So it’s going in a circle.

Thank you!

Do you want it like an arc or a filled circle?

Think he means arc

Arc: http://forum.facepunch.com/showthread.php?t=1524258&p=50582620 - top of the page

Circle: https://wiki.garrysmod.com/page/surface/DrawPoly - example 2

And then to make it do the full 360, you would do something like this (this applies to the arc. It can easily be changed from draw.Arc to draw.Circle):



hook.Add("HUDPaint", "wefghyui", function()

	local maxHealth = LocalPlayer():GetMaxHealth()
	local health = math.Clamp(LocalPlayer():Health(), 0, maxHealth)

	local healthAng = (health / maxHealth) * 360
	draw.Arc( 160, 160, 150, 10, 90, 90 + healthAng, 1, Color( 73, 255, 73, 200 ) )


Thanks dude!

But how do i set my health in the arc?

Could you possibly elaborate on that as I am not quite sure what you want.

For example put this in a arc:


  draw.RoundedBox( 0, 835, ScrH() - 90, 230 * hp, 45, Color( 225, 255, 255, 150)) 

I won’t do it for you but I can explain how the code for the arc works. Using the function from the code from this website (https://facepunch.com/showthread.php...258&p=50582620), we can use the draw.Arc function to draw the arc.



draw.Arc( x coordinates, y coordinates, radius of circle, thickness, starting degress (90 for the top), stopping degrees, 1 (Forgot what the 1 does), Color( codes ) )


So if we put that into code so it makes more sense, then you would have something like this:



local healthAng = (health / maxHealth) * 360 -- What degrees around the arc it will go. 360 for full arc.
draw.Arc( 160, 160, 150, 10, 90, 90 + healthAng, 1, Color( 73, 255, 73, 200 ) ) -- The + represents which direction it goes. + to go left, - to go right.


If you have done this correctly, you should have something similar to this: http://imgur.com/a/6BQVI (ignore the radar as I have been working on this sort of thing lately.

Not sure if this little tutorial makes sense. I might change a few things later on.


 [ERROR] lua/autorun/client/cl_shud.lua:55: attempt to perform arithmetic on global 'Health' (a nil value)
  1. v - lua/autorun/client/cl_shud.lua:55
   2. unknown - lua/includes/modules/hook.lua:84 

What to do?

Does this code exist?:



local maxHealth = LocalPlayer():GetMaxHealth()
local health = math.Clamp(LocalPlayer():Health(), 0, maxHealth)


Now i get this error:


 
[ERROR] lua/autorun/client/cl_fhud.lua:59: attempt to call field 'Arc' (a nil value)
  1. v - lua/autorun/client/cl_fhud.lua:59
   2. unknown - lua/includes/modules/hook.lua:84
 

Did not work… that’s why im posting the error…

According to the error, you’re not even using the Arc code.
Can we see the code? Because, you know. Saying “It doesn’t work” doesn’t help at all.

Ehm, silly mistake…
Forgot to paste a half of the code <3 <3 <3