Applying effects on status
About
Applying
local healthEffectAppeared = false -- preventing overcalling the effect
Config.Hud.Status['health'].get = function()
local currentTime = GetGameTimer()
if currentTime - lastMaxHealthCheck > 5000 then
cachedMaxHealth = GetEntityMaxHealth(Threads.Players.Data['ped'])
lastMaxHealthCheck = currentTime
end
if cachedMaxHealth < 30 and not healthEffectAppeared then -- statements
healthEffectAppeared = true
NUI.ApplyEffectOnInterfaceElement('hud', 'health', true) -- applying effect on hud on status hunger with state true
elseif cachedMaxHealth >= 30 and healthEffectAppeared then
healthEffectAppeared = false
NUI.ApplyEffectOnInterfaceElement('hud', 'health', false) -- applying effect on hud on status hunger with state false
end
return (GetEntityHealth(Threads.Players.Data['ped']) - 100) / (cachedMaxHealth - 100) * 100
endExport and function
Last updated