Code:
-- Author: Land
local AnnouncerSpeaks = ""
local frame = CreateFrame("Frame")
local msgType = {
["pvp"] = "BATTLEGROUND",
["arena"] = "PARTY",
["party"] = "PARTY",
["raid"] = "RAID",
}
local antispam = {}
function AnnouncerChatter()
local inGroup = IsInGroup()
local IsRaid = IsInRaid()
local inInstance, instanceType = IsInInstance()
local AnnouncerType = ""
if AnnouncerSay==true then
AnnouncerType = "SAY"
elseif IsInGroup(LE_PARTY_CATEGORY_INSTANCE) then
AnnouncerType = "INSTANCE_CHAT"
elseif IsInRaid() then
AnnouncerType = "RAID"
elseif IsInGroup(LE_PARTY_CATEGORY_HOME) then
AnnouncerType = msgType[instanceType]
end
if (AnnouncerRW == true and (UnitIsGroupAssistant("player") or UnitIsGroupLeader("player")) and AnnouncerType=="RAID") then
AnnouncerType = "RAID_WARNING"
end
SendChatMessage(AnnouncerSpeaks, AnnouncerType)
end
local function handler (msg)
if msg == '' then
AnnouncerHelp()
elseif msg == 'on' then
Announcer = true
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
print("Announcer is currently: "..getStatus(Announcer))
elseif msg == 'off' then
Announcer = false
frame:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
print("Announcer is currently: "..getStatus(Announcer))
elseif msg == 'say' then
AnnouncerSay = true
print("Announcer is announcing on "..CheckStatus().." .")
elseif msg == 'rw' then
AnnouncerRW = not AnnouncerRW
print("Announcer is announcing on raid warning when it can.")
elseif msg == 'group' then
AnnouncerSay = false
print("Announcer is announcing on "..CheckStatus().." .")
elseif msg == 'status' then
print("Announcer is currently: "..getStatus(Announcer))
print("Announcer is announcing to: "..CheckStatus())
end
end
SlashCmdList["Announcer"] = handler;
SLASH_Announcer1 = "/Announcer"
function AnnouncerHelp()
print("Announcer is currently: "..getStatus(Announcer))
print("To check the status of Announcer: /Announcer status")
print("To turn on Announcer: /Announcer on")
print("To turn off Announcer: /Announcer off")
print("To announce in /say: /Announcer say")
print("To announce in /party: /Announcer group")
print("To announce in /raidwarning: /Announcer rw")
end
function getStatus(cond)
if cond==true then
return "|cffff0000Speaking|r"
else
return "|cffff0000Silent|r"
end
end
function CheckStatus()
if AnnouncerRW == true then
return "|cffff0000Raid Warnings if Lead/Assist|r"
elseif AnnouncerSay == false then
return "|cffff0000Group|r"
end
return "|cffff0000Says|r"
end
local AnnouncerPortals = {
[11419] = true, -- Portal: Darnassus
[32266] = true, -- Portal: Exodar
[11416] = true, -- Portal: Ironforge
[11417] = true, -- Portal: Orgrimmar
[32267] = true, -- Portal: Silvermoon
[10059] = true, -- Portal: Stormwind
[49360] = true, -- Portal: Theramore
[11420] = true, -- Portal: Thunder Bluff
[11418] = true, -- Portal: Undercity
[49361] = true, -- Portal: Stonard
[120146] = true, -- Ancient Portal: Dalaran
[53142] = true, -- Portal: Dalaran - Northrend
[224871] = true, -- Portal: Dalaran - Broken Isles
[88345] = true, -- Portal: Tol Barad
[88346] = true, -- Portal: Tol Barad
[132620] = true, -- Portal: Vale of Eternal Blossoms
[132626] = true, -- Portal: Vale of Eternal Blossoms
[33691] = true, -- Portal: Shattrath
[35717] = true, -- Portal: Shattrath
[176244] = true, -- Portal: Warspear
[176246] = true, -- Portal: Stormshield
}
local AnnouncerBCConsumables = {
[57426] = true, -- Fish Feast
[58465] = true, -- Gigantic Feast
[57301] = true, -- Great Feast
[58474] = true, -- Small Feast
}
local AnnouncerCataConsumables = {
[92649] = true, -- Cauldron of Battle
[92712] = true, -- Big Cauldron of Battle
[87915] = true, -- Goblin BBQ
[87643] = true, -- Broiled Dragon Feast
[87644] = true, -- Seafood Magnifique Feast
}
local AnnouncerPandaConsumables = {
[105193] = true, -- Great Pandaren Banquet
[104958] = true, -- Pandaren Banquet
[145166] = true, -- Noodle Cart
[145169] = true, -- Deluxe Noodle Cart
[145196] = true, -- Pandaren Treasure Noodle Cart
[126495] = true, -- Banquet of the Wok
[126496] = true, -- Great Banquet of the Wok
[126499] = true, -- Banquet of the Steamer
[126500] = true, -- Great Banquet of the Steamer
[126497] = true, -- Banquet of the Pot
[126498] = true, -- Great Banquet of the Pot
[126501] = true, -- Banquet of the Oven
[126502] = true, -- Great Banquet of the Oven
[126492] = true, -- Banquet of the Grill
[126494] = true, -- Great Banquet of the Grill
[126503] = true, -- Banquet of the Brew
[126504] = true, -- Great Banquet of the Brew
}
local AnnouncerDraenorConsumables = {
[185706] = true, -- Fancy Darkmoon Feast
[160740] = true, -- Feast of Blood
[160914] = true, -- Feast of the Waters
[175215] = true, -- Savage Feast
[185709] = true, -- Sugar-Crusted Fish Feast
}
local AnnouncerLegionConsumables = {
[226241] = true, -- Codex of the Tranquil Mind
[201351] = true, -- Hearty Feast
[201352] = true, -- Lavish Suramar Feast
[188036] = true, -- Spirit Cauldron
}
local AnnouncerClassConsumables = {
[190336] = true, -- Conjure Refreshment (Mage)
[29893] = true, -- Create Soulwell (Warlock)
[83958] = true, -- Mobile Banking (All)
[698] = true, -- Ritual of Summoning (Warlock)
}
local AnnouncerEngineering = {
[54711] = true, -- Scrapbot
[22700] = true, -- Field Repair Bot 74A
[44389] = true, -- Field Repair Bot 110G
[67826] = true, -- Jeeves
[54710] = true, -- MOLL-E aka Mailbox
[157066] = true, -- Walter
[126459] = true, -- Blingtron 4000
[161414] = true, -- Blingtron 5000
[200217] = true, -- Blingtron 6000
[126462] = true, -- Thermal Anvil
[199109] = true, -- Auto-hammer
[199115] = true, -- Failure Detection Pylon
[200061] = true, -- Summon Reaves
[200204] = true, -- Reaves Auto-hammer
}
local AnnouncerMassRes = {
[212040] = true, -- Druid Revitalize
[212051] = true, -- Monk Reawaken
[212056] = true, -- Pally Absolution
[212036] = true, -- Priest Mass Res
[212048] = true, -- Shaman Ancestral Vision
}
frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("PLAYER_LOGIN")
frame:SetScript("OnEvent", function(self, event, ...)
if event == "ADDON_LOADED" then
if Announcer == nil then
Announcer = true
end
if AnnouncerSay == nil then
AnnouncerSay = false
end
if AnnouncerRW == nil then
AnnouncerRW = false
end
if Announcer == true then
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
else
frame:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
end
else
local _, event, _, _, sourceName, _, _, _, _, _, _, spellID, spellName = ...
if (Announcer == true and (UnitInParty(sourceName) or UnitInRaid(sourceName)) and (event=="SPELL_CAST_SUCCESS" or event=="SPELL_CAST_START")
and GetNumGroupMembers()>0 and (AnnouncerPortals[spellID] or AnnouncerBCConsumables[spellID] or AnnouncerCataConsumables[spellID] or
AnnouncerPandaConsumables[spellID] or AnnouncerDraenorConsumables[spellID] or AnnouncerLegionConsumables[spellID] or
AnnouncerClassConsumables[spellID] or AnnouncerEngineering or AnnouncerMassRes[spellID]
)) then
if AnnouncerPortals[spellID] then
AnnouncerSpeaks = "> "..sourceName.." set up a "..GetSpellLink(spellID).." <"
end
if AnnouncerBCConsumables[spellID] then
AnnouncerSpeaks = "> "..sourceName.." has created a "..GetSpellLink(spellID).." <"
end
if AnnouncerCataConsumables[spellID] then
AnnouncerSpeaks = "> "..sourceName.." has created a "..GetSpellLink(spellID).." <"
end
if AnnouncerPandaConsumables[spellID] then
AnnouncerSpeaks = "> "..sourceName.." has created a "..GetSpellLink(spellID).." <"
end
if AnnouncerDraenorConsumables[spellID] then
AnnouncerSpeaks = "> "..sourceName.." has created a "..GetSpellLink(spellID).." <"
end
if AnnouncerLegionConsumables[spellID] then
AnnouncerSpeaks = "> "..sourceName.." has created a "..GetSpellLink(spellID).." <"
end
if AnnouncerClassConsumables[spellID] then
AnnouncerSpeaks = "> "..sourceName.." is casting "..GetSpellLink(spellID).." <"
end
if AnnouncerEngineering[spellID] then
AnnouncerSpeaks = "> "..sourceName.." has created a "..GetSpellLink(spellID).." <"
end
if AnnouncerMassRes[spellID] then
AnnouncerSpeaks = "> "..sourceName.." is casting "..GetSpellLink(spellID).." <"
end
if (antispam[AnnouncerSpeaks]==nil) then
antispam[AnnouncerSpeaks] = time()
AnnouncerChatter(AnnouncerSpeaks)
elseif (time()-antispam[AnnouncerSpeaks])>12 then
antispam[AnnouncerSpeaks] = time()
AnnouncerChatter(AnnouncerSpeaks)
end
end
end
end)
Any help would be appreciated. It's probably a simple fix, but i'm not sure what the problem is.