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

As Páginas de Amigo são uma versão especial de Pages retornada por Players:GetFriendsAsync().Os itens contidos dentro incluem informações sobre os amigos de um jogador e têm a seguinte estrutura:


<th>Tipo</th>
<th>Descrição</th>
</tr>
<tr>
<td><code>Nome de Exibição</code></td>
<td>string / cadeia / texto</td>
<td>O nome de exibição atual do amizade.</td>
</tr>
<tr>
<td><code>Id</code></td>
<td>int64</td>
<td>O ID do usuário do amizade.</td>
</tr>
<tr>
<td><code>Nome de usuário</code></td>
<td>string / cadeia / texto</td>
<td>O nome de usuário do amizade.</td>
</tr>
Qual o nome

Veja os exemplos de código para como iterar sobre os amigos de um jogador.

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

    Se a página atual é ou não a última página disponível.

Métodos

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

  • Rendimentos

    Itera para a próxima página no objeto Páginas, se possível.

Propriedades

Métodos

Eventos