Difference between revisions of "FBInstant.matchPlayerAsync"
Line 2: | Line 2: | ||
'''Available since:''' Gideros 2018.3.1<br/> | '''Available since:''' Gideros 2018.3.1<br/> | ||
=== Description === | === Description === | ||
− | <br /> | + | <translate><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 /> | 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 /> | + | <br /></translate> |
<source lang="lua"> | <source lang="lua"> | ||
FBInstant.matchPlayerAsync(matchTag,switchContextWhenMatched,callback) | FBInstant.matchPlayerAsync(matchTag,switchContextWhenMatched,callback) | ||
</source> | </source> | ||
=== Parameters === | === 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'''<br/> | + | '''matchTag''': (string) <translate>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.</translate> '''optional'''<br/> |
− | '''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'''<br/> | + | '''switchContextWhenMatched''': (boolean) <translate>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.</translate> '''optional'''<br/> |
− | '''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. <br/> | + | '''callback''': (function) <translate>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.</translate> <br/> |
=== Examples === | === Examples === | ||
'''Example'''<br/> | '''Example'''<br/> | ||
− | <source lang="lua" | + | <source 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 20: | Line 20: | ||
<br/></source> | <br/></source> | ||
'''Example 2'''<br/> | '''Example 2'''<br/> | ||
− | <source lang="lua" | + | <source 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 | ||
end) | end) | ||
<br/></source> | <br/></source> |
Revision as of 13:32, 23 August 2018
Available since: Gideros 2018.3.1
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/>