So i have some functions like thoose:
Code:
function PVPSound:RegisterAllEvent()
PVPSoundFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
PVPSoundFrame:RegisterEvent("ZONE_CHANGED_NEW_AREA")
PVPSoundFrame:RegisterEvent("PLAYER_DEAD")
PVPSoundFrame:RegisterEvent("CHAT_MSG_BG_SYSTEM_NEUTRAL")
PVPSoundFrame:RegisterEvent("CHAT_MSG_BG_SYSTEM_ALLIANCE")
PVPSoundFrame:RegisterEvent("CHAT_MSG_BG_SYSTEM_HORDE")
PVPSoundFrame:RegisterEvent("CHAT_MSG_MONSTER_YELL")
PVPSoundFrame:RegisterEvent("CHAT_MSG_RAID_BOSS_EMOTE")
PVPSoundFrame:RegisterEvent("WORLD_MAP_UPDATE")
PVPSoundFrameTwo:RegisterEvent("UPDATE_WORLD_STATES")
PVPSoundFrameThree:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
end
function PVPSound:UnregisterAllEvents()
PVPSoundFrame:UnregisterEvent("PLAYER_ENTERING_WORLD")
PVPSoundFrame:UnregisterEvent("ZONE_CHANGED_NEW_AREA")
PVPSoundFrame:UnregisterEvent("PLAYER_DEAD")
PVPSoundFrame:UnregisterEvent("CHAT_MSG_BG_SYSTEM_NEUTRAL")
PVPSoundFrame:UnregisterEvent("CHAT_MSG_BG_SYSTEM_ALLIANCE")
PVPSoundFrame:UnregisterEvent("CHAT_MSG_BG_SYSTEM_HORDE")
PVPSoundFrame:UnregisterEvent("CHAT_MSG_MONSTER_YELL")
PVPSoundFrame:UnregisterEvent("CHAT_MSG_RAID_BOSS_EMOTE")
PVPSoundFrame:UnregisterEvent("WORLD_MAP_UPDATE")
PVPSoundFrameTwo:UnregisterEvent("UPDATE_WORLD_STATES")
PVPSoundFrameThree:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
end
And a toggle button like that:
Code:
function PVPSound:OptionsEnableAddonButtonToggle(self)
if self:GetChecked() then
PS_EnableAddon = true
PVPSound:RegisterAllEvent()
PVPSoundKillSoundButton:Enable()
PVPSoundKillSoundButtonText:SetTextColor(1, 1, 1)
PVPSoundMultiKillSoundButton:Enable()
PVPSoundMultiKillSoundButtonText:SetTextColor(1, 1, 1)
UIDropDownMenu_EnableDropDown(PVPSoundSoundPackDropDown)
UIDropDownMenu_EnableDropDown(PVPSoundSoundPackLanguageDropDown)
UIDropDownMenu_EnableDropDown(PVPSoundSoundChannelDropDown)
else
PS_EnableAddon = false
PVPSound:UnregisterAllEvents()
PVPSoundKillSoundButton:Disable()
PVPSoundKillSoundButtonText:SetTextColor(0.5, 0.5, 0.5)
PVPSoundMultiKillSoundButton:Disable()
PVPSoundMultiKillSoundButtonText:SetTextColor(0.5, 0.5, 0.5)
UIDropDownMenu_DisableDropDown(PVPSoundSoundPackDropDown)
UIDropDownMenu_DisableDropDown(PVPSoundSoundPackLanguageDropDown)
UIDropDownMenu_DisableDropDown(PVPSoundSoundChannelDropDown)
end
--print(PS_EnableAddon)
end
All working fine, but every time i unregister "CHAT_MSG_BG_SYSTEM_ALLIANCE" or "CHAT_MSG_BG_SYSTEM_HORDE" then the eventhandler brokes, and doesnt register thoose events (Unless i "/reload" with checked enable button.):
Code:
local PVPSoundFrame = CreateFrame("Frame", "PVPSoundFrame")
PVPSoundFrame:RegisterEvent("ADDON_LOADED")
function PVPSound:OnLoad()
if PS_EnableAddon == true then
PVPSoundFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
PVPSoundFrame:RegisterEvent("ZONE_CHANGED_NEW_AREA")
PVPSoundFrame:RegisterEvent("PLAYER_DEAD")
PVPSoundFrame:RegisterEvent("CHAT_MSG_BG_SYSTEM_NEUTRAL")
PVPSoundFrame:RegisterEvent("CHAT_MSG_BG_SYSTEM_ALLIANCE")
PVPSoundFrame:RegisterEvent("CHAT_MSG_BG_SYSTEM_HORDE")
PVPSoundFrame:RegisterEvent("CHAT_MSG_MONSTER_YELL")
PVPSoundFrame:RegisterEvent("CHAT_MSG_RAID_BOSS_EMOTE")
PVPSoundFrame:RegisterEvent("WORLD_MAP_UPDATE")
end
end
local PVPSoundFrameTwo = CreateFrame("Frame", "PVPSoundFrameTwo")
function PVPSound:OnLoadTwo()
if PS_EnableAddon == true then
PVPSoundFrameTwo:RegisterEvent("UPDATE_WORLD_STATES")
end
end
local PVPSoundFrameThree = CreateFrame("Frame", "PVPSoundFrameThree")
function PVPSound:OnLoadThree()
if PS_EnableAddon == true then
PVPSoundFrameThree:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
end
end
function PVPSound:OnEvent(event, ...)
if event == "CHAT_MSG_BG_SYSTEM_ALLIANCE" or event == "CHAT_MSG_BG_SYSTEM_HORDE" then
-- DONT RUNS WHEN BUTTON TOGGLED
end
end
PVPSoundFrame:SetScript("OnEvent", PVPSound.OnEvent)
Dont really get whats the problem.