Hook Change Level?

There’s any way to hook server’s change level event?

ShutDown?

The question is what are you trying to achieve there are 2 ways that I can think of:

  1. In case you want to detect if a trigger causes the changelevel then you could create a entity called trigger_changelevel and it would replace all existing triggers on the maps.
  2. Basically on each changelevel the lua environment will vanish and will call before doing so http://wiki.garrysmod.com/page/GM/ShutDown

Shutdown is server shutdown? Because I want to call a function before the map is changed, so I can record player’s time connected

GM:ShutDown is when the lua state is destroyed.

Edit:

I highly doubt it. ShutDown is when the lua state is successfully destroyed, which happens on a map change. Plus, if you didn’t destroy the lua state, then you’re bound to run into trouble with addons loaded when on a different map.

This also applies on shutdown/Crashes if I remember right - says the ULX log.

Isn’t it somehow possible to edit the function that changes the level, but in Lua enviorement, and make it call an hook? With that you could hook - which would be useless since you’d be able to directly put it in the function.

The ShutDown hook is called when the server shuts down or when the map changes. If the server crashes it is not able to call ShutDown

From previous use, it should be called on map change - might as well try it