View Single Post
03-12-12, 05:44 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
This modification of Ketho's code should handle party-to-raid conversions. If you're already in a party when the mass invites go out, it will convert the party to a raid. If you're not in a party yet, it will wait until someone accepts the invite, and then convert the party to a raid.

I also added the ability to configure the delay time in the slash command:

Code:
/rinv 15 Raid invites coming in 15 seconds!
If you don't specify a number, it will default to 10 seconds.

Code:
local WAIT_TIME = 10

local f = CreateFrame("Frame")
f:Hide()

f:SetScript("OnEvent", function(self, event)
	if GetNumRaidMembers() > 0 then
		self:UnregisterAllEvents()
	elseif GetNumPartyMembers() > 0 then
		ConvertToRaid()
	end
end)

local delay = 0
f:SetScript("OnUpdate", function(self, elapsed)
	delay = delay + elapsed
	if delay < WAIT_TIME then
		return
	end

	if GetNumRaidMembers() == 0 then
		self:RegisterEvent("RAID_ROSTER_UPDATE")
		if GetNumPartyMembers() == 0 then
			self:RegisterEvent("PARTY_MEMBERS_CHANGED")
		else
			ConvertToRaid()
		end
	end

	for i = 1, GetNumGuildMembers() do
		local name, _, _, level, _, _, _, _, online = GetGuildRosterInfo(i)
		if online and (level >= 70 and level <= 80) then
			InviteUnit(name)
		end
	end
	delay = 0
	self:Hide()
end

SLASH_RAIDINVITE1 = "/rinv"
SLASH_RAIDINVITE2 = "/raidinvite"

SlashCmdList["RAIDINVITE"] = function(msg, editbox)
	local wait, text = msg:trim():match("^(%d+) (.+)$")

	wait = tonumber(wait)
	if wait and wait > 0 then
		WAIT_TIME = wait
	else
		WAIT_TIME = 10
	end

	SendChatMessage(text or msg, "GUILD")
	f:Show()
end

Last edited by Phanx : 03-12-12 at 05:50 PM.
  Reply With Quote