FriendPages

แสดงที่เลิกใช้งานแล้ว

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่

ไม่สามารถสร้าง
ไม่ซ้ำ

FriendPages เป็นรุ่นพิเศษของ 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>ตัวเลข 64 บิต</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
  • คืนรายการบนหน้าปัจจุบัน คีย์ในรายการจะถูกกำหนดโดยแหล่งของวัตถุนี้

  • ผลตอบแทน

    จัดเตรียมการไปยังหน้าต่อไปในวัตถุหน้าหากเป็นไปได้

คุณสมบัติ

วิธีการ

อีเวนต์