FBInstant.context.getPlayersAsync: Difference between revisions

From GiderosMobile
No edit summary
No edit summary
Line 8: Line 8:
  FBInstant.context.getPlayersAsync(callback)
  FBInstant.context.getPlayersAsync(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. ''''''<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. <br/>
=== Examples ===
'''Example 1'''<br/>
<source lang="lua"><br />
FBInstant.context.getPlayersAsync(function(result,error)
    if result then
print("Active 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.context.getPlayersAsync(function(result,error)
    if result then
print("Active 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 09:44, 23 August 2018

Available since: Gideros 2018.3

Description


Gets an table of #contextplayer tables containing information about active players (people who played the game in the last 90 days) that are associated with the current context. This may include the current player.

 FBInstant.context.getPlayersAsync(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.

Examples

Example 1

<br />
FBInstant.context.getPlayersAsync(function(result,error)
    if result then
		print("Active 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.context.getPlayersAsync(function(result,error)
    if result then
		print("Active 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/>