Difference between revisions of "FBInstant.player.getConnectedPlayersAsync"
From GiderosMobile
Line 8: | Line 8: | ||
FBInstant.player.getConnectedPlayersAsync(callback) | FBInstant.player.getConnectedPlayersAsync(callback) | ||
</source> | </source> | ||
− | '''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. ''''''<br/> | + | === 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. <br/> | ||
+ | === Examples === | ||
+ | '''Example 1'''<br/> | ||
+ | <source lang="lua"><br /> | ||
+ | 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) | ||
+ | <br/></source> | ||
+ | '''Example 2'''<br/> | ||
+ | <source lang="lua"><br /> | ||
+ | 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) | ||
+ | <br/></source> |
Revision as of 10:39, 23 August 2018
Available since: Gideros 2018.3
Description
Fetches a table of ConnectedPlayer tables containing information about players that are connected to the current player.
FBInstant.player.getConnectedPlayersAsync(callback)
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
<br />
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)
<br/>
Example 2
<br />
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)
<br/>