local sw, sh = guiGetScreenSize()
local sx, sy = sw/1920, sh/1080 -- change those number with your resolution
local PedA = createPed(285, 1571.49634, -1664.07715, 28.39561, 90)
function healthbar()
local plr = localPlayer
local x, y, z = getElementPosition(PedA)
target = getPedTarget(plr)
if (not target) then
return false
end
if (not getElementType(target) == "ped" ) then
return false
end
if (not isElementOnScreen(PedA)) then
return false
end
local X, Y = getScreenFromWorldPosition(x, y, z)
if (X) then
local healthA = dxDrawRectangle(X - 50, Y - 50, sx*270, sy*27, tocolor(241, 236, 253, 114), false)
local health = getElementHealth(PedA)
local lineLength = 256 * (health / 100)
local healthB = dxDrawRectangle(X - 44, Y - 44, lineLength, sy*17, tocolor(9, 172, 213, 254), false)
end
end
addEventHandler("onClientRender", root, healthbar)