Originally Posted by Fizzlemizz
You're dead?
It should be gold text in the middle of your screen even if it's just 0/0.
If you're comming from an initial login rather than a /reload you can change the inital text setting to the PLAYER_LOGIN event.
You can change the "UNIT_HEALTH" to "UNIT_HEALTH_FREQUENT" if your doing this in Classic (leave it as is for BCC).
Lua Code:
local function UpdateHealth(self) -- Update the health text local health = UnitHealth("player") self.Text:SetText(health .. '/' .. self.healthMax) end local function UpdateHealthMax(self) -- Update min./max. health values self.healthMax = UnitHealthMax("player") UpdateHealth(self) end local f = CreateFrame("Frame", "nibsrsHealthText", UIParent) f:SetSize(5, 4) f:SetPoint("CENTER") f.Text = f:CreateFontString() f.Text:SetFontObject(GameFontNormal) f.Text:SetPoint("CENTER") f.Text:SetJustifyH("CENTER") f.Text:SetJustifyV("CENTER") f:SetScript("OnEvent", function(self, event, ...) if event == "UNIT_HEALTH" then -- Fired when health changes UpdateHealth(self) elseif event == "PLAYER_LOGIN" or event == "UNIT_MAXHEALTH" then -- Fired when max. health changes UpdateHealthMax(self) end end) f:RegisterEvent("UNIT_HEALTH") -- register the events to be used f:RegisterEvent("UNIT_MAXHEALTH") f:RegisterEvent("PLAYER_LOGIN") -- Fires only once before the "PLAYER_ENTERING_WORLD" event.
|
Sorry, it was my mistake lol Thank you so much!