So I currently have a stacked install (I.E I run a few servers out of 1 GMod install)
It all runs fine, and I’ve been doing that for about a year now. On the command line, I run servers and specify an extra .cfg file to execute. So for example, server 1 will look like this:
… -game garrysmod -port <port> +gamemode <gamemode> +map <map> +exec server_1.cfg
Server 2 will look like this:
… -game garrysmod -port <port> +gamemode <gamemode> +map <map> +exec server_2.cfg
server_x.cfg will specify things like hostname, for example.
Recently I wanted to add a custom convar to my servers, which would differ between them. So for example, in server_1.cfg I may have:
server_2.cfg I may have
I created an addon, which calls
Then I try to get the value of my_custom_cvar like so:
Which incorrectly returns “something_default” as I want it to return “something_here” or “something_else_here” as defined in server_x.cfg
Now, I notice that server.cfg gets called (a second time?) after the gamemode had loaded and the cvars have been defined by CreateConVar, however, any additional .cfgs I specified at command line do NOT, so my server_x.cfg files get executed BEFORE the convars are defined by the gamemode/addon. That means I get an error in the console: Unknown command “my_custom_cvar”, before the gamemode loads, which is understandable.
My question is, how do I go about solving this? Is there some way I can see a custom cvar I tried to set at the command line in my server_x.cfg? If not, is there a way to get which .cfg was executed at command line, so that I can manually call it? Bad practice, but at this point any solution would be appreciated. Alternatively, if you have any other solution, any help would be appreciated. It’s one of those things where someone will come along and say “why don’t you just do X?” and I’ll end up kicking myself. Well, I’m hoping so anyway.
Thanks very much in advance!