View Single Post
08-16-10, 02:24 PM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,331
When dealing with StaticPopupFrame, it's best to hook into the event that calls it so it'll reliably run AFTER the code that shows the popup. In this case, UIParent processes the event, so that's the frame we want to hook.

lua Code:
  1. UIParent:HookScript("OnEvent",function(self,event,...)
  2.     if event=="PARTY_INVITE_REQUEST" then
  3.         ShowFriends()-- Update friends list
  4.         for i=1,GetNumFriends() do
  5.             if (GetFriendInfo(i))==(...) then
  6.                 AcceptGroup();--        Accept invite
  7.                 StaticPopup_Hide("PARTY_INVITE",(...));--   Hide popup
  8.                 break;--    Stop scanning (we're done here)
  9.             end
  10.         end
  11.     end
  12. end);

Note: the only extra arg passed to the function is the name of the player inviting you. This is initially passed to StaticPopup_Show(), which assigns it as the popup's ID. You'll need to pass it to StaticPopup_Hide() hide the frame.
__________________
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 : 08-16-10 at 02:29 PM.
  Reply With Quote