Download

Multiplayer Questions (Lobby, Dedicated Server)

Hi Exi thanks for this it’s really helpfull. I just got one question though. For testing purposes I have my game set up to host and play games in a LAN like in you’re videos. So I can work on gameplay and other stuff

Eventually though I would like to play it via a hosted dedicated server . Would I have to completely rewrite the code to make it work? Or is it just the matchmaking stuff that would have to change and if so any idea where I would start ??

Thanks and awesome work

If we leave the dedicated server aside (there are tutorials on how to finally build and package one) you will just need to rethink specific parts of the multiplayer
code.

For example: In the Project i posted, the Server is 100% a client, which means we need to spawn the UI for him. If this would be a Dedicated Server, we don’t
want it to spawn the UI. So you need to filter the Dedicated Server with “Switch Has Authority” and such things and only do Client stuff really on the clients.

A dedicated Server has nothing to do with LAN or no LAN. It is just that the Server is a authority without an actual visual part. He will do the same thing
as the listen server, but you will want to NOT perform client actions on him.

I know how to package and set the server up. And I’m programming using the network authority switches an doing important stuff server side and client stuff client side. I just meant like the game play and stuff didn’t wanna spend ages getting it good only for it not to work later.

It’s just the Matchmaking is what confusing me though cos like on LAN you use the join session nodes etc and it automatically shows you the host etc but how does it work with a dedicated server because there is only one host/server
And also once the player are all on the server how would I get them actually into the games ?? Everything I can fin only goes into LAN match making .

Basically what I want is everybody joins my dedicated server where they can chat etc. then they hit play it takes them either to a new server or creates a game on the same server . Once they done they return the chat and can hit play again to begin the process .

Could I for instance have a folder with 10 copies of the same map eg game 1 , game 2 and when they click play simply spawn the players into the different maps??
Thanks

Ok so this has not really much to do with a dedicated server either. A listen host could “host” the same kind.

In LAN and Online (you need an OnlineSubsystem to retrieve ServerLists of Online Servers) the person who starts a server, may it be a listen or a dedicated server, will create a session.
If you have a listen host, he might do this by clicking on “Start Server” or “Host Game”. A dedicated server should do this on BeginPlay somewhere.

I haven’t looked into creating a Session with a Dedicated Server yet, but it should work the same. The Dedicated Server Creates a session which is either in LAN or Online (linked to OnlineSubsystem, for example Steam).
Then the Player gets the ServerList and joins the Server. Either you start the Game directly like i did in my example, or you have some kind of lobby, represented by an extra map, where you can chat.

Once the players are all there and you want to start the game, you can call “ServerTravel” to move the server to the actual GameMap, which will bring all Player along.
Either you do this with some logic automatically through the server, or you let the Clients have some way of telling the server to start the servertravel.
For example all pressed READY.

Is that what you wanted to know?

Yes I think so lol thanks for you’re help. I may just get my game fully functional and playable as LAN version and then pay or find someone later that can sort the matchmaking out.

But if I’m understanding so on my dedicated server at begin play I would (somehow???)
create or host a session

then on the client side they would (somehow??)
find and join this session .

Then once they hit play I would server travel them to the game map. Once play had finished sever travel them back to chat lobby map.

But how do I do the (somehows??) or is this what the online subsystem does??

I guess my only options are to try and incorporate steam or write my own. And the trouble is if I use steam how configurable is it. All matchmaking systems are geared towards shooter style death matches etc where as I need something completely different

An the other thing that confuses me is would I need a new server for each game and a main server for the lobby/chat or does one server support multiple maps??

So let’s say I have one server . All players log in and connect they are then loaded into the chat/lobby map .

But in order to server travel them into the game I would need to load the game map so if I only have one server wouldn’t this mean that everyone would get disconnected from the lobby/chat and then reconnected to the game map.

So let’s say there are 30 people total on my server . 10 click play and are split into two teams of 5 players.( game 1)

This leaves 20 ppl into lobby. Then 10 more players click ready . They are split into two teams of 5 and begin (game 2)

So I have 2 games going this leaves 10 ppl still in lobby.

Repeat the process etc

