FriendPages는 Pages 에 의해 반환된 특별한 버전입니다. 아이템에 포함된 정보는 플레이어의 친구에 대한 정보를 포함하며 다음과 같은 구조를 가집니다.
<tr><td><code>표시 이름</code></td><td>문자열</td><td>친구의 현재 디스플레이 이름입니다.</td></tr><tr><td><code>Id</code></td><td>int64</td><td>친구의 ID입니다.</td></tr><tr><td><code>사용자 이름</code></td><td>문자열</td><td>친구의 사용자 이름입니다.</td></tr>
이름 | 유형 | 설명 |
플레이어의 친구를 반복하는 방법에 대한 코드 샘플을 참조하십시오.
코드 샘플
This code sample loads the Player.UserId of the player whose username is provided at the top of the script by using Players:GetUserIdFromNameAsync(). Then, it gets a FriendPages object by calling Players:GetFriendsAsync() and iterates over each entry using the iterPageItems function. The username of each friend is stored in a table, then printed at the end.
Print Roblox Friends
local Players = game:GetService("Players")
local USERNAME = "Cozecant"
local function iterPageItems(pages)
return coroutine.wrap(function()
local pagenum = 1
while true do
for _, item in ipairs(pages:GetCurrentPage()) do
coroutine.yield(item, pagenum)
end
if pages.IsFinished then
break
end
pages:AdvanceToNextPageAsync()
pagenum = pagenum + 1
end
end)
end
-- First, get the user ID of the player
local userId = Players:GetUserIdFromNameAsync(USERNAME)
-- Then, get a FriendPages object for their friends
local friendPages = Players:GetFriendsAsync(userId)
-- Iterate over the items in the pages. For FriendPages, these
-- are tables of information about the friend, including Username.
-- Collect each username in a table
local usernames = {}
for item, _pageNo in iterPageItems(friendPages) do
table.insert(usernames, item.Username)
end
print("Friends of " .. USERNAME .. ": " .. table.concat(usernames, ", "))
요약
속성
Pages에서 상속된 속성
메서드
Pages에서 상속된 속성