WoW:API GetFriendInfo: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
<center>'''GetFriendInfo''' - ''Documentation by [[user:Author|IonDefender]]''</center>
{{wowapi}} __NOTOC__
Retrieves information about a person on your friends list.
name, level, class, area, connected, status = GetFriendInfo(friendIndex);


Gets the name, level, class, location, connection, status of a friend
name, level, class, area, connected, status = GetFriendInfo(friendIndex)
== Parameters ==
== Parameters ==
=== Arguments ===
=== Arguments ===
:(friendIndex)
:;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).
 
:;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)
=== Returns ===
=== Returns ===
:name, level, class, area, connected
:;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).


:;name : String - Friend's name ("Unknown" if index is out of bounds.)
:;level : Integer - Friend's level (0 if player is not online, 1 if index is out of bounds (confirmed by [[User:Topaz|Topaz]] 22:37, 12 Mar 2005 (EST))
:;class : String - Friend's class ("Unknown" if index is out of bounds or friend is offline).
:;area : String - Friend's current location ("Unknown" if index is out of bounds or friend is offline).
:;connected : Flag - 1 if friend is online, nil if not online (or index out of bounds).
:;status : String - Friends current status (IE AFK/etc found by [[User:Tigerheart|Tigerheart]]).
== Example ==
== Example ==
<!-- begin code -->
  local name, level, class, loc, connected, status = GetFriendInfo(1);
  local name, level, class, loc, connected, status = GetFriendInfo(1);
  DEFAULT_CHAT_FRAME:AddMessage("Your "..status.." friend "..name.." (The level "..level.." "..class..") is in "..loc..".");
  if (name) then
<!-- end code -->
  DEFAULT_CHAT_FRAME:AddMessage("Your "..status.." friend "..name.." (The level "..level.." "..class..") is in "..loc..".");
==== Result ====
else
<!-- begin code -->
  DEFAULT_CHAT_FRAME:AddMessage("You have no friends?!");
Your <AFK> friend Bill (The level 99 Leprechaun) is in Neverland.
end
<!-- end code -->
===Result===
 
Your <AFK> friend Bill (The level 99 Leprechaun) is in Neverland.
== Details ==
: 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.
 


----
==Notes==
{{WoW API}}
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.
__NOTOC__

Revision as of 12:16, 3 January 2007

WoW API < GetFriendInfo

Retrieves information about a person on your friends list.

name, level, class, area, connected, status = 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).

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

Example

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.