Code:
colorChatNamesByClass
is the CVar controlling class colors on player names.
The actual color information you can get for any player unit where you can get to their baseClass
through
Code:
_, baseClass = GetPlayerInfoByGUID(guid)
or
Code:
_, baseClass = UnitClass(unit)
then
Code:
local classColorTable = RAID_CLASS_COLORS[baseClass]
So when you have a valid
UnitId or
GUID you can get their class information and from that the color information.