question

Kyle Meadows avatar image
Kyle Meadows asked

What is the best way for a player to pass parameters into the server during matchmaking?

I want players to choose what faction they are going to play as before finding a match. It seems rules are more for 'matchmaking algorithms' and not what I'm looking for. I simply want the player to pass a single string and have the server read it. I'm currently getting the player's id by calling GetInitialPlayers, but it doesn't return any additional information.

So, how would I allow users to pass in info when matchmaking, and how would the server get that information? It seems rules are not it, and I haven't been able to find much info on 'attributes.'

Player DataCustom Game ServersMatchmaking
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Citrus Yan avatar image
Citrus Yan answered

Referring to this doc: Information passed to the game server:

“Matchmaking does not pass any ticket attributes to the game server. If the game needs to access any ticket attributes on the server, it can do so by calling GetMatch with the ReturnMemberAttributes header to true.”

In your case, you can specify the user info in the “Attributes” property when creating a Matchmaking Ticket. When a match is made, have the server call GetMatch with the ReturnMemberAttributes property to true to retrieve the info specified previously.

7 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Kyle Meadows avatar image Kyle Meadows commented ·

It seems I'm having problems getting the match from the server. Is there anything else I need to provide?

            PlayFabSettings.staticSettings.TitleId = GameserverSDK.TitleIdKey;
            PlayFabSettings.staticSettings.DeveloperSecretKey = ...

            PlayFabResult<GetMatchResult> matchResult = null;
            Task.Run(async () =>
            {
                matchResult = await PlayFabMultiplayerAPI.GetMatchAsync(new GetMatchRequest()
                {
                    QueueName = "1v1",
                    MatchId = GameserverSDK.SessionIdKey,
                    ReturnMemberAttributes = true
                });
            });
            var match = matchResult.Result; 	

I then get the members' id by doing this:

foreach(var member in match.Members)
            {
                string id = $"{member.Entity.Type}!{member.Entity.Id}";

		...
            }

I'm not quite sure how to debug this when it's uploaded to playfab... and I can't use the mock agent because this code is for when an actual match is made. The matchmaking works and I get the server info, but I think it then crashes.

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Kyle Meadows commented ·
0 Likes 0 ·
Kyle Meadows avatar image Kyle Meadows Citrus Yan commented ·

Thanks for the info! Isn't the match id fetched by using "GameserverSDK.SessionIdKey"? For some reason it is saying, "Invalid input parametersMatchId: Must be a valid GUID string"

var task = Task.Run(async () =>
            {
                var entity = new GetEntityTokenRequest();


                var entityResponse = await PlayFabAuthenticationAPI.GetEntityTokenAsync(new GetEntityTokenRequest());


                matchResult = await PlayFabMultiplayerAPI.GetMatchAsync(new GetMatchRequest()
                {
                    QueueName = "1v1",
                    MatchId = GameserverSDK.SessionIdKey,
                    ReturnMemberAttributes = true
                });
            });


            task.Wait();


            if (matchResult.Error != null)
            {
                GameserverSDK.LogMessage($"Could not get match: {matchResult.Error.GenerateErrorReport()}");
                return;
            }

0 Likes 0 ·
Show more comments
Mathieu Deletrain avatar image Mathieu Deletrain commented ·

Hi !

I'm having the same issue and wanted to try your solution, but according to this post, the server currently has no way to retrieve the queue name from which the match maker spawned it, and that prevent from calling the GetMatch API.

How would you work around that ?

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Mathieu Deletrain commented ·

Hi, sorry for the late response.

Yes, this feature is not supported for now, and we can see that you voted on that feature request, which helps us to prioritize our work, thanks for your feedback on this.

As a workaround, which may sounds dumb and brutal: you can iterate all possible Queue names when the number is quite small.

BTW, it's also recommended to ask a new question when having problems other than the original one so that we don't miss out hearing your voices:)

0 Likes 0 ·
Mathieu Deletrain avatar image Mathieu Deletrain Citrus Yan commented ·

Hi,

What I've done is pass the queue name in the start command. But that means a server can only be tied to a single queue. That will do the job for now but I hope we'll soon have ability to get queue name from GSDK :) ...


Thanks for your help !

1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.