WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Displaying group number when in raid on pitbull (https://www.wowinterface.com/forums/showthread.php?t=34255)

linguini 07-30-10 01:01 AM

Displaying group number when in raid on pitbull
 
trying to display my group number when im in a raid in lua texts!! :banana:

Krahg 07-30-10 01:34 AM

Your question is a little unclear, if this doesn't cover it, could you be a bit more specific?

I looked for a pre-made API for this, but didn't find one so this should do it.

Code:

function GetSubGroupID()
        if not UnitInRaid("PLAYER") then return
        for i = 1 , GetNumRaidMembers() do
                name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(i)
                if ( name == UnitName("PLAYER") ) then
                        return subgroup
                end
        end
end


linguini 07-30-10 12:19 PM

basically i just want to display my group number when im in a raid.
if im in group #3, it will display "3"
if im in group #4, it will display "4"
if im not in a raid group at all, it wont display anything

Krahg 08-01-10 03:10 AM

The function I posted should do that. Didn't it work for you? How do you want it displayed? You could try:

/run print(GetSubGroupID())

ravagernl 08-01-10 05:27 AM

See this page for some usefull info about lua texts: http://www.wowace.com/addons/pitbull4/pages/lua-texts/

This, along with PARTY_MEMBERS_CHANGED as event might be all that is needed.
Code:

if not UnitInRaid("player") then return
local myname = UnitName('player')
for i = 1 , GetNumRaidMembers() do
        local name = GetRaidRosterInfo(i)
        if ( name == myname ) then
                return subgroup
        end
end


linguini 08-01-10 10:37 PM

WOW i completely skipped over mrruben5's post. -_-

queep 10-16-10 08:24 AM

*bump*

Does this work with pitbull 4 ? I can't find the event PARTY_MEMBER_CHANGED.

Seerah 10-16-10 12:10 PM

This thread was about PitBull4 to begin with. ;)

Issa 11-07-10 08:31 AM

If you want to display the group number for every raid member, you can use this code:
Code:

if not UnitInRaid("PLAYER") then return end
for i = 1 , GetNumRaidMembers() do
    name, _, subgroup = GetRaidRosterInfo(i)
    if (name == Name(unit)) then
        return subgroup
    end
end

combined with the created event PARTY_MEMBERS_CHANGED that mrruben5 mentioned.

SkOODaT 06-13-11 07:59 PM

Code:

UpdateIn(0.25)
if not UnitInRaid("PLAYER") then return; end
    for i = 1 , GetNumRaidMembers() do
        name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(i)
        if ( name == UnitName("PLAYER") ) then
            return "Group " ..subgroup
        end
end


Enjoy All

BromFairain 02-04-12 01:17 PM

I was just researching this event and was glad to find this thread.
Thanks for all the code, but the Event PARTY_MEMBERS_CHANGED is not showing in the selector box.
This is in PitBull -> Layout -> Texts.
I find plenty of UNIT events in the list but not the above mentioned one. The event itself is in the LuaTexts.lua file in the PitBull4_LuaText folder.

Any pointer is appreciated

Phanx 02-06-12 08:13 AM

You should really use the local keyword when defining variables. Otherwise you're putting crap into the global namespace with generic names like "name" and "class".

Bad:
Code:

name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(i)
Good:
Code:

local name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(i)
This limits those variables to the scope in which they are defined, which is the only place they are needed. It also causes them to be garbage-collected after they go out of scope, instead of lying around forever.

Phanx 02-06-12 08:14 AM

Quote:

Originally Posted by BromFairain (Post 252101)
... the Event PARTY_MEMBERS_CHANGED is not showing in the selector box. ...

I'm not specifically familiar with PitBull4, but if there is a limited list of events you can choose from, then you will probably need to ask the PitBull4 developers to add PARTY_MEMBERS_CHANGED to that list, or modify the addon's code to add it to the list yourself.

Annekynn 09-30-12 06:49 PM

Sorry to resurrect an old thread but this code has ceased working due to changes in 5.x , specifically this bit:

Quote:

if not UnitInRaid("PLAYER") then return end
for i = 1 , GetNumRaidMembers() do
name, _, subgroup = GetRaidRosterInfo(i)
if (name == Name(unit)) then
return subgroup
end
end
Can any of you smart folks fix that so it works?

Dridzt 09-30-12 07:08 PM

Quote:

Originally Posted by Annekynn (Post 265461)
Sorry to resurrect an old thread but this code has ceased working due to changes in 5.x , specifically this bit:



Can any of you smart folks fix that so it works?

Code:

for i = 1 , GetNumGroupMembers() do
  local name, _, subgroup = GetRaidRosterInfo(i)
  if (name == Name(unit)) then
    return subgroup
  end
end

should be sufficient

Edit:
Ah, if there's any PARTY_MEMBERS_CHANGED, RAID_ROSTER_UPDATE events they should both be replaced with GROUP_ROSTER_UPDATE.

Annekynn 09-30-12 08:55 PM

Quote:

Originally Posted by Dridzt (Post 265462)
Code:

for i = 1 , GetNumGroupMembers() do
  local name, _, subgroup = GetRaidRosterInfo(i)
  if (name == Name(unit)) then
    return subgroup
  end
end

should be sufficient

Edit:
Ah, if there's any PARTY_MEMBERS_CHANGED, RAID_ROSTER_UPDATE events they should both be replaced with GROUP_ROSTER_UPDATE.

The group number always says 1, even when I moved people around. I have no option for GROUP_ROSTER_UPDATE , im assuming thats why its not updating. And my original code actually looked like this to display number and name (so I just updated it to say GetNumGroupMembers as you suggested):

Code:

for i = 1, GetNumGroupMembers() do
  if UnitIsUnit("raid"..i,unit) then
    local name, rank, subgroup = GetRaidRosterInfo(i)
    if name then return "%d %s", subgroup, name end
  end
end



All times are GMT -6. The time now is 07:06 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI