Ok so I think I'm getting closer..
I know this may seem long and drawn out but seems the only choice I have at the moment...
Code:
local function UpdateFrame(frame, guid, name)
if (not frame.text) then
SkinFrame(frame)
end
frame.inUse = true
local class
if (guid ~= nil and guid ~= '') then
_, class, _, _, _, _ = GetPlayerInfoByGUID(guid)
end
CUSTOM_FACTION_BAR_COLORS = {
[1] = {r = 1, g = 0, b = 0},
[2] = {r = 1, g = 0, b = 0},
[3] = {r = 1, g = 1, b = 0},
[4] = {r = 1, g = 1, b = 0},
[5] = {r = 0, g = 1, b = 0},
[6] = {r = 0, g = 1, b = 0},
[7] = {r = 0, g = 1, b = 0},
[8] = {r = 0, g = 1, b = 0},
}
-- Find Unit Types
for _, UNITZ in pairs ({
-- Main Units
player, pet, vehicle, target, focus, mouseover, none, npc,
-- Party Members
party1, party2, party3, party4,
-- Party Pets
partypet1, partypet2, partypet3, partypet4,
-- Raid Players
raid1, raid2, raid3, raid4, raid5, raid6, raid7, raid8, raid9, raid10,
raid11, raid12, raid13, raid14, raid15, raid16, raid17, raid18, raid19, raid20,
raid21, raid22, raid23, raid24, raid25, raid26, raid27, raid28, raid29, raid30,
raid31, raid32, raid33, raid34, raid35, raid36, raid37, raid38, raid39, raid40,
-- Raid Player Pets
raidpet1, raidpet2, raidpet3, raidpet4, raidpet5, raidpet6, raidpet7, raidpet8, raidpet9, raidpet10,
raidpet11, raidpet12, raidpet13, raidpet14, raidpet15, raidpet16, raidpet17, raidpet18, raidpet19, raidpet20,
raidpet21, raidpet22, raidpet23, raidpet24, raidpet25, raidpet26, raidpet27, raidpet28, raidpet29, raidpet30,
raidpet31, raidpet32, raidpet33, raidpet34, raidpet35, raidpet36, raidpet37, raidpet38, raidpet39, raidpet40,
-- Bosses
boss1, boss2, boss3, boss4, boss5,
-- Arena Players
arena1, arena2, arena3, arena4, arena5,
}) do
reaction = UnitReaction(UNITZ, "player")
end
if (name) then
local color = RAID_CLASS_COLORS[class] or CUSTOM_FACTION_BAR_COLORS[reaction]
frame.sender:SetText(('|cFF%2x%2x%2x%s|r'):format(color.r * 255, color.g * 255, color.b * 255, name))
if frame.text:GetWidth() < frame.sender:GetWidth() then
frame.text:SetWidth(frame.sender:GetWidth())
end
end
end
Now for players again it works fine, but for my NPC in my Garrison I get a color error