Code:

HealthandArmorHud = {};
-- Draws an arc on your screen.
-- startang and endang are in degrees,
-- radius is the total radius of the outside edge to the center.
-- cx, cy are the x,y coordinates of the center of the arc.
-- roughness determines how many triangles are drawn. Number between 1-360; 2 or 3 is a good number.
local cos, sin, abs, max, rad1, log, pow = math.cos, math.sin, math.abs, math.max, math.rad, math.log, math.pow
local surface = surface
function draw.Arc(cx,cy,radius,thickness,startang,endang,roughness,color)
surface.SetDrawColor(color)
surface.DrawArc(surface.PrecacheArc(cx,cy,radius,thickness,startang,endang,roughness))
end
function surface.DrawArc(arc) -- Draw a premade arc.
for k,v in ipairs(arc) do
surface.DrawPoly(v)
end
end
function surface.PrecacheArc(cx,cy,radius,thickness,startang,endang,roughness)
local quadarc = {}
-- Correct start/end ang
local startang,endang = startang or 0, endang or 0
-- Define step
-- roughness = roughness or 1
local diff = abs(startang-endang)
local smoothness = log(diff,2)/2
local step = diff / (pow(2,smoothness))
if startang > endang then
step = abs(step) * -1
end
-- Create the inner circle's points.
local inner = {}
local outer = {}
local ct = 1
local r = radius - thickness
for deg=startang, endang, step do
local rad = rad1(deg)
-- local rad = deg2rad * deg
local cosrad, sinrad = cos(rad), sin(rad) --calculate sin,cos
local ox, oy = cx+(cosrad*r), cy+(-sinrad*r) --apply to inner distance
inner[ct] = {
x=ox,
y=oy,
u=(ox-cx)/radius + .5,
v=(oy-cy)/radius + .5,
}
local ox2, oy2 = cx+(cosrad*radius), cy+(-sinrad*radius) --apply to outer distance
outer[ct] = {
x=ox2,
y=oy2,
u=(ox2-cx)/radius + .5,
v=(oy2-cy)/radius + .5,
}
ct = ct + 1
end
-- QUAD the points.
for tri=1,ct do
local p1,p2,p3,p4
local t = tri+1
p1=outer[tri]
p2=outer[t]
p3=inner[t]
p4=inner[tri]
quadarc[tri] = {p1,p2,p3,p4}
end
-- Return a table of triangles to draw.
return quadarc
end
hook.Add("HUDPaint", "HealthandArmorHudPaint", function()
local maxHealth = LocalPlayer():GetMaxHealth()
local health = math.Clamp(LocalPlayer():Health(), 0, maxHealth)
local armor = math.Clamp(LocalPlayer():Armor(), 0, 100)
local healthAng = (health / maxHealth) * 191.7
local armorAng = (armor / 100) * 191.7
draw.Arc( 160, 160, 150, 10, 90, 90 + 191.7, 1, Color( 0, 0, 0, 75 ) )
draw.Arc( 160, 160, 150, 10, 90, 90 - 191.7, 1, Color( 0, 0, 0, 75 ) )
if health <= maxHealth then
local i = maxHealth - health
draw.Arc( 160, 160, 150, 10, 90, 90 + healthAng, 1, Color( 73 + i, 255 - i, 73, 200 ) )
end
draw.Arc( 160, 160, 150, 10, 90, 90 - armorAng, 1, Color( 73, 73, 255, 200 ) )
end )