Can't Save to Server from Client?

Hello!

I’ve run into quite the snag, I have set up a saving system that is supposed to be run on a server and -not- on the client. It starts at EventBeginPlay and loops. However, it is only running for the server owner and not for the client. Does anyone know how to fix this? Thank you.

You told it to run only on the server because you only have an execution wire coming off the Authority pin and nothing coming out of the Remote pin (which is where it goes for remote clients connected tk the server)

Thank you for replying!

Executing it from both/remote doesn’t change it. It still only saves the server owner and not any of the clients. I’ve also tried making the initial event not replicated but running a RunOnServer variant for remote users, but this has not worked either

To make something happen on all machines you must make a Server RPC which then makes a Multicast RPC. Have you tried that?

Or you can just skip the server RPc and go straight to Multicast if the whole thing is always triggered from the server anyway.

What class has this code in it? it needs to be a connection-owning class such as Playercontroller in order to make a client to server RPC if that becomes necessary.

Everything you have here tells it to run the function on the server always - theres nothing telling it to run on any client.

I may have explained poorly; I am trying to get it to -only- save on the server, I don’t want to multicast because I don’t want the client to save anything to themself, only save it to the server. But what is happening is only the server owner saves, and all others for whatever reason do not save.

I was originally doing it in the character BP but after reading your comment I moved it to the player controller. It still does not appear to be working, however.

Oh! Sorry I misunderstood.
Well I think character will work just as well as Playercontroller because the ownership chain leads to the same connection.

I dont know the answer but i have an idea. I think maybe the way it works is this:
there is a difference between Authority and IsServer nodes. The former asks whether the owner of the connection is an ahthirity or remote role, but a remote client will still be a remote client player regardless of which machine is running the code.
IsServer asks which version of the world the code is running on, rather than the role of the actor’s owning connection (server’s world or client’s world)

So for this function if my theory is right, you could replace the Authority switch with an IsServer branch
OR
You could connect your SRV_GameSave directly to the MainGameInstance cast and maybe that will work.

I may be mistaken about how authority and remote works but its worth a try

The world transform variable inside of your controller isn’t set to replicate, which may be part of your issue, but if the event isn’t firing at all, I’m not entirely sure what the solution could be

I’ve tried replacing the SwitchHasAuthority with an IsServer branch, unfortunately it has not changed the result. I have, however, found out a bit more about the issue. The client doesn’t trigger the event until they pass the ‘ReadyToGo’ point (I had placed strings before this point and for whatever reason they don’t trigger until then) after which point the game -does- start creating a save, but for the hosting user. So if a client has gotten past the ‘ReadyToGo’ branch, and the server tries to load a save even if they never generated one, they will instead load the client’s save (technically the server’s save since it uses their ID as the FileName, but the information being saved comes from the client). Similarly, if multiple clients are on one server they will all generate a single save with the ID/FileName of the server host.

Also to reference what mm tendies said, I have now made all the variables related replicated, which has not changed the outcome.

I have replicated all the variables, if you have further thoughts please see my above post I made in reference to mightyenigma. Thank you!

So have you confirmed that on the client machines, GameSave event fires at all?

It -seems- to. For some reason it doesn’t print strings until the ‘Ready to Go’ branch is true, even though they are before it. After that point it does print strings after the branch, and it is firing but creating only a save for the server owner.

What part of the code triggers the first GameSave? Maybe the problem is there.

It starts on EventBeginPlay for the player controller. Essentially, it waits for a trigger that happens in the player character called ‘Ready To Go’, which happens at the end of the character’s EventBeginPlay.

I wanted to make a post with more detailed information in the hopes that it will shed some light on the issue.This good news is that after reading through your suggestions the main issue has been solved; the client can now save to the server. However, two new issues have arisen; Any client begining the save event generates a save event for the server, using the client’s data, and the client is unable to ever load a save. The server can load a save, but if a client begins their own save event it over-writes the server’s information.

The Character on event begin play casts references of Player Controller and Player state, then on a loop refreshes and sends information to specific player controller.

In the Player Controller, the event being run from the character saves the character’s variables to itself so they can be saved.

This is the improved (hopefully) save system based on your suggestions. It no longer creates a save on the client, AND it does make a save on the server which is great. However, for some reason it generates a save for the server regardless of wether or not the server has reached the ‘Ready To Go?’ state or not, and it fills in the information of the client playing. If there is more than one client as well as the server, it seems to randomly assign the save of one of the users to the server.

Lastly, and perhaps most importantly, the player can load their save from the HUD. If the server plays on their own without a client on the server, it works 100$ as intended; the server generates a save, and can then restart and load it. The client, however, is not able to load their save file even though it exists in the server’s save game directory. Specifically, it determines that the save is Invalid from the is valid check.

Since the issue has now completely changed and the primary issue that was the cause of this post was resolved, I’m going to list this post and answered and see if I can figure out loading. If not, I will make an post at a later point regarding the inability for a client to load a save from the server.

Since the issue has now completely changed and the primary issue that was the cause of this post was resolved, I’m going to list this post and answered and see if I can figure out loading. If not, I will make an post at a later point regarding the inability for a client to load a save from the server.