Auto running serverside console commands once every map change/startup

What the title says. I need a list of commands to run once every time the server starts up or the map is changed. In this case it’s for the Atmos weather mod:

[lua]
atmos_weather_chance 100
atmos_weather_length 3600
atmos_startstorm
atmos_dnc_length 3600
atmos_dnc_settime 1
atmos_dnc_pause[/lua]

I would also need these to run in order.

I tried putting them in the server.cfg, and I tried putting a timer in a lua file in lua/autorun. The timer was probably wrong, as I do not know how to use lua at all even if a tutorial is sitting in front of me.

Here’s the attempt at a timer:

[lua]timer.create(“Atmoscommands”,1,1,function()
game.ConsoleCommand(“atmos_weather_chance”, “100”)
game.ConsoleCommand(“atmos_weather_length”, “3600”)
game.ConsoleCommand(“atmos_startstorm”)
game.ConsoleCommand(“atmos_dnc_length”, “3600”)
game.ConsoleCommand(“atmos_dnc_settime”, “1”)
game.ConsoleCommand(“atmos_dnc_pause”)
end)[/lua]

So what would I actually need to do this, and where would I put it?

game.ConsoleCommand only takes a single string argument, and needs a new line at the end
[lua]game.ConsoleCommand("atmos_weather_chance 100
")[/lua]

I believe you would want to hook into ‘Initialize’.
timer.Simple works a little better for something like this as well. This timer will only run once and then stop.



hook.Add( "Initialize", "AtmosWeatherCvars", function()
	timer.Simple(3, function()
		game.ConsoleCommand("atmos_weather_chance 100
")
		game.ConsoleCommand("atmos_weather_length 360
")
		game.ConsoleCommand("atmos_startstorm 
")
		game.ConsoleCommand("atmos_dnc_length 3600
")
		game.ConsoleCommand("atmos_dnc_settime 1
")
		game.ConsoleCommand("atmos_dnc_pause
")
	end)
end)


No promises it was done in browser and I’m not the coldest beer in the fridge.