Originally Posted by p3lim
That is very odd, been using my method for auto-accepting group invites from people in my guild, and it has never failed.
|
Originally Posted by Haleth
I use that method, however it fails if it is used shortly after login.
|
I honestly hook into UIParent's OnEvent script handler for the event since it's the one that ends up calling
StaticPopup_Show() for a lot of similar events. The following code should cover both normal and LFG invites.
Lua Code:
UIParent:HookScript("OnEvent",function(self,event,sender)
if event=="PARTY_INVITE_REQUEST" then
DeclineGroup();
StaticPopup_Hide("PARTY_INVITE");
StaticPopupSpecial_Hide(LFGInvitePopup);
SendChatMessage("Party invite auto-declined.","WHISPER",nil,sender);
end
end
WoW handles dispatching events to registered frames by random order. Simply creating a frame and registering an event does not guarantee the order in which it receives its event in respect to other frames already registered for it. This is why a hook is required to reliably run this kind of code. UIParent receives the event and calls
StaticPopup_Show(). As such, you either have to hook its OnEvent script or the
StaticPopup_Show() call.