Thread Tools Display Modes
Prev Previous Post   Next Post Next
09-19-15, 06:06 AM   #1
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
Addon help

So here's a tiny module i recently added in my UI. Basically what it does amongst other things is, whenever i target one of those new rares in Tanaan jungle, it lists a custom group and when the rare is dead, it disbands the raid.

It's working just fine exept that, every time it disbands the raid, it also throws an error and i don't understand why. I even added a 5 seconds delay thinking it was doing it too fast after PLAYER_REGEN_ENABLED but that didn't help.

Anyway, here's the code and the error below it:

Code:
caelUI.rares:SetScript("OnEvent", function(self, event, addon, arg)
	if event == "CHAT_MSG_MONSTER_YELL" and (arg == "Frogan" or arg == "Tyrant Velhari" or arg == "Shadow-Lord Iskar" or arg == "Siegemaster Mar\'tak") and not IsInRaid() then
		self:RegisterEvent("PLAYER_TARGET_CHANGED")
	end

	if event == "PLAYER_TARGET_CHANGED" then
		if UnitName("target") == "Terrorfist" or UnitName("target") == "Vengeance" or UnitName("target") == "Deathtalon" or UnitName("target") == "Doomroller" then

			self:RegisterEvent("PLAYER_REGEN_ENABLED")
			self:UnregisterEvent("PLAYER_TARGET_CHANGED")
--			C_LFGList.CreateListing(Category ID, "groupName", itemLevel, "voiceChat", "comment", autoAccept)
			C_LFGList.CreateListing(16, UnitName("target"), 685, " ", "Join quick !", true)

			C_Timer.After(5, function()
				if not IsInRaid() then
					print("Converting to raid")
					ConvertToRaid()
				end
			end)

			C_Timer.After(120, function()
				print("Delisting group")
				C_LFGList.RemoveListing()
			end)
		end
	end

	if event == "PLAYER_REGEN_ENABLED" then
		C_Timer.After(5, function()
			if IsInRaid() then
				SendChatMessage("Target is dead, disbanding raid.", "RAID")
				for i = 1, GetNumGroupMembers() do
					local name, _, _, _, _, _, _, online = GetRaidRosterInfo(i)
					if online and name ~= caelUI.playerName then
						UninviteUnit(name)
					end
				end
			else
				SendChatMessage("Target is dead, disbanding group.", "PARTY")
				for i = MAX_PARTY_MEMBERS, 1, -1 do
					if GetPartyMember(i) then
						UninviteUnit(UnitName("party"..i))
					end
				end
			end
			LeaveParty()
			self:UnregisterEvent("PLAYER_REGEN_ENABLED")
		end)
	end
end)

Code:
ID: 1
Error occured in: Unnamed
Message:
caelUI attempted to call a protected function (UninviteUnit()) which may require interaction.
Debug:
   [C]: UninviteUnit()
   ...erface\AddOns\caelUI\modules\announcements\rares.lua:77:
      ...erface\AddOns\caelUI\modules\announcements\rares.lua:71
locals:
nil
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Addon help

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off