View Single Post
03/04/23, 02:38 AM   #3
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,580
Originally Posted by sinnereso View Post
im working on additional feature for my addon and having issues with the "GetFriendInfo()". Im looking to find a specific friend in friends list and check if they're online before executing code. im currently messing with this sort of thing.

Code:
local savedPlayer = xxx.savedVariables.savedPlayer
if not IsPlayerInGroup(savedPlayer) and IsFriend(savedPlayer) then
	for iD = 1, GetNumFriends() do
		if GetFriendInfo(iD) == (savedPlayer, nil, PLAYER_STATUS_ONLINE, nil) then
the formatting of these keeps messing me up.. ive tried in brackets etc. Any suggestions for something I've missed?
That's not valid Lua syntax.
You need to store each return value you want to compare into a local variable and then compare each of them separately:
Lua Code:
  1. local savedPlayer = xxx.savedVariables.savedPlayer
  2. if not IsPlayerInGroup(savedPlayer) and IsFriend(savedPlayer) then
  3.     for iD = 1, GetNumFriends() do
  4.         local friendName, _, status = GetFriendInfo(iD)
  5.         if friendName == savedPlayer and status == PLAYER_STATUS_ONLINE then
  Reply With Quote