Originally Posted by Ketho
Another solution is to register for CHAT_MSG_SYSTEM and look for this GlobalString
Code:
LEFT_PARTY = "%s leaves the party."
Although I don't know myself how exactly it should be done with format or strfind, I still don't understand that part
|
I've worked on this kind of function a few times, although during my recent remake of it, I abandoned it during a debug phase. The purpose was to recompile a format string into a pattern string for use with
string.match(). The design of it was to give it the format string and the result string of the format and it would return the argument list, acting in reverse of
string.format().
This function was to make localizations easier by providing a method in which it wasn't necessary to add different patterns for different locales. Also to cut down on CPU load from repetitive use, the function would remember what format strings it had already recompiled. Calling it with the same format string, it would only recompile it once, then just keep returning the same pattern string.
To provide a solution to the OP right now, this should do the trick.
lua Code:
local frame=CreateFrame("Frame");
frame:RegisterEvent("CHAT_MSG_SYSTEM");
frame:SetScript("OnEvent",function(self,event,...)
if event=="CHAT_MSG_SYSTEM" then
local name=(...):match("(.+) leaves the party.");
if name then-- Will be nil for any other message
-- Do stuff here
end
end
end);