Thread Tools Display Modes
02-07-08, 05:43 AM   #1
oXid_FoX
A Deviate Faerie Dragon
 
oXid_FoX's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2007
Posts: 18
Unhappy hide party frame when player join in combat

hello everybody !

I wrote a small addon to hide the party frame.
the whole code:
Code:
function oxPartyFrameHider_OnEvent(this, event)
	if GetNumPartyMembers() > 0 then
		HidePartyFrame()
	end

end

local frame = CreateFrame("Frame","oxPartyFrameHider",UIParent)
frame:SetScript("OnEvent", oxPartyFrameHider_OnEvent)
frame:RegisterEvent("PARTY_MEMBERS_CHANGED")
pretty simple, isn't it ?

but... there is a "bug": when a player join the party when we are in combat, the party frame appears...
the only solution I've found: the PARTY_MEMBERS_CHANGED event must be fired one more time (basically, it means a player must leave/join the party).

how could I fix that ?
thanks for your help, and sorry for my poor english...
  Reply With Quote
02-07-08, 07:09 AM   #2
break19
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 116
This is due to Secure Frames. Certain things cannot be done while in combat.

http://www.wowwiki.com/Secure_Frames_Overview

to read more.
  Reply With Quote
02-07-08, 07:39 AM   #3
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
PartyPooper by Guillotine.
11 lines of code so I won't post it, you can look at it.
(no idea why he hasn't posted it here)

It does exactly that.. who would have thought, 2 addons for hiding party frames

Soon a category.

Just teasing btw...

Last edited by Dridzt : 02-07-08 at 07:43 AM.
  Reply With Quote
02-07-08, 09:11 AM   #4
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
Originally Posted by oXid_FoX View Post
hello everybody !

I wrote a small addon to hide the party frame.
the whole code:
Code:
function oxPartyFrameHider_OnEvent(this, event)
	if GetNumPartyMembers() > 0 then
		HidePartyFrame()
	end

end

local frame = CreateFrame("Frame","oxPartyFrameHider",UIParent)
frame:SetScript("OnEvent", oxPartyFrameHider_OnEvent)
frame:RegisterEvent("PARTY_MEMBERS_CHANGED")
pretty simple, isn't it ?

but... there is a "bug": when a player join the party when we are in combat, the party frame appears...
the only solution I've found: the PARTY_MEMBERS_CHANGED event must be fired one more time (basically, it means a player must leave/join the party).

how could I fix that ?
thanks for your help, and sorry for my poor english...

To fix it use InCombatLockdown() ,

Code:
local frame = CreateFrame("Frame")
frame:RegisterEvent("PARTY_MEMBERS_CHANGED")
frame:SetScript("OnEvent", function(frame) 
   if InCombatLockdown() then
      frame:RegisterEvent("PLAYER_REGEN_ENABLED")
   else frame:UnRegisterEvent("PLAYER_REGEN_ENABLED")
      if GetNumPartyMembers() > 0 then
          HidePartyFrame()
      end
end
or do it how PartyPooper does it.

Last edited by Slakah : 02-09-08 at 10:56 AM.
  Reply With Quote
02-07-08, 05:01 PM   #5
oXid_FoX
A Deviate Faerie Dragon
 
oXid_FoX's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2007
Posts: 18
Originally Posted by Dridzt View Post
PartyPooper by Guillotine.
oops ! I didn't know his addon at all... my bad... if I knew that before writing my own addon...

great thanks, Slakah, I'll try it tomorrow (too tired to do something tonight).
  Reply With Quote
02-09-08, 08:03 AM   #6
oXid_FoX
A Deviate Faerie Dragon
 
oXid_FoX's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2007
Posts: 18
> Slakah

too bad, it doesn't work at all... even when we're not in combat...
and I don't understand how it works... registering PLAYER_REGEN_ENABLED and then ? what it does???
  Reply With Quote
02-09-08, 10:03 AM   #7
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Originally Posted by oXid_FoX View Post
> Slakah

too bad, it doesn't work at all... even when we're not in combat...
and I don't understand how it works... registering PLAYER_REGEN_ENABLED and then ? what it does???
It's incomplete.
As far as I can tell it was not meant to solve your problem with the party frame popping up when someone joins in combat.
It was meant to "solve" the second part:
Originally Posted by oXid_FoX
(basically, it means a player must leave/join the party).
What he meant to do (guessing) is when you process the PARTY_MEMBERS_CHANGED event,
check if the member joined or left in-combat, by checking InCombatLockdown().
If it was in-combat he registers PLAYER_REGEN_ENABLED.
PLAYER_REGEN_ENABLED will fire when you leave combat.

So presumably your
Code:
function oxPartyFrameHider_OnEvent(this, event)
	if GetNumPartyMembers() > 0 then
		HidePartyFrame()
	end
end
will run the HidePartyFrame() code when PLAYER_REGEN_ENABLED event fires thus hiding the party frames again.

What you'd get if this code worked would be the party frames showing when a change to party happens in combat,
but hiding again when combat ends without needing someone to leave/join.

Note: I didn't test any of this in-game, just commenting on the code.
PartyPooper is a more elegant way to do it without all these complications imo.
  Reply With Quote
02-09-08, 10:08 AM   #8
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Code:
function oxPartyFrameHider_OnEvent(this, event)
	if GetNumPartyMembers() > 0 then
		HidePartyFrame()
	end

end

local frame = CreateFrame("Frame","oxPartyFrameHider",UIParent)
frame:SetScript("OnEvent", oxPartyFrameHider_OnEvent)
frame:RegisterEvent("PARTY_MEMBERS_CHANGED")
frame:RegisterEvent("PLAYER_REGEN_ENABLED")
Try this to achieve the same effect without the registering/unregistering in-combat part.

If it works, your frames will re-hide when you exit combat.
  Reply With Quote
02-09-08, 11:08 AM   #9
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
Originally Posted by Dridzt View Post
Code:
function oxPartyFrameHider_OnEvent(this, event)
	if GetNumPartyMembers() > 0 then
		HidePartyFrame()
	end

end

local frame = CreateFrame("Frame","oxPartyFrameHider",UIParent)
frame:SetScript("OnEvent", oxPartyFrameHider_OnEvent)
frame:RegisterEvent("PARTY_MEMBERS_CHANGED")
frame:RegisterEvent("PLAYER_REGEN_ENABLED")
Try this to achieve the same effect without the registering/unregistering in-combat part.

If it works, your frames will re-hide when you exit combat.
Is there any downside to registering and unregistering events on the fly?

Last edited by Slakah : 02-09-08 at 12:02 PM.
  Reply With Quote
02-09-08, 01:09 PM   #10
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
No clue tbh
I just simplified it for oXid_FoX's benefit to illustrate the logic of what you posted for him.
  Reply With Quote
02-10-08, 10:35 AM   #11
oXid_FoX
A Deviate Faerie Dragon
 
oXid_FoX's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2007
Posts: 18
okay ! I love this community... thank you very much for your explanations.
what I didn't understand in the Slakah's code is he remove the registering of PARTY_MEMBERS_CHANGED event. okay, so just a line he forgot?

and I've tested, partypooper works fine... quite strange to do it one by one (each other member), but it works.

nevertheless I'll try this.
  Reply With Quote
02-10-08, 11:19 AM   #12
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
No he didn't forget the line.
He did it so that the OnEvent code doesn't run every time you get out of combat,
but only if PARTY_MEMBERS_CHANGED fired while you where in combat.

So he registers PLAYER_REGEN_ENABLED if party members changed while you were in combat,
and unregisters it (so that your addon doesn't react to it) if the party change happened while you were not in combat.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » hide party frame when player join in combat


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