Hey guys. I’ve been playing Garry’s Mod for a while and have recently started my own server. I have a little bit of lua experience and know enough to keep the server running well. There is just one thing I cannot seem to figure out and that’s how to change the gamemode from one mode to another based on what map is coming up next.
I’ve tried using if/else statements to read the map that’s loaded and alter the gamemode based on that, but I don’t know if it’s just not working or if it’s not executing correctly. I have it saved in garrysmod/lua/autorun/server and this is what I have in it.
function gamemodes() if ( string.find( string.lower( game.GetMap() ), "bhop_" ) ) then RunConsoleCommand( "gamemode bhop" ) else ( RunConsoleCommand( "gamemode deathrun") end end)
I’m attempting to get the mapname and load the gamemode based on that, but I feel like this will execute after the map loads anyway so it won’t have any effect on the server until another map change. Can anyone help me out with this? I don’t want you to do it for me, I want you to help me.