WoW:API GetNumGuildMembers: Difference between revisions

{{wowapi}}, format, example
(Noted that this function is bugged)
({{wowapi}}, format, example)
Line 1: Line 1:
<p>Returns the number of guild members</p>
{{wowapi}} __NOTOC__
<hr />
Returns the number of guild members.
<dl><dt><em>Arguments</em></dt></dl>
numGuildMembers = GetNumGuildMembers([includeOffline]);
<dl><dd>offline - boolean</dd></dl>
<hr />
<dl><dt><em>Returns</em></dt></dl>
<dl><dd>If called with no argument gets number of online guild members. If
offline argument is true get number of all guild members.</dd></dl>
<hr />
<dl><dt><em>Example</em></dt></dl>
<pre>
local numGuildMembers = GetNumGuildMembers();
local numAllGuildMembers = GetNumGuildMembers(true);
</pre>
<hr />
<dl><dt><em>Notes</em></dt></dl>
<dl><dd>This function seems to return 0 if you have not yet opened the guild roster.  I suspect that a call to GuildRoster(), before calling this function will cause it to return the proper result.</dd>
<dd>This function will return a maximum value of 500.</dd></dl>
<hr />
<dl><dt><em>Warnings</em></dt></dl>
<dl><dd>If the character is not part of a guild, but has left (/gquit) one, it will still return the number of members of the guild the character was last in. This means that GetNumGuildMembers() is not a reliable way to determine if the character is in a guild or not.</dd>
</dl>
<hr />


{{Template:WoW API}}
==Parameters==
===Arguments===
:;includeOffline : Boolean - include offline players in the headcount?
===Returns===
:;numGuildMembers : Integer - number of people in the guild (online / both online and offline) or 0 if the player is not in a guild.
 
==Example==
local numOnline, numTotal = (GetNumGuildMembers()), (GetNumGuildMembers(true));
DEFAULT_CHAT_FRAME:AddMessage(numTotal .. " guild members: " .. numOnline .. " online, " .. (numTotal - numOnline) .. " online.");
===Result===
Displays the number of people online, offline, and the total headcount of your guild in the default chat frame.
 
==Notes==
You may need to call [[API_GuildRoster|GuildRoster()]] first in order to obtain correct data. May return wrong values immediately after quitting a guild. Maximum returned value is 500.