I moved our discussion, since it is more general and would flood the thread!
(: I guess you can understand that.

@Your Questions:

A dedicated server is not more than a player without visuals. So you might be able to check in the “Init” function of the GameInstance,
if the Game is a Dedicated Server. Like i said, i have not yet done this, but i guess this is how you do it. I wouldn’t think that much about
getting the dedicated server to work, because this is not that huge step.

In Blueprints, there are Session Nodes that handle this. The server might use the “CreateSession” and “Openlevel XYZ?listen” the same way
as the Client would as a listen host. At least it can’t be much harder.

There are also Nodes to Search and Join Sessions, as well as destroying them. They are a bit limited, but you can use the Plugin that someone
wrote here in the forums to extend the options. Or you use C++, i wrote a Wiki entry with the real basics on how to get a SessionGame running
in C++.

The questions regarding the OnlineSubsystem:

Unreal Engine 4 uses functions that are so called “Wrapper functions”. They are used to simplify the whole setup for you.
If you are not using a subsystem, you use the “NULL” subsystem, which is a placeholder to get LAN to work.
If your setup works here, it will eventually work with a subsystem, because UE4 will just use the matching Steam functions
instead of the placeholder ones. As soon as you add Steam to the Game and have a valid AppID, your game will just work
with Steam out of the box.

Back to the other questions:

ServerTravel is a function from C++ and can be used in Blueprints via the “Execute Console Command” line. You call it on the Server
with the map you want to travel to and the rest just works. (Should also work with Steam and other supported Subsystems).

I can only recommend you to use Steam if you need a Subsystem. Writing your own is not what you want to look for :smiley: (not that you can’t, but this
would take so much time and way more than Blueprints and C++).

Your last question with the multiple servers:

Yes, one Server can only have one Map Instance. If you ServerTravel, you move ALL clients.
If you want to have multiple dedicated Servers that start and are used for specific players groups, you will have to use C++.
This is not something that works in Blueprints, because you are simply missing the functions (and you need to write your own functions).

Yeah sorry didn’t mean to hijack you’re other thread lol.

Yeah I think I understand now so basically I’m screwed I either need to lean c++ and do it myself which could take years lol or find someone that knows what they are doing.

Maybe though I could have one server that everyone joins as the lobby then rather than server travelling them I could just get them to disconnect from that server and then get them to join the second server to play the game .

It seems stupid though it’s ok for small numbers but doing the math if I had 1k players all split into a game of 5vs5 I would need 100 servers to host them all surely this can’t be right

and then just having a server for 10 ppl at a time when it can support hundreds is a waste of resources .

I thought by having small team games it would be easier and use less resources and be easier but it seems like it’s the opposite way round

It’s not stupid, it’s the only way to achieve this. I’m currently facing the same Problem and i know that i need to work with middleware like “RakNet” to achieve this.
But i have no clue how to. A friend of mine already achieved this, but he’s not available right now.

What’s raknet got to do with it ?? All raknet for is to let you use msql database and do other communication stuff it has nothin to do with servers .

And I’m saying it’s stupid cos I don’t get it

so you’re telling me a game like smite that has just reached 10 mill players would have to have 1 million servers just to run it? On average a game server would be £40 a month so that’s £40 million a month in server costs . This can’t be right??

Lol no. RakNet would be used to manage the overall setup. It would keep track of Players on all your Server Instances and help moving them around.
So it would help you putting these 20 of 40 players on Server 1 over to Server 2. Without a core server(master server) handling the multiple server instances
you will be pretty lost i guess.

Who said that one game server costs 40$ a month? It costs so much if you get one for a specific game from a company, but smite has their own servers.
A 40$ Server that you might rent for CS:GO or what ever is placed on ONE Root server together with may 100 others.
Also Smite will have pretty big server farms that manage and hold different server instances and they might not directly use something like dedicated servers.
They will have their own technique for handling multiple instances.

You don’t need to use RakNet, it was just an example. You could write your own Master Server. RakNet is also not only for MySQL Databses, but works as some kind
of OnlineSubsystem that you can modify yourself.

I haven’t worked with this and i’m constantly thinking about changing a few parts of the UE4 Source code regarding replication for my project.
Don’t know if your project needs these multiple server or could work with such a work around.

Oh yeah I get what you mean now thought you was on about something else. I’ve done some further research and Apparently you can have multiple instances of the same game running on one psychical server as we’ll . So it is possible just gotta figure out how lol

So we still need to follow the old documents where you need to download the engine source and rebuild? If so, come on Epic, this is painfully stupid…