WoW:API GetFriendInfo: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(Added friends notes (2.4))
m (Move page script moved page API GetFriendInfo to API GetFriendInfo without leaving a redirect)
 
(3 intermediate revisions by 3 users not shown)
Line 5: Line 5:
== Parameters ==
== Parameters ==
=== Arguments ===
=== 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]).
:;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 ===
=== Returns ===
:;name : String - Friend's name, or nil (if index is invalid)
:;name
:;level : Integer - Friend's level, or 0 (if offline/invalid).
:: String - Friend's name, or nil (if index is invalid)
:;class : String - Friend's class, or "Unknown" (if offline/invalid).
:;level
:;area : String - Friend's current location, or "Unknown" (if offline/invalid).
:: Integer - Friend's level, or 0 (if offline/invalid).
:;connected : Boolean - 1 if friend is online, nil otherwise.
:;class
:;status : String - Friend's current status flags (AFK or DND).
:: String - Friend's class, or "Unknown" (if offline/invalid).
:;note : String - Friends note.
:;area
:: String - Friend's current location, or "Unknown" (if offline/invalid).
:;connected
:: Boolean - 1 if friend is online, nil otherwise.
:;
:;status
:: String - Friend's current status flags (AFK or DND).
:;note
:: String - Friend's note.


== Example ==
== Example ==
Line 33: Line 42:
Do not use indexes greater than 50 (the maximum number of friend list entries)!
Do not use indexes greater than 50 (the maximum number of friend list entries)!


In some AddOn constellations I got WoW crashing by typing "/script GetFriendInfo(51)" (especially if FlagRSP was activated).
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").
This crash leads to ERROR #132 (memory could not be "read").
Line 40: Line 49:


== References ==
== References ==
{{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)}}
{{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)}}

Latest revision as of 04:45, 15 August 2023

WoW API < GetFriendInfo

Retrieves information about a person on your friends list.

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

Parameters[edit]

Arguments[edit]

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[edit]

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.
status
String - Friend's current status flags (AFK or DND).
note
String - Friend's note.

Example[edit]

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[edit]

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

Notes[edit]

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[edit]