FBInstant.matchPlayerAsync

This page contains changes which are not marked for translation.


Available since: Gideros 2018.3.1
Class: * Initialisation and Core

Description


Attempts to match the current player with other users looking for people to play with. If successful, a new Messenger group thread will be created containing the matched players and the player will be context switched to that thread. The default minimum and maximum number of players in one matched thread are 2 and 20 respectively, depending on how many players are trying to get matched around the same time. The values can be changed in fbapp-config.json. See the [Bundle Config documentation]https://developers.facebook.com/docs/games/instant-games/bundle-config for documentation about fbapp-config.json.

 FBInstant.matchPlayerAsync(matchTag,switchContextWhenMatched,callback)

Parameters

matchTag: (string) Optional extra information about the player used to group them with similar players. Players will only be grouped with other players with exactly the same tag. The tag must only include letters, numbers, and underscores and be 100 characters or less in length. optional
switchContextWhenMatched: (boolean) Optional extra parameter that specifies whether the player should be immediately switched to the new context when a match is found. By default this will be false which will mean the player needs explicitly press play after being matched to switch to the new context. optional
callback: (function) A function that will be called with two arguments: True when the player has been added to a group thread and switched into the thread's context. An error code if the function failed.

Examples

Example

FBInstant.matchPlayerAsync("level1", function(result,error)
	print(FBInstant.context.getID()) -- eg 12345
end)
<br/>

Example 2

FBInstant.matchPlayerAsync(nil, function(result,error)
	print(FBInstant.context.getID()) -- eg 34567
end)
<br/>