Applying effects on status
About
In previous updates we've created a new export ApplyEffects
that's still in development.
This small thing can make some element appear as active by animating it to the top for example.
Applying
If you would like to apply effect on some status element (in our example it will be health status), you can use your own handle (in some other resource) or to use our gatherers in client/addon/status.lua
. In that example we will be using second option.
Inside /client/addon/status.lua
we've added some statement to make health indication that it's low:
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
end
Export and function
NUI.ApplyEffectOnInterfaceElement(interface, status, state) -- ONLY USE IT IN ZSX_UIV2
-- or
exports['ZSX_UIV2']:ApplyEffect(interface, status, state) -- USE IT OUTSIDE OF ZSX_UIV
Last updated