Matchmaking
Start matchmaking for any world.
🗿Static Class
This is a Static Class. Access it's methods directly with
.
. It's not possible to spawn new instances.💂Authority
This static class can be accessed only on 🟦 Server side.
Examples​
Server/Index.lua
print("Matchmaking example")
local matchmaking_id
function EnterMatchmaking(player)
Matchmaking.LeaveAllMatchmaking(player, function (success)
if success then
Matchmaking.JoinMatchmaking("helix-casino-games", player, 5, function(sucess, match_id, current_players, min_players)
matchmaking_id = match_id
print(sucess)
print("Matchmaking ID = " .. match_id)
print("Current players =" .. current_players)
print("Min players to start = " .. min_players)
end)
end
end)
end
-- Check matchmaking status every second
Timer.SetInterval(function ()
if (matchmaking_id ~= nil) then
Matchmaking.CheckMatchmakingStatus(matchmaking_id, function(sucess, match_id, current_players, min_players, status, ip)
print("Matchmaking Status:")
print(sucess)
print(match_id)
print(current_players)
print(min_players)
print(status)
print(ip)
if (ip ~= '') then
-- connect
end
end)
end
end, 1000)
Static Functions​
Returns | Name | Description | |
---|---|---|---|
JoinMatchmaking | Join matchmaking for any world | ||
CheckMatchmakingStatus | Check matchmaking status | ||
LeaveMatchmaking | Remove player from specified matchmaking | ||
LeaveAllMatchmaking | Remove player from specified matchmaking |
JoinMatchmaking
​
Join matchmaking for any world
Matchmaking.JoinMatchmaking(world_name, player, min_players, callback)
Type | Parameter | Default | Description |
---|---|---|---|
string | world_name | World name to join | |
Player | player | Player joining matchmaking | |
integer | min_players | Minimum players to start | |
function | callback | Matchmaking callback in the format (success, match_id, current_players, min_players) |
CheckMatchmakingStatus
​
Check matchmaking status
Matchmaking.CheckMatchmakingStatus(match_id, callback)
Type | Parameter | Default | Description |
---|---|---|---|
string | match_id | Matchmaking ID | |
function | callback | Matchmaking status callback in the format (success, match_id, current_players, min_players, match_status, addr_to_connect) |
LeaveMatchmaking
​
Remove player from specified matchmaking
Matchmaking.LeaveMatchmaking(match_id, player, callback)
Type | Parameter | Default | Description |
---|---|---|---|
string | match_id | Matchmaking ID | |
Player | player | Player to be removed from matchmaking | |
function | callback | Matchmaking status callback in the format (success) |
LeaveAllMatchmaking
​
Remove player from specified matchmaking
Matchmaking.LeaveAllMatchmaking(player, callback)
Type | Parameter | Default | Description |
---|---|---|---|
Player | player | Player to be removed from matchmaking | |
function | callback | Matchmaking status callback in the format (success) |