Don't worry, you're fine. I wasn't attacking you, just informing you. You don't need UnitGUID to get a player's GUID from chat, it comes in the 12th argument in chat event payloads. It's how that cvar I mentioned works in the UI code.
Lua Code:
function ChatClassColorOverrideShown()
local value = GetCVar("chatClassColorOverride");
if value == "0" then
return true;
elseif value == "1" then
return false;
else
return nil;
end
end
function Chat_ShouldColorChatByClass(chatTypeInfo)
local override = ChatClassColorOverrideShown();
local colorByClass = chatTypeInfo and chatTypeInfo.colorNameByClass;
return override or (override == nil and colorByClass);
end
function GetColoredName(event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12)
-- truncate...
if ( arg12 and info and Chat_ShouldColorChatByClass(info) ) then
local localizedClass, englishClass, localizedRace, englishRace, sex = GetPlayerInfoByGUID(arg12)
if ( englishClass ) then
local classColorTable = RAID_CLASS_COLORS[englishClass];
if ( not classColorTable ) then
return arg2;
end
return string.format("\124cff%.2x%.2x%.2x", classColorTable.r*255, classColorTable.g*255, classColorTable.b*255)..arg2.."\124r"
end
end
-- truncate...
end
GetColoredName is called every single time ChatFrame_MessageEventHandler is called. Also, as long as any event gives you the GUID, it will return usable values, no matter who the player is. It's a universal solution for every player your UI interacts with. You're right about the cache thing, but there's no point in asking for info about an offline player or a player you don't see anywhere in the UI anyways.