FriendPages

Visualizza obsoleti

*Questo contenuto è tradotto usando AI (Beta) e potrebbe contenere errori. Per visualizzare questa pagina in inglese, clicca qui.

Non costruibile
Non Replicato

FriendPages è una versione speciale di Pages restituita da Players:GetFriendsAsync() .Gli elementi contenuti all'interno includono informazioni sugli amici di un Giocatoree hanno la seguente struttura:


<th>Tipo</th>
<th>Descrizione</th>
</tr>
<tr>
<td><code>Nome da mostrare</code></td>
<td>stringa</td>
<td>Il nome visualizzato attuale dell'Amico/Amica.</td>
</tr>
<tr>
<td><code>Id</code></td>
<td>int64</td>
<td>L'ID utente del Amico/Amica.</td>
</tr>
<tr>
<td><code>Nome utente</code></td>
<td>stringa</td>
<td>Il nome utente del Amico/Amica.</td>
</tr>
Nome

Vedi gli esempi di codice per come iterare sui amici di un Giocatore.

Campioni di codice

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, ", "))

Sommario

Proprietà

Proprietà provenienti da Pages
  • Sola Lettura
    Non Replicato
    Lettura Parallela

    Se la pagina attuale è l'ultima pagina disponibile o meno.

Metodi

Metodi provenienti da Pages
  • Restituisce gli elementi sulla pagina attuale. Le chiavi nell'elemento sono determinate dalla fonte di questo oggetto.

  • Itera alla pagina successiva nell'oggetto pagine, se possibile.

Proprietà

Metodi

Eventi