Loading a local save and replicating the results to all clients?

Hi guys, I’m currently I’m currently struggling to work out how to load a local save file and replicating the results to all other clients. To be more specific I have built a character customisation system which saves all information to a local file to be loaded when the players pawn is spawned, I am able to get the results loaded on to the character in single player fine, however I am a massive noob when it comes to multiplayer. So really the area that I need help with is how I would go about loading the local file to the players character and then replicate this to all other clients so that they see all of the customisations the other players have made. The customisation is added to the characters at spawn so I believe this would need some sort of RPC. I’ve tried creating a run on server custom event to the singleplayer script but that didn’t work. If anyone knows where I’m going wrong it would be great if you could let me know :smiley:

Thanks.

First set all the properties of your Custom Character BP that your local file sets to be replicated. Then create a Custom Event called “Set Custom Character Settings” in your Custom Character BP with Replicates set to “Run on Server” and “Reliable” checked. Add all of the properties in your local file as Inputs to the “Set Custom Character Settings” Custom Event. When you load the file on the client, call the “Set Custom Character Settings” custom event and send in the inputs. The properties will be set on the server and then replicate back to all the clients automatically.

If you have any questions or need more detail, let me know.

Thanks for the quick response Dartanlla, that method definitely gave me better results than I’ve been having and I was finally able to see some customisation on other pawns. The only problem is that on the local players instance all the pawns have his customisation. This happens with all clients. Am I going wrong somewhere because the method you suggested seemed like the right way to to this?

Thanks again :smiley:

Edit: Here is a screenshot as I’m not good at explaining :slight_smile:

Ok, you are really close to getting it working. So when you call an RPC on a character BP and it replicates settings back to all clients it only updates that one character, not all characters like you are seeing. What this means is that your RPC call must be getting called for each character instead of just the one you want to change. Try putting a breakpoint on the RPC call BP node to see why you are calling it for all characters instead of just the one.

Okay since I can’t test in editor because of steams subsystem I added a print when the RPC is called to see if it was being called a third time, turns out it is D: and I think I had the same problem the other day; since this is a listen server and I’m a noob I can’t seem to figure out how to determine between the server its self and the client attached to the server as the client counts as authority? Correct me if I’m wrong (Because I probably am) but it seems like the server is calling it as well as the two clients?

Although I may have set up the character BP all wrong, should I be loading the save within the character pawn or the Player controller?

Really appreciate the help! :slight_smile:

Yes, it sounds like it is being called in more places than it should be.

Are you using dedicated server? I have only done multiplayer networking with dedicated server checked in the editor. I have not worked with the Steam subsystem. Even if you don’t use a dedicated server, one client is still the server and you can use the Has Authority node to check.

One of the main concepts needed to understand networking is to realize which BP’s are loaded on which clients. So in a two player setup, each client has every other client’s Character BP as well as their own, but not every other client’s PlayerContoller. So you may try calling the Characters RPC to load the settings from the PlayerContoller. This will update only the one character on the Server and then only replicate those settings to that one Character on all clients.

If that doesn’t work and you want to post some screenshots of your RPC event and where you call it, I can take a look.

No I’m using a listen server unfortunately. Well whenever I use the on authority switch the the authority seems to always be client 1? I’m probably using it wrong? Ah that helps to know, how about the game instance does everyone share one in a multiplayer situation?

Okay so I tried a few different methods along the advice you gave me and I feel like I’m really close. Currently client 1/listen server sees everything he should, however client 2 doesn’t see anything change on client 1/listen server? Screenshot is easier :smiley: Left is Client 1

Here is the BP so far :slight_smile:

It is hard to tell what all those functions do, but it seems more complex than what I was expecting to see. I was only expecting to see a call to a Run On Server function that passes the charcter data and then a function that uses that character data to set some variables. If visible things need to happen on the client when the settings are changed (like loading a new character model) you may need to change your variable replication to Rep Notify to fire a function on the client when the setting value xhanges.

So I ended up using a replicated variable; inside the function I put the function that adds the customisation to the character, and it works! :smiley:

Thanks for the help Dartanalla!

You have no idea how much i love u right now

I’d really like to see the blueprint. I’m having the same issue. Server has and displays the correct version for self and clients. Clients just see the base model

I have found that even when I set replicated variables on the server copy of an actor, the changes don’t show up on the client copy of the actor, and I have to do a MultiCast. So I have lots of multicasts in my BP code.

Seems like it shouldn’t be that way…

Multicasts are quite dangerous and are probably the biggest network game programming mistake most UE4 developers make. The main issue with multicast is that they are temporal and do not permanently change the state of the game. If you watch the networking tutorial Epic made, they warn about this and show an example where a player outside the replication range will get out of synch if you use multicasts (the treasure chest opening example). Personally I only use multicast for temporary effects that are not important to the gameplay, such as very short (2 seconds or less) sounds and effects. If you need to change the state of your game, you will rant to use replicated vars or replicated vars with notify. A replicated var with notify is very similar to a multicast, except it permanently changes the state of the game and will not break when new users login or when players move from one portion of the map to another. Multicasts will break when a new user logs in to the game if they are being used to change the game state.

If your replicated vars are not replicating from the server to the clients, then it means your not setting them on the server or you are setting them on the server and quickly setting the values back before they can replicate. If the values on the server are supposed to be modified based on client input, the correct pattern is to RPC (Run at Server) the value from the client to server, set the value on the replicated var on the server and then let it replicate to all clients while optionally using an on rep notify if you need to run specific code on each client when a value changes (similar to how a multicast works).

Thank you for clarifying that - I’ve been struggling to get this to work any way I can, even if it means using those dirty multicasts.This is probably why when a new player joins the game, the other players’ tanks don’t have the color and name they chose before joining, which through a client-to-server RPC they signaled should be applied to their tank.

im having a similar issue im making a game where players can place stuff in a map i can get that stuff to saved to that persons computer but i want a client to join map and be able to see what that person has placed