SparkMultiplayer
Provides access to the platform's multiplayer capabilities.
e.g.
var multiplayer = Spark.getMultiplayer();
createMatch
signature createMatch(SparkPlayer[] players)
returns string
validity All Scripts
Create a match between the given players.
params
players - An array of players to include in the match
returns
The matchId if a match was successfully created, or null
example
var matchId = Spark.getMultiplayer().createMatch(player1, player2);
createMatchById
signature createMatchById(string[] playerIds)
returns string
validity All Scripts
Create a match between the players for the given playerIds.
params
playerIds - An array of playerIds to include in the match
returns
The matchId if a match was successfully created, or null
example
var matchId = Spark.getMultiplayer().createMatchById(playerId1, playerId2);
createMatchWithMatchId
signature createMatchWithMatchId(string matchId, SparkPlayer[] players)
returns string
validity All Scripts
Create a match between the given players, using the given matchId.
params
matchId - The matchId to use when creating this match
players - An array of players to include in the match
returns
The matchId if a match was successfully created, or null
example
var matchId = Spark.getMultiplayer().createMatchWithMatchId("myId", player1, player2);
createMatchByIdWithMatchId
signature createMatchByIdWithMatchId(string matchId, string[] playerIds)
returns string
validity All Scripts
Create a match between the players for the given playerIds, using the given matchId.
params
matchId - The matchId to use when creating this match
playerIds - An array of playerIds to include in the match
returns
The matchId if a match was successfully created, or null
example
var matchId = Spark.getMultiplayer().createMatchById("myId", playerId1, playerId2);
loadMatch
signature loadMatch(string matchId)
returns SparkMatch
validity All Scripts
Load the match with the given matchId
params
matchId - The id of the match to load
returns
The match if a match was found with the given id
example
var matchId = Spark.getMultiplayer().loadMatch(matchId);
getMatchConfig
signature getMatchConfig(string shortCode)
returns SparkMatchConfig
validity All Scripts
Load the match configuration for the given shortCode
params
shortCode - The shortCode of the match configuration to load
returns
The match configuration if a one was found with the given shortCode
example
var matchConfig = Spark.getMultiplayer().getMatchConfig(shortCode);
loadPendingMatchById
signature loadPendingMatchById(string pendingMatchId)
returns PendingMatch
validity All Scripts
Load the pending match with the given pendingMatchId
params
pendingMatchId - The id of the pending match to load
returns
The pending match if one was found with the given id
example
var pendingMatch = Spark.getMultiplayer().loadPendingMatchById(pendingMatchId);
loadPendingMatchByPlayer
signature loadPendingMatchByPlayer(SparkPlayer player, string shortCode, string matchGroup)
returns PendingMatch
validity All Scripts
Load the pending match containing the given player for the match shortCode and match group.
params
player - A player within the pending match
shortCode - The shortCode of the match configuration for the pending match
matchGroup - The matchGroup for the pending match
returns
The pending match if one was found with the given id
example
var pendingMatch = Spark.getMultiplayer().loadPendingMatchByPlayer(player, matchShortCode, matchGroup);
cancelMatchmaking
signature cancelMatchmaking(SparkPlayer player, string shortCode, string matchGroup)
returns void
validity All Scripts
Cancel matchmaking for the given player, match shortCode and match group.
params
player - A player within a pending match
shortCode - The shortCode of the match configuration for the pending match
matchGroup - The matchGroup for the pending match
example
Spark.getMultiplayer().cancelMatchmaking(player, matchShortCode, matchGroup);