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
[QUOTE=FireWolf2525;52629630]Do you want it like an arc or a filled circle?[/QUOTE]
Arc: [url]https://facepunch.com/showthread.php?t=1524258&p=50582620[/url] - top of the page
Circle: [url]https://wiki.garrysmod.com/page/surface/DrawPoly[/url] - 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):
[code]
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 ) )
[/code]
[QUOTE=FireWolf2525;52629645]Arc: [url]https://facepunch.com/showthread.php?t=1524258&p=50582620[/url] - top of the page
Circle: [url]https://wiki.garrysmod.com/page/surface/DrawPoly[/url] - 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):
[code]
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 ) )
[/code][/QUOTE]
Thanks dude!
But how do i set my health in the arc?
[QUOTE=Scepto;52629651]Thanks dude!
But how do i set my health in the arc?[/QUOTE]
Could you possibly elaborate on that as I am not quite sure what you want.
[QUOTE=FireWolf2525;52629668]Could you possibly elaborate on that as I am not quite sure what you want.[/QUOTE]
For example put this in a arc:
[code] draw.RoundedBox( 0, 835, ScrH() - 90, 230 * hp, 45, Color( 225, 255, 255, 150)) [/code]
[QUOTE=Scepto;52629810]For example put this in a arc:
[code] draw.RoundedBox( 0, 835, ScrH() - 90, 230 * hp, 45, Color( 225, 255, 255, 150)) [/code][/QUOTE]
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 ([url]https://facepunch.com/showthread.php...258&p=50582620[/url]), we can use the draw.Arc function to draw the arc.
[code]
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 ) )
[/code]
So if we put that into code so it makes more sense, then you would have something like this:
[code]
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.
[/code]
If you have done this correctly, you should have something similar to this: [url]http://imgur.com/a/6BQVI[/url] (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.
[QUOTE=FireWolf2525;52630010]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 ([url]https://facepunch.com/showthread.php...258&p=50582620[/url]), we can use the draw.Arc function to draw the arc.
[code]
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 ) )
[/code]
So if we put that into code so it makes more sense, then you would have something like this:
[code]
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.
[/code]
If you have done this correctly, you should have something similar to this: [url]http://imgur.com/a/6BQVI[/url] (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.[/QUOTE]
[code] [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 [/code]
What to do?
[QUOTE=Scepto;52630278][code] [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 [/code]
What to do?[/QUOTE]
Does this code exist?:
[code]
local maxHealth = LocalPlayer():GetMaxHealth()
local health = math.Clamp(LocalPlayer():Health(), 0, maxHealth)
[/code]
[QUOTE=FireWolf2525;52630295]Does this code exist?:
[code]
local maxHealth = LocalPlayer():GetMaxHealth()
local health = math.Clamp(LocalPlayer():Health(), 0, maxHealth)
[/code][/QUOTE]
Now i get this error:
[code]
[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
[/code]
[QUOTE=Scepto;52633165]Now i get this error:
:snip: dumb error[/QUOTE]
[QUOTE=FireWolf2525;52629645][B]Arc: [url]https://facepunch.com/showthread.php?t=1524258&p=50582620[/url] - top of the page[/B]
Circle: [url]https://wiki.garrysmod.com/page/surface/DrawPoly[/url] - example 2[/QUOTE]
[QUOTE=FireWolf2525;52630010]I won't do it for you but I can explain how the code for the arc works. [B]Using the function from the code from this website ([url]https://facepunch.com/showthread.php?t=1524258&p=50582620[/url]), we can use the draw.Arc function to draw the arc.[/B][/QUOTE]
[QUOTE=geferon;52633291][/QUOTE]
Did not work... that's why im posting the error....
[QUOTE=Scepto;52633303]Did not work... that's why im posting the error....[/QUOTE]
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.
[QUOTE=geferon;52633406]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.[/QUOTE]
Ehm, silly mistake...
Forgot to paste a half of the code <3 <3 <3
Sorry, you need to Log In to post a reply to this thread.