Thread: Beginner
View Single Post
04-11-18, 01:20 PM   #41
GreyFox777
A Cliff Giant
Join Date: Jan 2017
Posts: 75
Hey guys, why my health color are not refreshing automatically if entering AFK?

local function UpdateHealthColor(health, unit, cur, max)
health:RegisterEvent('PLAYER_FLAGS_CHANGED')
local r, g, b, t
-- local afk = UnitIsAFK(unit)

if(health.disconnected and health.colorDisconnected or UnitIsDeadOrGhost(unit)) then
health:SetValue(max)
t = colors.disconnected
elseif(health.colorTapping and not UnitPlayerControlled(unit) and UnitIsTapDenied(unit)) then
t = colors.tapped

elseif UnitIsAFK(unit) then
r, g, b = 1, 0, 0
health:SetScript('OnEvent', UpdateHealthColor)

elseif(health.colorSmooth) then
r, g, b = health.__owner.ColorGradient(cur, max, unpack(colors.smooth))
else
t = colors.health
end

if(t) then
r, g, b = t[1], t[2], t[3]
end

if(b) then
health:SetStatusBarColor(r, g, b)
end
end
  Reply With Quote