According to documentation: The GameMode object only exists on the server. It generally stores information related to the game that clients do not need to know explicitly. For example, if a game has special rules like “rocket launchers only”, the clients may not need to know this rule, but when randomly spawning weapons around the map, the server needs to know to pick only from the “rocket launcher” category.
Step 1 : Create Gamemode, Create Interface, Create reference to Gamemode.
Set your GameMode in your level.
Note : If you are following along with the different parts, you already made the gamemode at step 1 of part 6
I want to store the playerinfo of each connected player in the gamemode and want te be able to print all connected players to all clients. The GameMode knows which players are connected.
The problem is that the menu (widget) lives only on the clients and the gamemode lives only on the server. So I use the PlayerController (lives on both server and client) to communicatie between menu and gamemode.
Step 2 Blueprints GameMode
Add PrintConnectedPlayersGM to interface gamemode.
Add Event OnpostLogin in gamemode. Create var Connected Players.
Create array ConnectedPlayersInfo and fill with playerinfo of each connected controller.
Add Event OnLogout.
Add Event PrintConnectedPlayersGM which will print the player info on server and clients.
Note: The ConnectedPlayers array is of type : Player Controller Object references! Turns out this is not my FD_PlayerController that is why you see the Cast to FD_PlayerController node.
Note: In part 6, step 3 the PlayerInfo from the GameInstance is copied to the PlayerController.
Note: PrintConnectedPlayersPC (prints on the clients) is discussed in the next step 3. player
Step 3 : Blueprints PlayerController
Event PrintConnectedPlayersPC (runs on Owning Client) prints the playerinfo of all connected players on the owning client
Event RunonServerGM (Run on server) which calls the PrintConnectedPlayersGM which is defined on the GameMode
Step 4 : MainMenu
Add button PrintConnectedPlayers to menu
Video showing the result step 1 to 4