WoW API: GetNumWhoResults

From AddOn Studio
Jump to navigation Jump to search

WoW API < GetNumWhoResults

Title -Documentation by Mikk-

Get the number of entries resulting from your most recent /who query.

  numWhos, totalCount = GetNumWhoResults();

Parameters

Returns

Returns
totalCount, numWhos
totalCount
Number - number of users matching the query
numWhos
Number - number of entries actually returned

Normally, these two will be returned as the same number.

However, if the query matched more players than the server wants to return (currently 49), totalCount will be returned as 50 and numWhos will be returned as 49. Hence, totalCount being greater than numWhos seems to be a future-safe indication of the list having been truncated.


FrameXML has these two names swapped around, but I suspect that it is a bug. There is code to display a warning about the list being truncated, but it never triggers.




Comment by egingell

The following code does not produce the results I expected. First pass (assume that it should find 10 people) sends 'numWhos = 0 totalCount = 0' to the chat frame. Second pass (assume that it should find 1 person) sends 'numWhos = 10 totalCount = 10' to the chat frame. Third pass sends 'numWhos = 1 totalCount = 1' to the chat frame. GetNumWhoResults() seems to be one step behind SendWho().

SendWho(filter);
local numWhos, totalCount = GetNumWhoResults(); 
DEFAULT_CHAT_FRAME:AddMessage('numWhos = '..tostring(numWhos).. ' totalCount = '..tostring(totalCount));


Comment by hudlee

After you call SendWho("filter"); you have to wait for a WHO_LIST_UPDATE event before the results are available. So you'll need to call GetNumWhoResults(); from an event handler.