FriendPages는 반환된 특별 버전의 에서 돌아오는 페이지입니다.내부에 포함된 항목에는 플레이어의 친구에 대한 정보가 포함되어 있으며 다음 구조를 가집니다:
<th>유형</th><th>설명</th></tr><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에서 상속된 속성