sourcemod
sourcemod copied to clipboard
Add OnServerHibernate() and OnServerHibernate_Post() forwards
Hello,
Can some implement a forward to be notified when server goes on hibernate state please?
Cases for exemple:
- setup plugins/scripts just before hibernate
- make sql queries just before the sleep (because we need to use the main thread before it sleep, otherwise it can cause troubles)
- others actions that must be done when the server goes in this state
2 forwards like OnServerHibernate() and OnServerHibernate_Post() will be very nice !
Why not just use the last client disconnecting from the server?
I'm not sure any forward here would be useful for executing further async work, as you'll have no way to keep the server ticking until your results are processed.
Why not just use the last client disconnecting from the server?
That was my first idea but there is 2 problems:
1st: When on map start, no way to detect this state if server go to hibernate state directly after the mapstart 2nd: When server change map, all players go throught disconnect, its not a hibernate state and no way to filter this case (mapend arrive after players disconnections).
Wow! Great idea.
I'm not sure any forward here would be useful for executing further async work, as you'll have no way to keep the server ticking until your results are processed.
But you can assign this to the system in the game thread and an asynchronous response when the server is unfrozen in theory.
2nd: When server change map, all players go throught disconnect, its not a hibernate state and no way to filter this case (mapend arrive after players disconnections).
That's not correct. You are able to filter really disconnected players using "player_disconnect" game event. Those raised only for player who disconnected themselves. Only OnClientDisconnect() forward is affected by both cases. Anyway, for the plugin to process successfully, you have to temporarily switch the state of "sv_hibernate_when_empty" ConVar. You can see an example in this plugin.