WEBVTT

00:07.210 --> 00:08.200
Welcome back.

00:08.200 --> 00:13.840
Now, even though our game is programmed for multiplayer, our save game is single player.

00:13.840 --> 00:20.200
And for that reason, I'd like to just place a couple of safeguards in place for anyone who's launching

00:20.200 --> 00:26.620
this project up, brings it up in the Pi, and goes ahead and sets the number of players to two and

00:26.620 --> 00:27.730
presses play.

00:27.730 --> 00:35.020
And of course, this isn't going to be a problem unless we load up our single player solution for loading,

00:35.020 --> 00:35.620
right?

00:35.890 --> 00:42.580
I don't want anyone to be able to select a slot right here on the client and press play.

00:42.580 --> 00:48.460
I want to force that person to just play in single player mode.

00:48.460 --> 00:54.850
So for the select slot button, I'm going to prevent anything from happening as well as making the quit

00:54.850 --> 00:56.920
button here on a client.

00:56.920 --> 01:02.530
Quit the game because if I quit and go back to this menu and press play, then I'm going to see some

01:02.530 --> 01:04.210
information here again.

01:04.210 --> 01:05.650
So here's what I'm going to do.

01:05.650 --> 01:08.800
I'm going to go into my C plus plus project.

01:08.800 --> 01:15.880
I'm going to close all tabs, but I'm going to go to UI actually in the private folder into ViewModel,

01:15.880 --> 01:18.430
into MVVM load screen.

01:18.730 --> 01:24.970
So the first thing I'm going to look for here in MVVM load screen is load data.

01:25.390 --> 01:30.640
And on the client or a game mode isn't going to be valid.

01:31.150 --> 01:33.790
So I'm going to first place a check here.

01:33.790 --> 01:40.210
If not is valid or a game mode will return.

01:40.210 --> 01:47.380
In this case, the next thing I want to do is look for new slot button pressed, as I don't want to

01:47.380 --> 01:53.170
be able to make a new slot if or a game mode isn't valid here as well.

01:53.170 --> 02:01.630
So what I'm going to do is place another if check if not is valid or a game mode.

02:01.630 --> 02:06.340
And in this case I'd like to add an on screen debug message.

02:06.340 --> 02:07.960
I'm going to say G engine.

02:10.660 --> 02:17.680
Add on screen debug message I'll use one for the key, 15 seconds for the time for the color.

02:17.680 --> 02:20.530
Let's make this pretty magenta will do.

02:20.530 --> 02:24.100
And for the F string I'm going to say.

02:25.360 --> 02:29.140
Please switch to single player.

02:30.810 --> 02:37.260
So at least the user will know why it's not working and they'll be instructed how to make it work.

02:37.470 --> 02:38.940
And we'll return here.

02:39.390 --> 02:41.190
So let's see how this works.

02:44.830 --> 02:47.710
I'll go ahead and just go to the load menu.

02:48.040 --> 02:50.740
And first I'm going to try it with one player.

02:50.740 --> 02:54.940
Make sure we can enter a new name, create a new slot and play.

02:54.940 --> 02:56.620
Everything works fine.

02:58.980 --> 03:01.290
I can select an old slot and play that.

03:01.290 --> 03:03.090
Everything looks fine.

03:04.390 --> 03:07.210
Of course I'm going to have to fix that up, but that's cool.

03:07.630 --> 03:08.980
Things are working.

03:10.150 --> 03:13.900
Now I'm going to set the number of players to two and it looks like we're standalone.

03:13.900 --> 03:16.360
So I'm going to set it to play as listen server.

03:17.070 --> 03:18.960
And see what happens on the client.

03:18.990 --> 03:20.370
Now here's what happens.

03:20.370 --> 03:26.670
And even though I can click the plus, if I click new slot I see, please switch to single player so

03:26.670 --> 03:29.100
we can't click on a new slot.

03:29.130 --> 03:34.350
However, if we quit and then press play, then we're loading things up.

03:34.350 --> 03:39.030
So we need to make this quit button make us exit the game.

03:39.030 --> 03:40.020
That's what I'd like to do.

03:40.020 --> 03:43.170
So I'm going to go into my blueprints.

03:43.810 --> 03:49.930
Into UI load menu and open Wbhp load screen.

03:49.930 --> 03:52.960
I'm interested in my quit button here.

03:53.550 --> 03:54.870
So here's my quit button.

03:54.870 --> 04:01.320
What we're doing is we're opening a level, but I don't want to do that if we're on a client.

04:01.320 --> 04:04.440
So what I'm going to do is get the game mode.

04:05.000 --> 04:08.540
With get game mode and I'm going to check is valid here.

04:12.100 --> 04:13.690
And if it's valid.

04:13.690 --> 04:16.510
All right, we'll go ahead and open that level.

04:16.510 --> 04:19.960
If it's not valid, I'd like to quit the game.

04:20.320 --> 04:23.110
So we're going to call quit game.

04:24.120 --> 04:25.500
Simple as that.

04:25.740 --> 04:28.560
And with that, I'm going to press play.

04:28.650 --> 04:32.310
And on the client, if I quit, we exit the game.

04:32.400 --> 04:36.990
So now our single player save game solution is enforced.

04:36.990 --> 04:42.030
And if we set this to play as client well that's not going to work.

04:43.600 --> 04:49.810
We have to set this to play as either standalone or listen server with a single player.

04:51.840 --> 04:54.240
And then, of course, it'll work.

04:55.750 --> 04:56.680
Excellent.

04:56.680 --> 04:57.970
I'll see you soon.
