Lobby matchmaking

Hello! I’m just starting experimenting with Nakama, I’m loving it so far!

What I need to achieve is to implement a lobby-like matchmaking, I need that a player should be able to create a room and wait for the rest of the members up to 4 players, and he should start the game when they want it. (Even if its only 2 members)

It is possible to achieve something like this on Nakama?

What I saw on the matchmaking documentation once a match is made you must start the multiplayer immediately and theres no possibility for other players to join, is this correct?

I was thinking in creating chat rooms to act as a lobby, and do the matchmaking manually looking open chat rooms, what do you think about this, is this a viable option?

Thank you for your help!

Hi @LucasGaspar welcome :wave:

Have a look at the documentation for match listings. This covers the lobby-style of multiplayer system you want to achieve. It supports both relayed and authoritative multiplayer matches. We recommend that you use match listings when you want players to find matches. And use the matchmaker when you want players to find other players to form a match with.

A typical pattern with our match listings API is to wrap it in an RPC function call that’s executed by game clients which acts as a “find or create” operation for the match.

Hope that helps.

2 Likes

Awesome! :star_struck:
Thank you a lot for your fast answer!

1 Like

I am actively also trying to figure this out :). I want to have some kind of lobby system so it shows servers and how many people are in them etc. Kind of like how BFBC2 does, where it even shows empty servers since they are still active. THen players can just pick a server to join and if it lets them, etc. Reading up on it, but its tough to figure out how to convert the functions and all that to gdscript :P. I have this right now for matchmaking but I want to switch to match listing:

func start_matchmaking(_nakama_socket: NakamaSocket, data: Dictionary = {}) -> void:
	leave()
	_set_nakama_socket(_nakama_socket)
	match_mode = MatchMode.MATCHMAKER
	
	if data.has('min_count'):
		data['min_count'] = max(min_players, data['min_count'])
	else:
		data['min_count'] = min_players
	
	if data.has('max_count'):
		data['max_count'] = min(max_players, data['max_count'])
	else:
		data['max_count'] = max_players
	
	if client_version != '':
		if not data.has('string_properties'):
			data['string_properties'] = {}
		data['string_properties']['client_version'] = client_version
		
		var query = '+properties.client_version:' + client_version
		if data.has('query'):
			data['query'] += ' ' + query
		else:
			data['query'] = query
	
	match_state = MatchState.MATCHING
	var result = yield(nakama_socket.add_matchmaker_async(data.get('query', '*'), data['min_count'], data['max_count'], data.get('string_properties', {}), data.get('numeric_properties', {})), 'completed')
	if result.is_exception():
		leave()
		emit_signal("error", "Unable to join match making pool")
	else:
		matchmaker_ticket = result.ticket

This basically finds clients that are on the same server or are actively searching for each other on the same server. I want to change this to a lobby system like the OP wants. I would love to keep following up on this! BTW thank you guys for what you do!

You’ll want to swap from using matchmaker to using match listing instead. You submit a request that will return all matching matches available, which you can then present to the player and let them decide which one to join.

Thanks for the reply :slight_smile: So, basically its standard procedure of getting information from the server to the client just using Nakama’s built in functions right? SO, there are no custom functions needed, all I need to do is grasp the understanding of the Nakama MatchList fuctions and make them work for the Engine I’m using, and then use the Engines built in nodes to display it like a list?

It’s not as complicated as it looks I hope :P.

Exactly! If you are using Godot, here is an example of its use.

1 Like

Thank you very much! I actually had my tabs expanded so I didn’t even notice the Godot3, Godot4, Dart, etc tabs on the left :P.