• Hook Change Level?
    7 replies, posted
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 [URL]http://wiki.garrysmod.com/page/GM/ShutDown[/URL]
[QUOTE=NiandraLades;48613468]ShutDown?[/QUOTE] 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. [B]Edit:[/B] [QUOTE=whitestar;48614912]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.[/QUOTE] 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.
[QUOTE=stev_;48614231]GM:ShutDown is when the lua state is destroyed.[/QUOTE] 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
[QUOTE=Nicksf13;48614063]Shutdown is server shutdown? Because I want to call a function before the map is changed, so I can record player's time connected[/QUOTE] From previous use, it should be called on map change - might as well try it
Sorry, you need to Log In to post a reply to this thread.