Messing around with markers until I somehow did this:
(hi Mikeeh)
It turns black on death, yellow on damage (lazy to fix ok)
health.zip (818 Bytes)
Messing around with markers until I somehow did this:
(hi Mikeeh)
It turns black on death, yellow on damage (lazy to fix ok)
health.zip (818 Bytes)
Updated to work with newest FiveM update.
New download available in original post (Ver2)
Pleass new link! I need this!
Links are dead ((( please reupload
Link updated and hopefully permanent:
health.zip (818 Bytes)
Had a few issues with the lerp. It returns floats so it’s messing with the DrawMarker function. Here’s what I changed:
function colorLerp(x1, y1, z1, x2, y2, z2, t)
t = math.min(t, 1.0)
local x = x1 + (x2 - x1) * t
local y = y1 + (y2 - y1) * t
local z = z1 + (z2 - z1) * t
return math.min(math.floor(math.abs(x)),255), math.min(math.floor(math.abs(y)),255), math.min(math.floor(math.abs(z)),255)
end
And this goes in the while / for loop:
-- Triangle health bar
local ped = GetPlayerPed(id)
local health = GetEntityHealth(ped) - 100 or 0.0
local maxHealth = GetEntityMaxHealth(ped) - 100 or 0.0
local ratio = health/maxHealth
if IsPedDeadOrDying(ped, 1) then
r,g,b = 0,0,0
else
r,g,b = colorLerp(255,0,0,0,255,0,ratio)
end
-- drawText(health..' '..maxHealth..' '..ratio..' '..r..' '..g..' '..b, 0.5, 0.5, { size = 0.8 })
local x1,y1,z1 = table.unpack(GetWorldPositionOfEntityBone(ped, i))
DrawMarker(3,x1,y1,z1+1.5, 0.0, 0.0, 0.0, 0.0, 180.0, 0.0, 0.3, 0.3, 0.3, r, g, b, 75, false, true, false, false)
Color seems correct now. Let me know if I did something wrong.
Damn this is cool.