WoW:API UnitIsSameServer and WoW:API GetGuildRosterContribution: Difference between pages

From AddOn Studio
(Difference between pages)
Jump to navigation Jump to search
(Created page with "  {{wowapi}} <!-- List return values and arguments as well as function name, follow Blizzard usage convention for args --> UnitIsSameServer(UnitId, UnitId) Determines if the …")
 
(update info for 4.0.3a)
 
Line 1: Line 1:
 
{{wowapi}} __NOTOC__
{{wowapi}}
Retrieves the Guild XP and Guild XP Rank information of the unit.
<!-- List return values and arguments as well as function name, follow Blizzard usage convention for args -->


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


Determines if the two units supplied are from the same server.  It is important to note that it returns nil rather than false, nil is treated like false for most operations but it is *not* a proper boolean.
== Arguments ==
----
;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).
;''Arguments''


:''[[API_TYPE_UnitId|UnitId]]''
== Returns ==
;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).


----
== Example ==
;''Returns''
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.


:''True/nil''
Using the above sample guild rosters, this code
 
local totalMembers, onlineMembers = GetNumGuildMembers();
----
local visibleMembers = onlineMembers;
;''Example''
if ( GetGuildRosterShowOffline() ) then
<!-- List return values and arguments as well as function name, follow Blizzard usage convention for args -->
  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)


if (UnitIsSameServer(UnitId, "player")) then
== Details ==
    --Unit is from the same server as the player
<!-- I hope this is clear enough. -->
  else
* When {{api|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).
    --Unit is from a different server
: 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:
  end
  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.

Revision as of 21:50, 17 January 2011

WoW API < GetGuildRosterContribution

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

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

Arguments

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).

Returns

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).

Example

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)

Details

  • 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.