FriendPages
非推奨を表示
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
友達ページは、Pages によって返された特別版の Players:GetFriendsAsync() です。含まれるアイテムには、プレイヤーの友達に関する情報が含まれており、次の構造を持っています:
<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 から継承されました