GM:Shutdown()

When is this called?
Is this called when the server is starting to think of shutting down, or is about to drop?
How much time do you have once it’s called?
How much code can you call before the server shuts down interrupting your queries and corrupting your data?
Will the server exit before this hook has finished fucking about?
I want to know because I have a hook called every so often that tells all the various plugins and such to save all their data via sql.query, and sets off a timer cascade that does a bunch of processing for each player and then fires off a tmysql.query.
Obviously I want everything to save on shutdown, but will anything actually manage to save if I call this hook?
(Obviously the timer cascade would be a problem, but I can work around that)

This function is called before the server has shut down.

This isn’t called when it crashes though.

It’s called if the server is shutting down in a legitimate fashion, ie by stopping srcds, changing level and so on. Crashes aren’t accounted for with this.

I understood this much. I meant “at what part of the normal shutdown cycle is this hook called?”
As in, as soon as the ‘quit’ command has been issued and source is starting to close things up (I’ve found that can take up to a second or two) or just before the Lua environment is killed and if so, will said killing wait for Lua to finish doing things like returning threaded module callbacks and whatnot, or will it just grow impatient and end?

It waits for lua to finish first I believe (would seem daft not to).

I have uses this for saving alot of times and never found problems with it so yes it will work for saving your data

when the lua dll is about to shutdown, like changelevel, or you typed exit in the console, it executs it.
but when it crashes the hole engine stops so it wont tell the lua dll that its about to shutdown so it wont be called.

the best thing you can do is save data each 10-20 min just for the crashes, or if you got plugins that only need settings one time, then just save it when it changes else leave it alone.

It’ll be easier to execute the code to save every 5 minutes / 300 seconds or PlayerDisconnect so it will save there data when they disconnect!

yes, but when the server crashes, the players wil timeout and not get kicked or disconected
>:Ð

Yes but, at least there latest info gets saved before server crashes, to be precise if you do it when the server shuts down then your 99.9% of the clients info can be lost because crashes and they are gonna be angry to re earn it again, Crashes can happen any time so if you save every 5 minutes then you have that information safe and secured.

got my 3 servers running 24/7 and it crashes about once in a day becouse some fucktard gliching props outside the map
(2 props to a wall, physgun one and push the other one out of the map once its gone BOEM crash or 2 porps whit much force on it to glich in the wall)
trugh, i fixed all the crashes whit my uber DLL :smiley:

I said that I ran the update hook every so often, which is enough for me. I don’t need you to suggest timings for my update schedule.