I wrote a mod (ForumName2 on WoWI) a while back that pastes a custom note next to peoples' names in chat messages by running the code below in a hook of ChatFrame.AddMessage for each chat frame. In the post 4.0 UI code though, the code below doesn't do anything because "event" doesn't exist.
function ForumName2:AddMessage(frame, msg, ...)
if(event == "CHAT_MSG_SYSTEM") then
for i, info in pairs(systemMessageInfo) do
local output = self:SystemMessageHelper(msg, info, string_match(msg, info.pattern))
if(output) then
msg = output
break
end
end
elseif(chatEvents[event]) then
local note = self:GetNote(arg2)
if note then
msg = string_gsub(msg, "|h(.*)" .. arg2 .. "(.*)|h", "|h%1" .. arg2 .. " (" .. note .. ")" .. "%2|h", 1)
end
end
self.hooks[frame]["AddMessage"](frame, msg, ...)
end
I tried changing this to use the chat message filter system, but the message you are passed in a chat filter does not contain the full formatting so I can't put the note next to the player's name as in the above code. I also tried just changing the name (which IS passed to you in the chat filter) but this causes issues with display in further messages.
So, I'm looking for a way to either a) get access to "event" in ChatFrame_AddMessage or b) accomplish the above using chat message filters. Any ideas?
function ForumName2:AddMessage([B]event[/B], msg, ...)
if(event == "CHAT_MSG_SYSTEM") then
for i, info in pairs(systemMessageInfo) do
local output = self:SystemMessageHelper(msg, info, string_match(msg, info.pattern))
if(output) then
msg = output
break
end
end
elseif(chatEvents[event]) then
local note = self:GetNote(arg2)
if note then
msg = string_gsub(msg, "|h(.*)" .. arg2 .. "(.*)|h", "|h%1" .. arg2 .. " (" .. note .. ")" .. "%2|h", 1)
end
end
self.hooks[[B]self[/B]]["AddMessage"]([B]self[/B], event, msg, ...)
end
Since that's the only code you posted, I'm going to assume that you know how to fix everything else that's related.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Oops. I didn't notice it was an :AddMessage(). I was preoccupied by the improperly used self, and frame variables.
I didn't notice the arg2.
Anyway, I was referring to where the function is being called from.
Fix arg2 by declaring it.
local arg1, arg2 = ... will do.
Since that's the only code you posted, I'm going to assume that you know how to fix everything else that's related.