Dedicated Server - How to handle save files?

Hello everyone,

I have a question in regard to server-side save files. I have read all relevant resources (i.e. WizardCell as well as that multiplayer compendium) but it seems no one is talking about how to manage data on the server.

I have created a simple save file subsystem, however, I am facing trouble connecting to the correct lifecycle hooks for the following:

  • Handling Player Data on Player Exit (i.e. position & rotation of pawn)
  • Saving All Data on Server Exit (i.e. Play-In-Editor stop / exit)

I am trying to use a combination of the GameModeBase::Logout function and data stored in the PlayerController, however, I cannot find the right hooks on the PlayerController to store the controlled pawn’s rotation / transform before they exit / logout from the game. I have tried all the following hooks to no avail:

  • AActor::OnNetCleanup ← Called before GameModeBase::Logout but GetPawn not available here
  • AActor::BeforeDestroy ← Called after GameModeBase::Logout

I do not want to resort to an external solution (i.e. SQL database) as I want the servers to be runnable on any machine, I do not care about cheating. I just wish to store some data on the server whenever a client disconnects as well as write the save file to disk when the server shuts down.