WoWInterface SVN AutoInviteFriends

[/] [trunk/] [AutoInviteFriends.lua] - Rev 3

Compare with Previous | Blame | View Log

-- Version 1.0.1
local frame = CreateFrame("FRAME", "aif_frame");
frame:RegisterEvent("PLAYER_ENTERING_WORLD");
frame:RegisterEvent("FRIENDLIST_UPDATE");
frame:RegisterEvent("PARTY_INVITE_REQUEST");


local function eventHandler(self, event, sender)
        if (event == "PLAYER_ENTERING_WORLD") then
                aif_InviteFriends()
        end
        
        if (event == "FRIENDLIST_UPDATE") then
                aif_InviteFriends()
        end
        
        if (event == "PARTY_INVITE_REQUEST") then
                aif_AcceptInvite(sender)
        end
end

frame:SetScript("OnEvent", eventHandler);


function aif_InviteFriends()
        -- Invite from your friend list who is online at the moment.
        
        for aif_x=1, GetNumFriends() do
                aif_name, aif_level, aif_class, aif_area, aif_connected, aif_status, RAF = GetFriendInfo(aif_x)

                if (aif_connected == 1) then
                        if (UnitInParty(aif_name) ~= 1) then
                                InviteUnit(aif_name)
                                -- Set the loot type to Free for All
                                SetLootMethod("freeforall");
                        end
                end
        end



end



function aif_AcceptInvite(sender)
        
        for aif_x=1, GetNumFriends() do
                aif_name, aif_level, aif_class, aif_area, aif_connected, aif_status, RAF = GetFriendInfo(aif_x)
                if (sender == aif_name) then
                        AcceptGroup()
                        StaticPopup_Hide("PARTY_INVITE");
                end
        end
end

Compare with Previous | Blame