PDA

View Full Version : XRI: Ok, tried everything I can think of....


ChaosInc
15-10-2006, 04:11 PM
I've created a filter system to scan the received messages in BG chat and such.

**Code Begin **
local ORIG_ChatFrame_OnEvent = ChatFrame_OnEvent;

function ChatFrame_OnEvent(event)
-if (event == "CHAT_MSG_BATTLEGROUND") or (event == "CHAT_MSG_BATTLEGROUND_LEADER") or (event == "CHAT_MSG_WHISPER") then
--local arg1 = string.lower(arg1);
--local arg2 = string.lower(arg2);
--if (XRI_Debug) then
---DEFAULT_CHAT_FRAME:AddMessage("|cFFFF00FFXRI:|r Event trigged: ".. event);
--end;
--if (XRI_FilterCheck(arg1)) then -- does anything in the message match a filtered word?
---if (XRI_Debug) then
----DEFAULT_CHAT_FRAME:AddMessage("|cFFFF00FFXRI:|r Filter match found, displaying message despite author ignore status.");
---end;
---ORIG_ChatFrame_OnEvent(event);
---return;
--elseif (XRI_IgnoreCheck(arg2)) then -- is the author on the ignored list?
---return;
--end;
-end;
-ORIG_ChatFrame_OnEvent(event);
end;

**Code End**

I'm running into a problem though. It scans the messages and author just fine and takes the appropriate action, but when it's done it fires the same event a second time before it outputs a result, and sometimes prints the message twice. I'm pretty sure it has to to with registering and unregistering the event, but even after looking to wowwiki, I can't seem to get it right (tend to blow up a lot of stuff.)

The filter and ignore list functions are working correctly, so I left them out. If anyone can help with this but needs those, I'll be happy to post it up. I'm about at my wits end having worked on this for 2 days now and can't seem to get it working correctly.

Here's a screenshot of what's happening:
http://www.rucls.net/~chaosinc/wowpics/error.jpg

Sherkhan
16-10-2006, 04:10 PM
I have seen something similar to this. The issue I ran into was that attaching directly to the ChatFrame_OnEvent for message parsing would double or triple, etc... the message (ie: it would get see multiple times). I am not sure why, although I think this event triggers 1x for each chat frame tab that you have.

To properly parse for a message (and only see it 1 time), I had to register my addon frame to the Chat even type I was looking for and then parse it there.

The base ChatFrame_OnEvent is good for hiding the message all together, but does not work well for trying to parse the contents of the message due to the fact that is does get called multiple times for the same chat message.

ChaosInc
16-10-2006, 07:39 PM
I'll post the fix in case anyone else runs into this:

Moved "local ORIG_ChatFrame_OnEvent = ChatFrame_OnEvent;" into the OnLoad function and renamed CF_OE to MyAddOn_CF_OE. Thus, looked like this:

function MyAddon_OnLoad()
-ORIG_ChatFrame_OnEvent = ChatFrame_OnEvent;
-ChatFrame_OnEvent = MyAddOn_ChatFrame_OnEvent;
Whatever else....
end;

function MyAddon_ChatFrame_OnEvent()
Rest stayed the same....
end;

Hope this helps anyone else who's had this problem.