Facepunch / garrysmod-requests

Feature requests for Garry's Mod
83 stars 24 forks source link

Hook called before map is changed #1221

Open TomatoCo opened 5 years ago

TomatoCo commented 5 years ago

When the server changes maps due to the map command, changelevel, game.LoadNextMap(), or whatever, a OnMapChange or PreMapChange hook should be called, with two args. One for the method used (the examples above), and the other for the map that the server is changing to.

meepen commented 5 years ago

Shutdown is called, not sure why you would need the reason it changed maps, but having shutdown provide info about the shutdown would be nice

On Sat, Oct 13, 2018, 6:33 PM TomatoCo notifications@github.com wrote:

When the server changes maps due to the map command, changelevel, game.LoadNextMap(), or whatever, a OnMapChange or PreMapChange hook should be called, with two args. One for the method used (the examples above), and the other for the map that the server is changing to.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Facepunch/garrysmod-requests/issues/1221, or mute the thread https://github.com/notifications/unsubscribe-auth/AF5lSR7KS_6ADRUOEig3HCf7uivqujJ4ks5ukmoggaJpZM4Xa3Bi .

GitSparTV commented 4 years ago

Bump, useful, people are making their own implementations for making the same thing. Gmod can help them all by making its own hook or ShutDown parameter

robotboy655 commented 4 years ago

What would this achieve that Shutdown doesn't?

GitSparTV commented 4 years ago

It doesn't differ server shutdown and changelevel. I'm aware ShutDown is called when the map is about to be changed.

robotboy655 commented 4 years ago

Why does it matter if it is a changelevel or a full shutdown? What are you ever gonna do differently for a change level?

GitSparTV commented 4 years ago

for my addon stuff, I don't want the server to re-download and re-mount the startup addons on a map change - and right now there is no way of detecting whether this is an initial startup or a map change There are also other circumstances - for example, I have a script that paints the skybox on my space map - and when I change to this map specifically, I'd like to disable StormFox (which conflicts and has to be disabled pre-map change if you want to stop it overriding the sky paint)

changelevel doesn't recreate file system, only lua state and new map. ShutDown can't tell what exactly happens. Also there's no startup hook that can tell the same

viral32111 commented 4 years ago

Wishing this was a thing right now, is it really that hard to just run a seperate hook when changelevel is ran, or at the very least add an argument to ShutDown that specifies if it was a map change or server quit?

Andrew-Eathan commented 9 months ago

Why does it matter if it is a changelevel or a full shutdown? What are you ever gonna do differently for a change level?

chiming in to share a use case this would be useful for: discord chat relays i wrote a chat relay for my community and every time the server changes maps i can't tell if it's a shutdown or a changelevel, so it just says the server shut down, and then on startup it pings a role as if the server freshly booted up, despite it being a changelevel

it would be pretty useful to have an argument in the shutdown hook to take care of that, but i can see why it might not be a priority especially if implementing it is harder than changing a couple of lines