PDA

View Full Version : An addon to hide a Chat Frame, when we are in raid ?


grievious
14-07-2007, 06:45 PM
Hi,

I would like to make an addon who should be able to hide one chat frame when we are in raid party.

For exemple, I have 2 chat frame, one to the left where i have my "Guild", "party" an "raid" chan and the second chat frame, to the right, where we have the "General", "Cry" and "Said" chan. It's this second chan i'would like to hide when i'm in a raid group.

I've tried to make it alone, but it dosen't work.

This my files :

1st the .TOC file (HicheChat.toc)

## Interface: 20100
## Author: Shamonyou
## Title: HideChat
## Notes: Hide a chat frame in raid
## Version: 0.00.1
## DefaultState: Enabled
## SavedVariables: hidechat

HideChat.lua

2d the .lua file (HideChat.lua)

function AutohideChat_OnLoad()
this:RegisterEvent("RAID_ROSTER_UPDATE");
end

function AutohideChat_OnEvent(event)
if(event=="RAID_ROSTER_UPDATE") then
if ChatFrame3:IsShown() then ChatFrame3:Hide() else ChatFrame3:Show() end
end
end

When i make a simply macro, it works :

/script if ChatFrame1:IsShown() then ChatFrame1:Hide() else ChatFrame1:Show() end

Can you Help me please ?

Jumpy
14-07-2007, 07:06 PM
One difference between your macro and the addon is that the macro only fires once, when you execute it. The RAID_ROSTER_UPDATE fires several times according to WoWWiki.
Fired whenever a raid is formed or disbanded, players are leaving or joining a raid (unsure if rejected join requests also fire the event), or when looting rules are changed (regardless of being in raid or party!)
It might even be fired more often than that, I don't know. ChatFrame1 is flip flopping from shown to hidden and back I am guessing.

Jumpy
14-07-2007, 08:33 PM
Also I am assuming you have an xml file that specifies where to go on an event.

Telic
15-07-2007, 10:56 AM
When the event fires you should do another check like

if ( GetNumRaidMembers() > 0 ) then.....

or

if ( IsInInstance() ) then.....


Or do it from within an OnUpdate that checks every second or two to see if you are in a Raid or not....

grievious
15-07-2007, 01:25 PM
Thks four your help.

I've found a script who works perfectly :

local hiding
local frame = CreateFrame("Frame")
frame:SetScript("OnLoad", function()
ChatFrame3:HookScript("OnShow", function() if hiding then this:Hide() end end)
end)
frame:SetScript("OnEvent", function()
if GetNumRaidMembers() > 0 then
hiding = true
ChatFrame3:Hide()
else
hiding = false
ChatFrame3:Show()
end
end)
frame:RegisterEvent("RAID_ROSTER_UPDATE")