FriendsService
成员函数
获取好友数量 |
根据好友的序列号拿到好友信息 |
void QueryFriendInfoAsync () |
---|
异步查询好友信息 |
是否查询完成 |
是否查询完成 |
代码示例
lua
------ 判断某人是否是好友 ----------
local function checkFriends(playerUin)
local friendsService = game:GetService("FriendsService")
friendsService:QueryFriendInfoWithCallback(function(ok)
if not ok then
print("查询好友信息失败")
return
end
local friendsNum = friendsService:GetSize() --获取好友数(总序列号)
for i = 0,friendsNum-1,1 do --初值,终值,步数
local uin,nickName,onLine = friendsService:GetFriendsInfoByIndex(i) --遍历好友
local isFriend = false
if playerUin == uin then --比对该uin和拉去的好友列表
isFriend = true
end
if isFriend then
print("%s: is friend",nickName)
else
print("%s: is not friend",nickName)
end
end
end)
end
local playerUin = 1111 --已知某人的uin信息
checkFriends(playerUin)