Although you are using raw c++ I will foolishly assume it works just about exactly the same.
In this example you can substitute “Event Handle Starting New Player” with your “EventPostLogin”. Event Handle Starting New Player is a better option for using seamless travel if in fact you wish to move around to different levels within the same game session on the server…
Off the true you will want to kick the player assuming you have too many clients. Off the false you will execute anything related to spawning. Once the player is kicked you would handle the player leaving from the “EventOnLogout” and decrement that variable there in the much the same way as when they entered. If you can write this in c++ its relatively simple.
If you are operating a true stand-alone dedicated server, the server map would already be open and running at the specified IP address of the machine its running on and will have a default game mode and session created at which point everything would be deterministic at that point from the game mode. There wouldn’t be a need to pass a “Number Of Players” variable because the game mode would already have that information for you and wouldn’t allow the client to change it directly anyway since its already running and existing only on the server itself.
If you required multiple differences in server maps that alternated and travelled between specific levels and game modes you would need to create another server map and packaged it accordingly with the correct connecting IP address on open level with a game mode that handled that game’s rules specifically. If you travelled with server travel to another level at that point you can switch game modes and have a different set of rules once you arrived via server travel.
For example:
-
Client wants to play a 6 v 6 team death match game on a dedicated server.
-
They select a 6 v 6 team death match map link/button inside perhaps the main menu level of the game that is not on the server. The button executes the “Open Level” at which point the IP address and port to that game will be specified on the Open Level and the player connects to the server and the server knows through the logic you created whether to allow the player in.
-
They arrive to find there is available space. The game plays out how you set the rules. Or there is no available slots and the player is graciously returned the main menu outside of the server on their local machine.
-
Player returns the main menu after leaving or being kicked out of the game and decides to play a 8 v 8 death match game at which point selects a different button for 8 v 8 deathmatch that opens level at a perhaps the same IP address, but an alternate port assuming yet another instance of the game is running on the same machine.
In what I’m describing here is essentially a game that operates in pieces of separately running “servers” on a particular machine or server. So your main menu or level menu is essentially a portal to other games outside of the main menu existing in another place in the actual world and you are merely connecting to existing games with predetermined player counts and rules.
If you are creating a session for LAN then this doesn’t really apply in the same way since you have a valid player controller and the client acts as the server, they can determine the number of players while creating a session and alternate to whatever game mode/level they wish with however many players by creating said session.
I apologize if this isn’t what you had in mind and there are far better experts out here that have much better knowledge on this subject, but as far as I’m aware when operating dedicated servers they are their own mind and once they are running separately from the local players machine or even on their machine they can only be connected to and manipulated through its own set of rules and only from within the game mode or through the game mode via the game state. So essentially “creating” a dedicated server game session would be equivalent to literally executing a binary from your file explorer on windows and opening a server application running in the background of your pc or server.
I have grappled with this situation for a while and there isn’t a lot of info regarding this on actual stand-alone dedicated servers and connecting to multiple different game types, but I have managed to make all this work like I have stated… Fortnite is apparently run in this same manner. Essentially a number of instances of stand-alone servers running on one machine or multiple machines on Amazon’s elastic IP instances being connected externally through a matchmaking system on a separate server that opens the IP to these external “games” that exist outside of the local players game.