BeamMP-Server icon indicating copy to clipboard operation
BeamMP-Server copied to clipboard

onShudownReceived ()

Open emlodnaor opened this issue 1 year ago • 4 comments

Is your feature request related to a problem? Please describe. I need to store information before the server shuts down, and I need to do it before players are kicked, so that information I need to store is still available

Describe the solution you'd like once the server receive a shutdown instruction from anywhere, as it's first step it should trigger onShudownReceived(), time needs to be given to allow information to be stored to disk etc, maybe wait for all onShudownReceived functions to return, or somehow allow them to set a delay for the rest of the shutdown?

Describe alternatives you've considered I could use a timer to store the information every now and then, but it feels dirty, and would never be perfect a onPreKick might also do the trick

emlodnaor avatar Sep 26 '24 14:09 emlodnaor

Im pretty sure this event already exists as onShutdown is described to be called when "Triggered when the server shuts down. Currently happens after all players were kicked.". But this is obviously called after the players where kicked, meaning you can save the data everytime a player is diconnected?

OfficialLambdax avatar Sep 27 '24 12:09 OfficialLambdax

it does not seem to me that onPlayerDisconnect is triggered on server exit when the server kicks the players, but I could be wrong, I will do more testing later and report back...

emlodnaor avatar Sep 27 '24 12:09 emlodnaor

You are probably storing data in tables of your script state right? Meaning that once onShutdown has been called, you can just save these tables, the players are still in there if onPlayerDisconnect isnt called. Sure the server may kicked them already, meaning you cant send them events, but data would still be there

OfficialLambdax avatar Sep 27 '24 12:09 OfficialLambdax

yes and no, I'm trying to avoid any sort of timer, and make it as light as possible, so I don't continuously update the tables, only on disconnect, and then I was planning to also do it when the server is shut down... so that's why I made this issue... but I can find a workaround, and it's not critical...

emlodnaor avatar Sep 27 '24 16:09 emlodnaor