[v2.1.0] MatchmakingService - ON HOLD

While that’s helpful too, I need the full stacktrace along with the error. It will show what line the error occurred on and what function called it.

You mean this?

 ServerStorage.MainModule:1237: Failed to invoke transformation function.  -  Server - MainModule:1237
  22:14:15.374  Stack Begin  -  Studio
  22:14:15.374  Script 'ServerStorage.MainModule', Line 1237 - function RemovePlayerFromGameId  -  Studio - MainModule:1237
  22:14:15.374  Script 'ServerStorage.MainModule', Line 1247 - function RemovePlayerFromGame  -  Studio - MainModule:1247
  22:14:15.374  Script 'ServerScriptService.Script', Line 41  -  Studio - Script:41
  22:14:15.374  Stack End  -  Studio

Yes. Thank you.

I’m gonna go out on a limb and say it’s this: MatchmakingService:StartGame(7852647049, false). The first value passed must be the game id that was passed in player’s join data. This value is not static and a new id is generated for every game. That’s why in the example it gets the id from their join data

So the first value of the StartGame function must be the original places id?

No, when a player is added to the queue it constantly searches for more users and puts them into a group. This group of users is in a “game.” Game in this context has nothing to do with roblox games, they’re completely separate from roblox places. I understand how that could be confusing. Basically, that code is the joinData.TeleportData.gameCode from users. You can see that in the example script here:

game.Players.PlayerAdded:Connect(function(player)
	local joinData = player:GetJoinData()
	if _G.gameId == nil and joinData then
		_G.gameId = joinData.TeleportData.gameCode -- this line is where the game id is extracted from
		_G.ratingType = joinData.TeleportData.ratingType
	end
	if #game.Players:GetPlayers() >= 2 then
		Start()
	end
end)

In reality, this code is just the teleport code to the reserved place. But it’s uniquely identifying so it works for this.

So initially, where does _G come from in this sense?

_G is the global context. _G can be accessed from any script at any time. It is not recommended to use it often as it can lead to memory leaks, but the server will be closed after the game ends anyways.

https://www.lua.org/pil/14.html

Basically this allows _G.gameId to be accessed and used from any script.

Okay make sense now. This is currently my script in my main place. Would this be alright?

local MatchmakingService = require(ServerStorage.Modules.MainModule).GetSingleton()


workspace.SpawnLocation.ProximityPrompt.Triggered:Connect(function(plr)
	MatchmakingService:QueuePlayer(plr, "Solo")
	local reservedCOde = game["Teleport Service"]:ReserveServer(7852647049)
	game["Teleport Service"]:TeleportToPrivateServer(7852647049, reservedCOde, plr)
end)

--// Matchmake Settings

PlayerManager.Start()

MatchmakingService:SetMatchmakingInterval(3)
MatchmakingService:SetPlayerRange(NumberRange.new(0, 10))
MatchmakingService:SetGamePlace(7852647049)

MatchmakingService.PlayerAddedToQueue:Connect(function(plr, glicko, rateType, skillPool)
	print(plr, glicko, rateType, skillPool)
end)

MatchmakingService.PlayerRemovedFromQueue:Connect(function(plr, ratingType, skillPool)
	print(plr, ratingType, skillPool)
end)


It should, but you shouldn’t teleport players to the place yourself. You should let matchmakingservice handle this for you. If you wish to discuss this further, please dm me so we stop bumping the topic.

So I can detect when a player is added/removed but can I get the number of indexes in the queue?

What do you mean the number of indexes in queue? Like the number of players in queue?

1 Like

Isn’t TrueSkill patented though? You would need Microsoft’s permission to even use it legally.

Yes that is what I mean by the number of indexes in a queue

You can use GetQueueCounts(), but as I said in the post, I don’t recommend spamming that method. Using PlayerAddedToQueue and PlayerRemovedFromQueue and keeping track of it like that is much better in terms of performance. For example GetQueueCounts() can up to make 3+numberOfDifferentSkillLevelsQueued*3 and has a minimum of 1+numberOfDifferentSkillLevelsQueued calls to memory. Now for 1 or 2 different skill types, this doesn’t matter. But if you have even 10 different skill levels queued, that’s 10 calls to memory minimum every time you call GetQueueCounts().

GetQueueCounts()`

1 Like

Ah, yeah it is. I didn’t even think about that. I don’t think it’d even be possible (for me) to obtain a sublicensable license from microsoft for all users of MatchmakingService.

See this reddit post.
My module has a different name and is based on this open-license implementation which uses different math.

2 Likes

If I don’t care about the ratings or SBMM system, can I just not initialize MatchmakingService on the game server? I’m asking if doing that will break any systems in the matchmaking (e.g. it was expecting a match result).

You can safely not call UpdateRatings() and it’ll keep everyone at the same rating effectively meaning everyone is always at the same level. This is more clearly stated in the new docs I’m working on. However you should still initialize the service and call RemoveGame() and StartGame() at their appropriate times.

I will add though that roblox has still not replied to my bug report… So this service is still a little broken

Is there a reason I need to use RemoveGame() and StartGame()? I’m in a weird situation here.

There can be up to 2 players normally in a server, but at certain points during a co-op experience parties will “intersect” if they are at the same point in the story; so they will come together in a single 4 player server for a period of time. If you’ve heard of resident evil 6’s intersection system, it’s basically that.

Also, is there a way to modify the function when a “match” is found? I need to set a datastore with the new servers’ reserve code for teleport data such as what checkpoint they are at in the story.

If you don’t use RemoveGame() the game will exist in memory until it times out which is bad for the overall performance of the memory store (and more importantly, right now it’s a big problem, see current solutions bug report for why). There is no real reason to use StartGame() other than to mark it as started. Currently there isn’t a way to modify match found, but I can add that functionality in the future

Edit: I accidentally reset the solution, sorry to anyone that was notified!