Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function nameplateHealthText(unit, healthBar)
- if not healthBar then return false end
- if not healthBar.text and UnitIsEnemy("player", unit) then
- healthBar.text = healthBar:CreateFontString(nil, "ARTWORK", nil)
- healthBar.text:SetPoint("CENTER")
- healthBar.text:SetFont("Fonts\\2002b.TTF", 11, "OUTLINE, THICKOUTLINE")
- end
- if UnitIsEnemy("player", unit) then
- local _, maxHealth = healthBar:GetMinMaxValues()
- local currentHealth = healthBar:GetValue()
- if(healthBar.text) then
- healthBar.text:SetText(string.format(math.floor ((currentHealth / maxHealth) * 100)) .. "%")
- end
- if healthBar and not healthBar.lockValues then
- local cur=healthBar:GetValue()
- local _, max = healthBar:GetMinMaxValues()
- local r, g, b=1, 0, 0
- if cur/max>0.30 then r,g,b=1,1,1 end
- if healthBar.text then
- healthBar.text:SetTextColor(r,g,b)
- end
- end
- else
- if(healthBar.text) then
- healthBar.text:SetText("")
- end
- end
- end
- local function nameplateHealthTextFrame(self)
- local inInstance, instanceType = IsInInstance()
- if inInstance and not (instanceType == 'arena' or instanceType =='pvp') then
- if self:IsForbidden() then return end
- end
- if self.unit and self.unit:find('nameplate%d') then
- if self.healthBar and self.unit then
- if UnitName("player") ~= UnitName(self.unit) then
- local unit = self.unit
- local healthBar = self.healthBar
- nameplateHealthText(unit, healthBar)
- end
- end
- end
- end
- local function nameplatePlayerName(self)
- if ShouldShowName(self) then
- if self.optionTable.colorNameBySelection then
- local inInstance, instanceType = IsInInstance()
- if inInstance and not (instanceType == 'arena' or instanceType =='pvp') then
- if self:IsForbidden() then return end
- end
- -- Classcolor Playername
- --if self.unit then
- -- local _, class = UnitClass(self.unit)
- -- local color = RAID_CLASS_COLORS[class]
- -- -- if UnitIsPlayer(self.unit) and UnitIsEnemy("player", self.unit) and self.name then
- -- -- if UnitIsPlayer(self.unit) and self.name then
- -- self.name:SetVertexColor(color.r, color.g, color.b)
- -- end
- --end
- -- -- Hide Servername
- -- if db.server then
- -- if self.name and self.unit then
- -- if UnitIsPlayer(self.unit) then
- -- local name, server = UnitName(self.unit)
- -- self.name:SetText(name)
- -- end
- -- end
- -- end
- -- Font Size Function
- local function SetFont(obj, optSize)
- local fontName = obj:GetFont()
- obj:SetFont(fontName, optSize, "OUTLINE")
- end
- -- Set Font Size for Nameplate Names
- SetFont(SystemFont_LargeNamePlate, 15)
- SetFont(SystemFont_NamePlate, 15)
- SetFont(SystemFont_LargeNamePlateFixed, 15)
- SetFont(SystemFont_NamePlateFixed, 15)
- end
- end
- end
- -- Set Nameplate Health Percentage
- hooksecurefunc("CompactUnitFrame_UpdateHealthColor", nameplateHealthTextFrame)
- hooksecurefunc("CompactUnitFrame_UpdateHealth", nameplateHealthTextFrame)
- hooksecurefunc("CompactUnitFrame_UpdateStatusText", nameplateHealthTextFrame)
- -- Set Nameplate Name Color
- hooksecurefunc("CompactUnitFrame_UpdateName", nameplatePlayerName)
Advertisement
Add Comment
Please, Sign In to add comment