question

cooltom2013 avatar image
cooltom2013 asked

How does player information reach the server when matchmaking?

With UE4, when connecting to a playfab matchmaking server, how would I obtain data about the players that are expected to join? So that I could place them on the right teams, and retrieve their account data?

Player DatadataMatchmaking
10 |1200

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

Citrus Yan avatar image
Citrus Yan answered

Are you using PlayFab Matchmaking along with PlayFab Mutiplayer Servers? In that case, if you integrated Matchmaking with PlayFab Multiplayer Servers, a server instance will spin up with the following information passed into it when a match is found:

  • SessionId - The SessionId for the server will be equal to the MatchId for the match.
  • InitialPlayers - This value is set to the list of members in the match. The list of players can be read in the game by using the GSDK.
  • PreferredRegions - This field is set to the RegionPreferences field from the match. The game server service will choose an appropriate region for the server from this list.

https://docs.microsoft.com/en-us/gaming/playfab/features/multiplayer/matchmaking/multiplayer-servers#information-passed-to-the-game-server

The IntialPlayers field represents a list of players in a match and is automatically passed to the server instance, you can use GameserverSDK.GetInitialPlayers() to get such info and therefore use that to obtain data about the players.

Or, if you didn’t integrate Matchmaking with PlayFab Multiplayer Servers and manually calls RequestMultiplayerServer to request servers instead, you may specify the InitialPlayer field in the body so that it can be passed to the game server for later use.

Or, if you doesn’t use PlayFab Multiplayer Servers but uses external server hosting instead, you may need to manually pass the matched players’ info to the server for later use.

2 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.

starkgaminginc avatar image starkgaminginc commented ·

Update: I've found a solution and I will update in general discussion shortly

For the SessionID it mentioned it will be equal to the MatchID for the match. I am on UE4 as well and I'm wondering how to specifically make a call to get the MatchID/SessionID when the server starts up. I can certainly have the first players that join RPC that information to the server but I'd prefer a more server-oriented logic.

I'm using both Playfab Matchmaking and the PlayFab Multiplayer Servers.

In the legacy server environment this information was passed to the command line which was actually very useful, is there anyway to add the SessionID to the command line for the new servers?

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan starkgaminginc commented ·

When "Integrating with PlayFab Multiplayer Servers" is enabled, SessionId will be passed to the server:

https://docs.microsoft.com/en-us/gaming/playfab/features/multiplayer/matchmaking/multiplayer-servers#information-passed-to-the-game-server

You can use GSDK to retrieve it:

https://docs.microsoft.com/en-us/gaming/playfab/features/multiplayer/servers/integrating-game-servers-with-gsdk#getting-configuration-settings-within-your-game-server

BTW, you can create a new thread next time in case sometimes we may miss answered questions.

0 Likes 0 ·
element808 avatar image
element808 answered

The way we did it was to keep all persistent player data in our game instance (since it acts like a singleton)..so things like username, level, clothing equipped, etc are stored here in a struct...then we can pass this struct up to the server within the PlayerState (via RPC). You can also use the PlayerState to hold non-persistent variables for the player such as assigned team, and score, or whatever you want. These all need to be done via RPC.

Also, keep in mind the Game Mode is only accessible to the dedicated server (or listen server), and the Game State is used for the main flow of the game or things like assigning teams to each player state. The Game State has an array of Player States you can access.

10 |1200

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

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.