Difference between revisions of "FBInstant.player.getConnectedPlayersAsync"

From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight")
Line 7: Line 7:
 
Fetches a table of ConnectedPlayer tables containing information about players that are connected to the current player.<br />
 
Fetches a table of ConnectedPlayer tables containing information about players that are connected to the current player.<br />
 
<br /></translate>
 
<br /></translate>
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
  FBInstant.player.getConnectedPlayersAsync(callback)
 
  FBInstant.player.getConnectedPlayersAsync(callback)
 
</source>
 
</source>
Line 14: Line 14:
 
=== <translate>Examples</translate> ===
 
=== <translate>Examples</translate> ===
 
'''Example 1'''<br/>
 
'''Example 1'''<br/>
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
FBInstant.player.getConnectedPlayersAsync(function(result,error)
 
FBInstant.player.getConnectedPlayersAsync(function(result,error)
 
     if result then
 
     if result then
Line 28: Line 28:
 
<br/></source>
 
<br/></source>
 
'''Example 2'''<br/>
 
'''Example 2'''<br/>
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
FBInstant.player.getConnectedPlayersAsync(function(result,error)
 
FBInstant.player.getConnectedPlayersAsync(function(result,error)
 
     if result then
 
     if result then

Revision as of 15:28, 13 July 2023


Available since: Gideros 2018.3
Class: Player

Description


Fetches a table of ConnectedPlayer tables containing information about players that are connected to the current player.

<syntaxhighlight lang="lua">

FBInstant.player.getConnectedPlayersAsync(callback)

</source>

Parameters

callback: (function) A function that will be called with two arguments: a set of key-value pairs or nil is the operation failed, and an error code if the function failed. NOTE: This promise will not resolve until FBInstant.startGameAsync() has resolved.

Examples

Example 1
<syntaxhighlight lang="lua"> FBInstant.player.getConnectedPlayersAsync(function(result,error)

   if result then

print("Connected players:",#result) for loop=1,#result do local player=result[loop] for key,value in pairs(player) do print(key,value) end end end end)
</source> Example 2
<syntaxhighlight lang="lua"> FBInstant.player.getConnectedPlayersAsync(function(result,error)

   if result then

print("Connected players:",#result) for loop=1,#result do local player=result[loop] print("id, name, photo:",player.getID(),player.getName(),player.getPhoto()) end end end)
</source>