Thread Tools Display Modes
08-19-09, 07:17 PM   #1
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Invite button.

Iam useing the following code for a invite button. What would i have to add to make it so the button hides if the person is already in the party?

Code:
<Button name="$InviteButton" frameStrata="HIGH" hidden="true">
        <!--<FrameSkin skinid="dcb143e1-a4ab-4e7c-b934-1efa40101d21" frameid="2d508884-59c2-4f83-ae10-27aaad48391b" />-->
        <Size>
          <AbsDimension x="15" y="15" />
        </Size>
        <Anchors>
          <Anchor point="CENTER">
            <Offset>
              <AbsDimension x="-25" y="-0" />
            </Offset>
          </Anchor>
        </Anchors>
        <Scripts>
          <OnLoad>self:RegisterEvent("UNIT_TARGET")
self:Hide()</OnLoad>
          <OnEvent>if UnitIsFriend("player","target") and UnitIsPlayer("target") then
self:Show()
else
self:Hide()
end</OnEvent>
        <OnClick>local name = UnitName("target");
        InviteUnit(name)</OnClick>
        </Scripts>
        <NormalTexture file="Interface\AddOns\GrimUIcore\Icons\InviteIcon">
          <TexCoords left="0" right="1" top="0" bottom="1" />
        </NormalTexture>
        <PushedTexture file="Interface\AddOns\GrimUIcore\Icons\InviteIcon">
          <TexCoords left="0" right="1" top="0" bottom="1" />
        </PushedTexture>
        <DisabledTexture file="Interface\AddOns\GrimUIcore\Icons\InviteIcon">
          <TexCoords left="0" right="1" top="0" bottom="1" />
        </DisabledTexture>
        <HighlightTexture file="Interface\AddOns\GrimUIcore\Icons\InviteIcon" alphaMode="ADD">
          <TexCoords left="0" right="1" top="0" bottom="1" />
        </HighlightTexture>
        <ButtonText name="$parentText">
          <FontHeight>
            <AbsValue val="10" />
          </FontHeight>
        </ButtonText>
        <NormalFont style="GameFontNormal" />
        <HighlightFont style="GameFontHighlight" />
        <DisabledFont style="GameFontDisable" />
      </Button>
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
08-24-09, 06:11 AM   #2
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
Add
Code:
and not UnitInParty("target")
to your if-condition and it should work.

P.S: You could change your event to PLAYER_TARGET_CHANGED instead of UNIT_TARGET to reduce updating.
__________________
« Website | GitHub »

Oh hai!

Last edited by xConStruct : 08-24-09 at 06:15 AM.
  Reply With Quote
08-24-09, 10:58 AM   #3
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
That line worked perfectly even made it so that it hides the button if i target myself which was my next task.

So is it possible to make it so that when you have someone targeted and you invite them to group the invite button hides when they join? so i dont have to untarget and retarget to get it to hide?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
08-24-09, 11:02 AM   #4
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
Just do a re-check on PARTY_MEMBERS_CHANGED.
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote
08-24-09, 11:52 AM   #5
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
hmm wouldn't that require another event register? can it be done like this?


Scripts>
<OnLoad>self:RegisterEvent("UNIT_TARGET","PARTY_MEMBERS_CHANGED")
self:Hide()</OnLoad>
<OnEvent>if UnitIsFriend("player","target") and UnitIsPlayer("target") and not UnitInParty("target") then
self:Show()
else
self:Hide()
end</OnEvent>
<OnClick>local name = UnitName("target");
InviteUnit(name)</OnClick>
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
08-24-09, 11:54 AM   #6
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
as far as the UNIT_TARGET change wouldnt the way you mentioned only update when the target changes? the way i have it should change every time you click a target change or not? or em i confused?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
08-24-09, 12:02 PM   #7
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
UNIT_TARGET fires if the target of the player, party-members, focus, pet, raid-members and so on changes.
PLAYER_TARGET_CHANGED only fires for the player.

And you need a new call to RegisterEvent() for each new event.
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote
08-24-09, 12:20 PM   #8
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
alright, so it could look like this?

<OnLoad>self:RegisterEvent("PLAYER_TARGET_CHANGED") self:RegisterEvent("PARTY_MEMBERS_CHANGED")
self:Hide()</OnLoad>
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
08-24-09, 12:25 PM   #9
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
Yep, this should be working.
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote
08-24-09, 02:14 PM   #10
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
works perfect.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Invite button.


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