--by pavetr.top/ds hook.Add("HUDPaint", "DrawArmorBarWH", function() local ply = LocalPlayer() if not IsValid(ply) then return end for _, target in ipairs(player.GetAll()) do if target == ply then continue end if not IsValid(target) or not target:Alive() then continue end local armor = target:Armor() local maxArmor = target.GetMaxArmor and target:GetMaxArmor() or 100 -- Получаем границы модели local mins, maxs = target:GetModelBounds() if not mins or not maxs then continue end -- Позиции головы и ног local headPos = target:LocalToWorld(Vector(0, 0, maxs.z)) local feetPos = target:LocalToWorld(Vector(0, 0, mins.z)) local center = (headPos + feetPos) / 2 -- Смещение вправо от модели (чтобы бар не перекрывал игрока) local camRight = EyeAngles():Right() -- вектор "вправо" от камеры local offsetRight = camRight * 24 local barWorldPos = center + offsetRight -- Преобразуем в экранные координаты local barScreen = barWorldPos:ToScreen() local headScreen = headPos:ToScreen() local feetScreen = feetPos:ToScreen() -- Размеры бара (фиксированные, не зависят от расстояния) local barHeight = math.abs(headScreen.y - feetScreen.y) local barWidth = 4 -- Координаты для рисования local x = barScreen.x local y = math.min(headScreen.y, feetScreen.y) -- Рисуем рамку surface.SetDrawColor(0, 0, 0, 255) surface.DrawOutlinedRect(x, y, barWidth, barHeight) -- Заполнение local fillHeight = math.Clamp((armor / maxArmor) * barHeight, 0, barHeight) surface.SetDrawColor(0, 128, 255, 255) surface.DrawRect(x + 1, y + barHeight - fillHeight + 1, barWidth - 2, fillHeight - 2) -- Цифра брони (чуть правее бара) draw.SimpleText( tostring(armor), "DermaDefaultBold", x + barWidth + 6, y + barHeight - fillHeight, Color(0, 128, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_BOTTOM ) end end)