Thread Tools Display Modes
07-02-10, 08:31 AM   #1
ventilator
A Murloc Raider
Join Date: Jul 2010
Posts: 4
class icon in chat

Hey,

I'm trying to put next to the player name the class icon using GetPlayerInfoByGUID. So it would look this:
class icon - unit whispers: message
but instead it is shown like this:
|Hplayer: - icon - unit - :2103 - icon - unit whispers: message
2103 seems to be the lineID (http://www.wowwiki.com/CHAT_MSG_CHAN...AT_MSG_CHANNEL) but I can't figure out where the |Hplayer: comes from.
However it looks only this odd whenever I put the icon next to the player name (it works if the icon is in the message)

Maybe a screenshot will explain better what I mean:
(in the chat message)
http://img641.imageshack.us/f/doesntwork.jpg
(next to the player name)
http://img59.imageshack.us/f/workj.jpg

Code:
local classIcons = {
	DEATHKNIGHT = "Interface\\Icons\\Spell_Deathknight_ClassIcon",
	DRUID = "Interface\\Icons\\INV_Misc_MonsterClaw_04",
	WARLOCK = "Interface\\Icons\\Spell_Nature_FaerieFire",
	HUNTER = "Interface\\Icons\\INV_Weapon_Bow_07",
	MAGE = "Interface\\Icons\\INV_Staff_13",
	PRIEST = "Interface\\Icons\\INV_Staff_30",
	WARRIOR = "Interface\\Icons\\INV_Sword_27",
	SHAMAN = "Interface\\Icons\\Spell_Nature_BloodLust",
	PALADIN = "Interface\\AddOns\\addon\\UI-CharacterCreate-Classes_Paladin",
	ROGUE = "Interface\\AddOns\\addon\\UI-CharacterCreate-Classes_Rogue",
}

function addPlayerIcons(self, event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12)
  local _, fontSize = GetChatWindowInfo(self:GetID())
  local _, class = GetPlayerInfoByGUID(arg12)
  local arg2 = "|T"..classIcons[class]..":"..fontSize.."|t"..arg2
  return false, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12
end

ChatFrame_AddMessageEventFilter("CHAT_MSG_CHANNEL", addPlayerIcons)
ChatFrame_AddMessageEventFilter("CHAT_MSG_SAY", addPlayerIcons)
ChatFrame_AddMessageEventFilter("CHAT_MSG_YELL", addPlayerIcons)
ChatFrame_AddMessageEventFilter("CHAT_MSG_GUILD", addPlayerIcons)
ChatFrame_AddMessageEventFilter("CHAT_MSG_WHISPER", addPlayerIcons)
  Reply With Quote
07-02-10, 01:17 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Have a look at ChatIcons: http://www.wowinterface.com/download...ChatIcons.html
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
07-03-10, 06:49 PM   #3
ventilator
A Murloc Raider
Join Date: Jul 2010
Posts: 4
I think I figured it out. The author used this pattern
Code:
"|Hplayer:([^|:]+)
to clean the icon. I already knew the addon but I always overlooked this part of the code.

I'm new to writing addons in WoW as you can see

Thanks for the help.
  Reply With Quote
07-03-10, 10:54 PM   #4
v6o
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 399
If you let blizzard's chat system color the names of the people you could probably just use that and just do a reverse lookup (color -> class)
__________________
I stopped playing back World of Warcraft in 2010 and I have no plans on returning.
This is a dead account and if you want to continue any of my addons or make a fork then feel free to do so.
This is your permission slip.

If you need to contact me, do so on Twitter @v6ooo

Best regards, v6.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » class icon in chat


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off