Class colors behind the name

Sorry if it’s in wrong category but didn’t know where to place it.

Hey, theres a scirpt im using to change player frames into class colored ones.
Thing is it colors the background behind the name frame but also the health bar. I want it to just color the background behind the name.

local function colour(statusbar, unit)
local _, class, c
if UnitIsPlayer(unit) and UnitIsConnected(unit) and unit == statusbar.unit and UnitClass(unit) then
_, class = UnitClass(unit)
c = CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[class] or RAID_CLASS_COLORS[class]
statusbar:SetStatusBarColor(c.r, c.g, c.b)

    end

end
hooksecurefunc(“UnitFrameHealthBar_Update”, colour)
hooksecurefunc(“HealthBar_OnValueChanged”, function(self)
colour(self, self.unit)

end)

local frame = CreateFrame(“FRAME”)
frame:RegisterEvent(“GROUP_ROSTER_UPDATE”)
frame:RegisterEvent(“PLAYER_TARGET_CHANGED”)
frame:RegisterEvent(“PLAYER_FOCUS_CHANGED”)
frame:RegisterEvent(“UNIT_FACTION”)

local function eventHandler(self, event, …)
if UnitIsPlayer(“target”) then
c = RAID_CLASS_COLORS[select(2, UnitClass(“target”))]
TargetFrameNameBackground:SetVertexColor(c.r, c.g, c.b)
end
if UnitIsPlayer(“focus”) then
c = RAID_CLASS_COLORS[select(2, UnitClass(“focus”))]
FocusFrameNameBackground:SetVertexColor(c.r, c.g, c.b)
end
if PlayerFrame:IsShown() and not PlayerFrame.bg then
c = RAID_CLASS_COLORS[select(2, UnitClass(“player”))]
bg=PlayerFrame:CreateTexture()
bg:SetPoint(“TOPLEFT”,PlayerFrameBackground)
bg:SetPoint(“BOTTOMRIGHT”,PlayerFrameBackground,0,22)
bg:SetTexture(TargetFrameNameBackground:GetTexture())
bg:SetVertexColor(c.r,c.g,c.b)
PlayerFrame.bg=true
end
end

frame:SetScript(“OnEvent”, eventHandler)

for _, BarTextures in pairs({TargetFrameNameBackground, FocusFrameNameBackground}) do
BarTextures:SetTexture(“Interface\TargetingFrame\UI-StatusBar”)
end

I want this script to only color the background behind the name. Does anybody know how to change the script?

I think removing these lines will do the trick.

Also, if you surround your code within three backticks on a line before and after it, it will look much nicer:

local foo = "something"
print (format("Hello %s!", foo))

(For syntax highlight, also put “lua” - without quotes - right after the starting three backticks.)

I’ve already tried removing those lines before i posted it. Sadly it doesn’t work.

f=CreateFrame("FRAME")
f:RegisterEvent("PLAYER_TARGET_CHANGED")
f:RegisterEvent("PLAYER_FOCUS_CHANGED")
f:RegisterEvent("UNIT_FACTION")
f:RegisterEvent("GROUP_ROSTER_UPDATE")

function e(self,event,...)
if UnitIsPlayer("target")
then c=RAID_CLASS_COLORS[select(2,UnitClass("target"))]
TargetFrameNameBackground:SetVertexColor(c.r,c.g,c.b)
end
if UnitIsPlayer("focus")
then c=RAID_CLASS_COLORS[select(2,UnitClass("focus"))]
FocusFrameNameBackground:SetVertexColor(c.r,c.g,c.b)
end
end
f:SetScript("OnEvent",e)

if PlayerFrame:IsShown() and not PlayerFrame.bg then
c=RAID_CLASS_COLORS[select(2,UnitClass("player"))]
bg=PlayerFrame:CreateTexture()
bg:SetPoint("TOPLEFT",PlayerFrameBackground)
bg:SetPoint("BOTTOMRIGHT",PlayerFrameBackground,0,22)
bg:SetTexture(TargetFrameNameBackground:GetTexture())
bg:SetVertexColor(c.r,c.g,c.b)
PlayerFrame.bg=true end
1 Like

Thanks a lot Thyna, i found one meanwhile but it had some issues like changing randomly colors of mobs frames, not that important but was pretty weird. Yours is perfect! Tyvm

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.