Welcome back.
Now, even though our game is programmed for multiplayer, our save game is single player.
And for that reason, I'd like to just place a couple of safeguards in place for anyone who's launching
this project up, brings it up in the Pi, and goes ahead and sets the number of players to two and
presses play.
And of course, this isn't going to be a problem unless we load up our single player solution for loading,
right?
I don't want anyone to be able to select a slot right here on the client and press play.
I want to force that person to just play in single player mode.
So for the select slot button, I'm going to prevent anything from happening as well as making the quit
button here on a client.
Quit the game because if I quit and go back to this menu and press play, then I'm going to see some
information here again.
So here's what I'm going to do.
I'm going to go into my C plus plus project.
I'm going to close all tabs, but I'm going to go to UI actually in the private folder into ViewModel,
into MVVM load screen.
So the first thing I'm going to look for here in MVVM load screen is load data.
And on the client or a game mode isn't going to be valid.
So I'm going to first place a check here.
If not is valid or a game mode will return.
In this case, the next thing I want to do is look for new slot button pressed, as I don't want to
be able to make a new slot if or a game mode isn't valid here as well.
So what I'm going to do is place another if check if not is valid or a game mode.
And in this case I'd like to add an on screen debug message.
I'm going to say G engine.
Add on screen debug message I'll use one for the key, 15 seconds for the time for the color.
Let's make this pretty magenta will do.
And for the F string I'm going to say.
Please switch to single player.
So at least the user will know why it's not working and they'll be instructed how to make it work.
And we'll return here.
So let's see how this works.
I'll go ahead and just go to the load menu.
And first I'm going to try it with one player.
Make sure we can enter a new name, create a new slot and play.
Everything works fine.
I can select an old slot and play that.
Everything looks fine.
Of course I'm going to have to fix that up, but that's cool.
Things are working.
Now I'm going to set the number of players to two and it looks like we're standalone.
So I'm going to set it to play as listen server.
And see what happens on the client.
Now here's what happens.
And even though I can click the plus, if I click new slot I see, please switch to single player so
we can't click on a new slot.
However, if we quit and then press play, then we're loading things up.
So we need to make this quit button make us exit the game.
That's what I'd like to do.
So I'm going to go into my blueprints.
Into UI load menu and open Wbhp load screen.
I'm interested in my quit button here.
So here's my quit button.
What we're doing is we're opening a level, but I don't want to do that if we're on a client.
So what I'm going to do is get the game mode.
With get game mode and I'm going to check is valid here.
And if it's valid.
All right, we'll go ahead and open that level.
If it's not valid, I'd like to quit the game.
So we're going to call quit game.
Simple as that.
And with that, I'm going to press play.
And on the client, if I quit, we exit the game.
So now our single player save game solution is enforced.
And if we set this to play as client well that's not going to work.
We have to set this to play as either standalone or listen server with a single player.
And then, of course, it'll work.
Excellent.
I'll see you soon.