WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   PTR General Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=172)
-   -   Simple Nameplate Addon help needed (https://www.wowinterface.com/forums/showthread.php?t=58256)

Ayacoz 10-07-20 11:35 AM

Simple Nameplate Addon help needed
 
Hi there, i need some advice/help about an addon that i use.

Someone here in the forums did the code for me

local NamePlateHealthText={};
hooksecurefunc(NamePlateDriverFrame,"OnNamePlateCreated",function(self,base)-- Hook Nameplate creation
local unitframe=base.UnitFrame;

local health=unitframe.healthBar:CreateFontString(nil,"OVERLAY");
health:SetFont("Fonts\\FRIZQT__.TTF",12,"OUTLINE");-- Fonts are easier to read when made from scratch rather than resizing an inherited one
health:SetPoint("CENTER");
health:SetTextColor(1,1,1);

NamePlateHealthText[unitframe]=health;
end);

hooksecurefunc("CompactUnitFrame_UpdateHealth",function(self)-- This is a shared function with other UnitFrames
if NamePlateHealthText[self] then
local cur,max=UnitHealth(self.displayedUnit),UnitHealthMax(self.displayedUnit);
NamePlateHealthText[self]:SetFormattedText("%d - %.0f%%",cur,100*cur/max); end
end);


It works great for BfA, but ion Shadowlands, it doesnt, can anyone help me out ?


L3n1n 04-22-21 05:25 AM

I know this is necroposting but i wrote solution for you:

Code:

hooksecurefunc("CompactUnitFrame_UpdateStatusText", function(frame)
        if frame:IsForbidden() then return end
        if frame.statusText then return end

        if not frame.healthBar.value then
                frame.healthBar.value = frame.healthBar:CreateFontString("$parentHeathValue", "OVERLAY")
                frame.healthBar.value:SetPoint("CENTER", frame.healthBar)
                frame.healthBar.value:SetFont('Fonts\\FRIZQT__.ttf', 12, "OUTLINE")
        end

        local cur, max = UnitHealth(frame.displayedUnit), UnitHealthMax(frame.displayedUnit)
        if cur > 0 then
                frame.healthBar.value:SetFormattedText("%d - %.0f%%", cur, 100*cur/max)
        else
                frame.healthBar.value:SetText("")
        end
end)



All times are GMT -6. The time now is 05:22 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI