Difference between revisions of "FBInstant.matchPlayerAsync"

From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight")
Line 7: Line 7:
 
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.<br />
 
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.<br />
 
<br /></translate>
 
<br /></translate>
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
  FBInstant.matchPlayerAsync(matchTag,switchContextWhenMatched,callback)
 
  FBInstant.matchPlayerAsync(matchTag,switchContextWhenMatched,callback)
 
</source>
 
</source>
Line 16: Line 16:
 
=== <translate>Examples</translate> ===
 
=== <translate>Examples</translate> ===
 
'''Example'''<br/>
 
'''Example'''<br/>
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
FBInstant.matchPlayerAsync("level1", function(result,error)
 
FBInstant.matchPlayerAsync("level1", function(result,error)
 
print(FBInstant.context.getID()) -- eg 12345
 
print(FBInstant.context.getID()) -- eg 12345
Line 22: Line 22:
 
<br/></source>
 
<br/></source>
 
'''Example 2'''<br/>
 
'''Example 2'''<br/>
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
FBInstant.matchPlayerAsync(nil, function(result,error)
 
FBInstant.matchPlayerAsync(nil, function(result,error)
 
print(FBInstant.context.getID()) -- eg 34567
 
print(FBInstant.context.getID()) -- eg 34567

Revision as of 14:26, 13 July 2023


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.

<syntaxhighlight lang="lua">

FBInstant.matchPlayerAsync(matchTag,switchContextWhenMatched,callback)

</source>

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
<syntaxhighlight lang="lua"> FBInstant.matchPlayerAsync("level1", function(result,error) print(FBInstant.context.getID()) -- eg 12345 end)
</source> Example 2
<syntaxhighlight lang="lua"> FBInstant.matchPlayerAsync(nil, function(result,error) print(FBInstant.context.getID()) -- eg 34567 end)
</source>