FriendPages

Mostrar obsoleto

*Este conteúdo é traduzido por IA (Beta) e pode conter erros. Para ver a página em inglês, clique aqui.

Não criável
Não replicado

FriendPages es una versión especial de Pages devuelta por Players:GetFriendsAsync() . Los elementos contenidos dentro incluyen información de amigos de un jugador y tienen la siguiente estructura:


<tr>
<td><code>Nombre de visualización</code></td>
<td>cadena</td>
<td>El nombre de la pantalla actual del amistad.</td>
</tr>
<tr>
<td><code>Id.</code></td>
<td>int64</td>
<td>El ID de usuario del amistad.</td>
</tr>
<tr>
<td><code>Nombre de usuario</code></td>
<td>cadena</td>
<td>El nombre de usuario del amistad.</td>
</tr>
NombreTipoDescripción

Vea los ejemplos de código para cómo repetirse sobre los amigos de un jugador.

Amostras de código

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

Resumo

Propriedades

Propriedades herdados de Pages
  • Somente leitura
    Não replicado
    Ler Parallel

    Independentemente de a página atual ser a última página disponível.

Métodos

Métodos herdados de Pages
  • Retorna os itens na página atual. As chaves do item são determinadas pela fonte deste Objeto.

  • Rendimentos

    itera para a próxima página no Objetode páginas, se possível.

Propriedades

Métodos

Eventos