Jump to content

Server Event: OnServerShuttingDown


Konijima

Recommended Posts

Hello it's me yet again,

Some mods require to save files or data into files that are kept into memory.

The ability to save that data when ever the server is going to shutdown would be a blessing.

Suggestion

Adding a server event named 'OnServerShuttingDown' that allow server mods to do a finalization work when the server is shutting down.

 

Result

Saving files and data when the server is shutting down.

 

Link to comment
Share on other sites

15 minutes ago, EnigmaGrey said:

Wouldn't that be the OnSave event?

 

Always call save before quit so that the game has time to complete it's save.


OnSave seem to be only a client sided event after looking at the source.

Added this into a server script file.
Screenshot_2.png.545f73cd7981433721b9f3f60a5be8c0.png

Called `save` and `quit` and no print.
Screenshot_1.png.64a570c8ba7fd6d309e08db69261a202.png

Link to comment
Share on other sites

So now that I think about it.

If adding a OnServerSave method, could probably get a param that specify if the shutdown signal has been given.
Would probably be good to trigger that event before the saving of the GlobalModData so that we can still change stuff in it.

local function onServerSave(isShuttingDown)
	if isShuttingDown then
		-- do something before saving only if shutting down
	end

	-- save stuff
end
Events.OnServerSave.Add(onServerSave);

 

Edited by Konijima
Adding specification.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...