View Single Post
04-17-12, 10:27 PM   #13
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Originally Posted by p3lim View Post
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 View Post
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:
  1. UIParent:HookScript("OnEvent",function(self,event,sender)
  2.     if event=="PARTY_INVITE_REQUEST" then
  3.         DeclineGroup();
  4.         StaticPopup_Hide("PARTY_INVITE");
  5.         StaticPopupSpecial_Hide(LFGInvitePopup);
  6.         SendChatMessage("Party invite auto-declined.","WHISPER",nil,sender);
  7.     end
  8. 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.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 04-17-12 at 10:44 PM.
  Reply With Quote