View Single Post
Unread 03-23-12, 01:50 AM   #10
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,746
There was a missing parenthesis. Here is a corrected version:
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)
	if msg == "" then
		return print("|cffffff00Usage:|r /rinv |cff66ffff10|r |cffff99ffRaid invites coming in 10 seconds!|r")
	end

	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
As I'm not in a guild, I can't completely test it, but the slash command with no arguments outputs the help line as expected, and there are no syntax errors.

Also, for future reference, when testing code, or trying to figure out why an addon isn't working right, you should install BugSack or a similar error catching tool so you can see any Lua errors that are occurring. Just enabling Lua errors in the Blizzard interface options isn't enough, because that won't show you errors that occur during the initial loading sequence (like those caused by missing parentheses).
Phanx is offline   Reply With Quote