Creating and Adding Lua Hooks to Server Execution

So I run a server, and I’m trying to make it so that whenever two rounds in the gamemode have passed (zombie survival), the mapvote menu is opened.
As I’m new to Lua, I don’t have a very firm grasp on how it works. I can read the language fine, but I don’t really know how to write it, or how to execute it.

I understand what hooks are, although I think compatibility between Zombie Survival and the mapvote system I’m using may be questionable.

From the ZS Hooks and Configs file:

The hook I’m sure I need to use:

And the ReadMe from the mapvote system I’m using: (excl Mapvote)

I’m not sure what to script exactly, or where to put the finished script so it can run.

I’m at a loss here. If anyone could help me, that’d be greatly appreciated.

First of all, nice job picking out the relevant parts of the documentation. You’re already quite a bit farther than most people who post here asking for help. (Dunno about the nazi stuff on your profile though).

Anyway, here’s some knowledge:

  • Any scripts inside the folder garrysmod/lua/autorun/server/ are ran automatically on the server (which is where your mapvote addon is)
  • Judging by the documentation and the sv_compat file, you should just need to create a hook for the gamemode’s LoadNextMap function. That function will then be called at the end of the game and is where you should put your code to start the map vote.
  • Reading the code for the map vote addon, it seems that it will automatically change the map after the vote has finished, so you won’t need to worry about changing the level yourself.

Here’s where you could stop reading and try to implement it yourself. If you fail, here’s code that should work.

– this file should be placed in lua/autorun/server/ so that it is ran
– on the server automatically.

– register a callback for the Zombie Survival LoadNextMap hook
hook.Add(“LoadNextMap”, “MapVote_ZombieSurvival”, function()
– start the map vote by calling the map vote addon’s Start function
– block the Zombie Survival default map change code
return true

Heyyyy it worked! Thanks man!