Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
No edit summary
(status is the last return value.)
(21 intermediate revisions by 13 users not shown)
Line 1: Line 1:
  +
{{wowapi}} __NOTOC__
<center>'''Title''' ''-Documentation by [[user:Author|IonDefender]]-''</center>
 
  +
Retrieves information about a person on your friends list.
  +
name, level, class, area, connected, status, note = GetFriendInfo(friendIndex);
   
  +
== Parameters ==
<!-- List return values and arguments as well as function name, follow Blizzard usage convention for args -->
 
 
=== Arguments ===
  +
:;friendIndex : Integer - Index of friend in the friend list (Note that status changes can re-order the friend list, indexes are not guaranteed to remain stable across events) (Also note that index should not be greater than 50 [see Notes]).
   
 
=== Returns ===
retVal1, retVal2, retVal3, retVal4 = GetFriendInfo(arg1);
 
  +
:;name : String - Friend's name, or nil (if index is invalid)
  +
:;level : Integer - Friend's level, or 0 (if offline/invalid).
  +
:;class : String - Friend's class, or "Unknown" (if offline/invalid).
 
:;area : String - Friend's current location, or "Unknown" (if offline/invalid).
  +
:;connected : Boolean - 1 if friend is online, nil otherwise.
 
:;note : String - Friends note.
  +
:;status : String - Friend's current status flags (AFK or DND).
   
 
== Example ==
<!-- Describe the purpose of the function, though exhausting detail can be saved for a later section -->
 
  +
This example is pre-2.4 and thus doesn't utilize the friend note.
 
local name, level, class, loc, connected, status = GetFriendInfo(1);
  +
if (name) then
 
DEFAULT_CHAT_FRAME:AddMessage("Your "..status.." friend "..name.." (The level "..level.." "..class..") is in "..loc..".");
  +
else
  +
DEFAULT_CHAT_FRAME:AddMessage("You have no friends?!");
  +
end
 
===Result===
 
Your <AFK> friend Bill (The level 99 Leprechaun) is in Neverland.
   
  +
==Notes==
Gets the name, level, class, and location of your friends
 
  +
Friend information isn't necessarily automatically kept up to date. You can use the [[API ShowFriends|ShowFriends]] function to request an update from the server.
   
----
 
;''Arguments''
 
   
  +
Do not use indexes greater than 50 (the maximum number of friend list entries)!
<!-- List each argument, together with its type -->
 
   
  +
With some AddOns installed the client may crash after typing "/script GetFriendInfo(51)" (especially if FlagRSP is activated).
:(arg1) : Int - Index of friend (Does not appear to be the exact order they appear in the friends list as online friends are sorted to the top but always have the same index)
 
   
  +
This crash leads to ERROR #132 (memory could not be "read").
----
 
;''Returns''
 
   
  +
Please use GetNumFriends() to iterate over all indexes securely.
<!-- List each return value, together with its type -->
 
   
  +
== References ==
:retVal1, retVal2, retVal3, retVal4
 
   
  +
{{Elink|icon=wowus|link=http://forums.worldofwarcraft.com/thread.html?topicId=5835557417#1|site="ACTUAL API Changes - 2.3.3 to 2.4.1" - Forum post by Iriel (UI and Macros Forum MVP)}}
:;retVal1
 
:;String - Friends name.
 
:;retVal2
 
:;String - Friends level. If unknown returns 0, but sometimes 1 (can someone else test this)
 
:;retVal3
 
:;String - Friends class. If unknown returns "Unknown"
 
:;retval4
 
:;String - Friends current location. If unknown returns "Unknown"
 
 
----
 
;''Example''
 
 
<!-- If it helps, include an example here, though it's not required if the usage is self-explanatory -->
 
 
local num1, num2, num3, num4 = GetFriendInfo(1);
 
DEFAULT_CHAT_FRAME:AddMessage("Your friend "..num1.." (The level "..num2.." "..num3..") is in "..num4..".");
 
 
;''Result''
 
 
<!-- If it helps, include example results here, though they are not required-->
 
 
Your friend Bill (The level 99 Leprechaun) is in Neverland.
 
 
----
 
{{Template:WoW API}}
 
<!-- Update the category to the appropriate subsection, and be sure to put the function name as the label for the category link. Multiple subcategories are okay if appropriate, please dont link functions to the API Functions category directly. -->
 
[[Category:API Functions|Empty Template]]
 

Revision as of 04:56, 6 April 2009

Retrieves information about a person on your friends list.

name, level, class, area, connected, status, note = GetFriendInfo(friendIndex);

Parameters

Arguments

friendIndex
Integer - Index of friend in the friend list (Note that status changes can re-order the friend list, indexes are not guaranteed to remain stable across events) (Also note that index should not be greater than 50 [see Notes]).

Returns

name
String - Friend's name, or nil (if index is invalid)
level
Integer - Friend's level, or 0 (if offline/invalid).
class
String - Friend's class, or "Unknown" (if offline/invalid).
area
String - Friend's current location, or "Unknown" (if offline/invalid).
connected
Boolean - 1 if friend is online, nil otherwise.
note
String - Friends note.
status
String - Friend's current status flags (AFK or DND).

Example

This example is pre-2.4 and thus doesn't utilize the friend note.

local name, level, class, loc, connected, status = GetFriendInfo(1);
if (name) then
 DEFAULT_CHAT_FRAME:AddMessage("Your "..status.." friend "..name.." (The level "..level.." "..class..") is in "..loc..".");
else
 DEFAULT_CHAT_FRAME:AddMessage("You have no friends?!");
end

Result

Your <AFK> friend Bill (The level 99 Leprechaun) is in Neverland.

Notes

Friend information isn't necessarily automatically kept up to date. You can use the ShowFriends function to request an update from the server.


Do not use indexes greater than 50 (the maximum number of friend list entries)!

With some AddOns installed the client may crash after typing "/script GetFriendInfo(51)" (especially if FlagRSP is activated).

This crash leads to ERROR #132 (memory could not be "read").

Please use GetNumFriends() to iterate over all indexes securely.

References