WoW API: GetGuildRosterContribution

WoW API < GetGuildRosterContribution

Retrieves the Guild XP and Guild XP Rank information of the unit.

weeklyXP, totalXP, weeklyRank, totalRank = GetGuildRosterContribution(index)

ArgumentsEdit

index
Integer - Index of guild member in the guild roster, where index is greater than 0 and less than or equal to total member count. (Note that sorting re-orders the roster, indexes are not guaranteed to remain stable across events).

ReturnsEdit

weeklyXP
Number - The amount of Guild XP contributed by the member this week (0 < weeklyXP <= 1575002).
totalXP
Number - The total amount of Guild XP contributed by the member.
weeklyRank
Number - The rank of the member for the week.
totalRank
Number - The rank of the member for total contribution (since the introduction of "contribution" or the formation of the guild, whichever comes after).

ExampleEdit

Fig 1.1                                Fig 1.2
+--------+-------+--------+-----------+    +--------+-------+--------+-----------+
| Status | Name  | Weekly |   Total   |    | Status | Name  | Weekly |   Total   |
|--------+-------+--------+-----------|    |--------+-------+--------+-----------|
| Off    | Alpha | #4  10 | #1  42000 |    | On     | Gamma | #2  30 | #3  20000 |
| Off    | Beta  | #3  20 | #2  30000 |    | Off    | Alpha | #4  10 | #1  42000 |
| On     | Gamma | #2  30 | #3  20000 |    | Off    | Beta  | #3  20 | #2  30000 |
| Off    | Delta | #1  42 | #4  13373 |    | Off    | Delta | #1  42 | #4  13373 |
+--------+-------+--------+-----------+    +--------+-------+--------+-----------+
| [x]Show Offline Members         1/4 |    | [ ]Show Offline Members         1/4 |
+-------------------------------------+    +-------------------------------------+

  Note: In fig 1.2, 'show offline members' is disabled so only Gamma
        will be visible in the Guild UI, but for ease of explanation,
        the others are listed.

Using the above sample guild rosters, this code

local totalMembers, onlineMembers = GetNumGuildMembers();
local visibleMembers = onlineMembers; 
if ( GetGuildRosterShowOffline() ) then
 visibleMembers = totalMembers;
end
for index=1, visibleMembers do
 local weeklyXP, totalXP, weeklyRank, totalRank = GetGuildRosterContribution(index);
 DEFAULT_CHAT_FRAME:AddMessage('g'..index..' weeklyXP: '..weeklyXP..' (#'..weeklyRank..'), totalXP: '..totalXP..' (#'..totalRank..')');
end

would output for fig 1.1

g1 weeklyXP: 10 (#4), totalXP: 42000 (#1)
g2 weeklyXP: 20 (#3), totalXP: 30000 (#2)
g3 weeklyXP: 30 (#2), totalXP: 20000 (#3)
g4 weeklyXP: 42 (#1), totalXP: 13373 (#4)

and for fig 1.2

g1 weeklyXP: 30 (#2), totalXP: 20000 (#3)

Note that if we allowed the index to include offline members for fig 1.2, the output would be:

g1 weeklyXP: 30 (#2), totalXP: 20000 (#3)
g2 weeklyXP: 10 (#4), totalXP: 42000 (#1)
g3 weeklyXP: 20 (#3), totalXP: 30000 (#2)
g4 weeklyXP: 42 (#1), totalXP: 13373 (#4)

DetailsEdit

  • When GetGuildRosterShowOffline is false, the logical roster is always sorted by status first (i.e. online before offline) and then by the current sorting (for level, class, name, activity), and thus indices greater than online count (i.e., onlineMembers < index <= totalMembers) will point to the offline member. When GetGuildRosterShowOffline is true, the logical roster is sorted by the current sorting (for level, class, name, activity).
To illustrate with name sorting, an index of 5 (in a guild of 2 online and 5 offline) will point to the 3rd offline member ('d' in this case) when offline is hidden:
 1   2   3   4  (5)  6   7  -- Index
 b   e  [a] [c] [d] [f] [g] -- Bracket indicating offline.
and the 2nd online member ('e' in this case) when offline is shown:
 1   2   3   4  (5)  6   7  -- Index
[a]  b  [c] [d]  e  [f] [g] -- Bracket indicating offline.