hook.Add("HUDPaint", "HealthAndArmorPaint", function()
local scrW, scrH = ScrW(), ScrH()
local boxW = scrW * 0.12
local boxH = scrH * 0.007
local ply = LocalPlayer()
local hp = ply:Health()
local maxHp = ply:GetMaxHealth()
local armor = ply:Armor()
local maxArmor = ply:GetMaxArmor()
local weapon = ply:GetActiveWeapon()
local vignette = Material("materials/vignette.png")
local TarkovStand = Material("materials/tarkovstand.png")
local TarkovSit = Material("materials/tarkovsit.png")
local TarkovLean = Material("materials/tarkovlean.png")
function drawVignette()
surface.SetMaterial(vignette)
surface.SetDrawColor(255, 255, 255, 205)
surface.DrawTexturedRect(0, 0, ScrW(), ScrH())
end
function drawVignetteOnBars(x, y, wide, height)
surface.SetMaterial(vignette)
surface.SetDrawColor(255, 255, 255, 215)
surface.DrawTexturedRect(x, y, wide, height)
end
function drawTriangle(trianglePos)
surface.SetDrawColor(240, 240, 240, 225)
draw.NoTexture()
surface.DrawPoly(trianglePos)
end
function drawWhiteRects(y)
surface.SetDrawColor(255, 255, 255, 160)
for i = 1, 7 do
surface.DrawRect(30, y, boxH * 0.62, boxH * 0.62)
if (i == 6) then
y = y + 64
else
y = y + 30
end
end
end
triangleStand = {
{x = 17, y = scrH * .745},
{x = 17, y = scrH * .74},
{x = 22, y = scrH * .742}
}
triangleSit = {
{x = 17, y = scrH * .745 + 5 * 30},
{x = 17, y = scrH * .74 + 5 * 30},
{x = 22, y = scrH * .742 + 5 * 30}
}
triangleLean = {
{x = 17, y = scrH * .745 + scrH * .198},
{x = 17, y = scrH * .74 + scrH * .198},
{x = 22, y = scrH * .742 + scrH * .198}
}
if (ply:Alive()) then
if (weapon:IsValid()) then
if (weapon:Clip1() != -1) then
draw.WordBox(2, scrW * .15, scrH * .95, weapon:Clip1() .. "/" .. ply:GetAmmoCount(weapon:GetPrimaryAmmoType()), "AmmoFont", Color(0, 0, 0, 120), Color(255, 255, 255, 120), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
else
draw.WordBox(2, scrW * .15, scrH * .95, ply:GetAmmoCount(weapon:GetPrimaryAmmoType()), "AmmoFont", Color(0, 0, 0, 120), Color(255, 255, 255, 120), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
end
if (ply:GetAmmoCount(weapon:GetSecondaryAmmoType()) > 0) then
draw.WordBox(2, scrW * .19, scrH * .95, ply:GetAmmoCount(weapon:GetSecondaryAmmoType()), "AmmoFont", Color(0, 0, 0, 120), Color(222, 31, 31, 120), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
end
end
surface.SetDrawColor(48, 48, 48, 255)
surface.DrawRect(51, scrH * .95, boxW + 4, boxH + 4)
surface.SetDrawColor(0, 0, 0, 160)
surface.DrawRect(53, scrH * .952, boxW, boxH)
surface.SetDrawColor(48, 48, 48, 255)
surface.DrawRect(51, scrH * .965, boxW + 4, boxH + 4)
surface.SetDrawColor(0, 0, 0, 160)
surface.DrawRect(53, scrH * .967, boxW, boxH)
surface.SetDrawColor(0, 0, 0, 220)
surface.DrawRect(29, scrH * .742 - 1, boxH * 0.62 + 2, boxW * .95 + 2)
surface.SetDrawColor(94, 94, 94, 140)
surface.DrawRect(30, scrH * .742, boxH * 0.62, boxW * .95)
if (hp >= maxHp) then
surface.SetDrawColor(68, 160, 235, 255)
surface.DrawRect(53, scrH * .952, boxW, boxH)
else
surface.SetDrawColor(68, 160, 235, 255)
surface.DrawRect(53, scrH * .952, boxW * (hp / maxHp), boxH)
end
if (armor >= maxArmor) then
surface.SetDrawColor(63, 217, 132, 255)
surface.DrawRect(53, scrH * .967, boxW, boxH)
else
surface.SetDrawColor(63, 217, 132, 255)
surface.DrawRect(53, scrH * .967, boxW * (armor / maxArmor), boxH)
end
drawVignetteOnBars(53, scrH * .952, boxW, boxH)
drawVignetteOnBars(53, scrH * .967, boxW, boxH)
drawWhiteRects(scrH * .742)
if (ply:Crouching()) then
surface.SetDrawColor(255, 255, 255, 220)
surface.SetMaterial(TarkovSit)
surface.DrawTexturedRect(55, scrH * .712, scrW * .105, scrH * .236)
drawTriangle(triangleSit)
elseif (ply:IsProne()) then
surface.SetDrawColor(255, 255, 255, 220)
surface.SetMaterial(TarkovLean)
surface.DrawTexturedRect(55, scrH * .712, scrW * .166, scrH * .237)
drawTriangle(triangleLean)
else
surface.SetDrawColor(255, 255, 255, 220)
surface.SetMaterial(TarkovStand)
surface.DrawTexturedRect(55, scrH * .712, scrW * .105, scrH * .236)
drawTriangle(triangleStand)
end
end
end)