I used CreateConVar but I can't edit it by server.cfg

Excuse me for any grammatical errors.

In my script, I created a ConVar like this:

local my_convar= CreateConVar(“convar_example”, “3”)

It works fine into the script, but if I go to the server.cfg and I type:
convar_example 6
Then I don’t edit anything, the convar doesn’t change.

Somebody can help me?


The cfg is probably executing before the convar is created.

For what it’s worth, Predda, I understand your problem which Moku also said. However, I don’t know of a solution. Others are probably on the same boat.

If you’re creating the cvar in a hook or some event rather than creating it the moment the file is loaded, or the file itself isn’t being loaded automatically, that may possibly be the cause. You could try moving the convar somewhere where it gets created as soon as the server starts up and loads the lua files (assuming this is an addon).

If that’s not the case, you could try what’s below. Otherwise, I’m not really sure what could be the issue.

You could try archiving the ConVar, that way it gets stored into the server.vdf file (holds convar values between sessions so they can be reloaded and not lost) and presumably would let you modify it via server.cfg.

CreateConVar( "convar_example", "3", { FCVAR_ARCHIVE } )

I don’t think I’ve personally experienced the issue you have, so I don’t know if this is the best solution, but it’s something to try.
You may to need shut down the server cleanly (‘exit’) for the convar value to get stored into server.vdf after making it archived.

The convar is out side of any function!
I’m trying to change the convar type (like you said).

[editline]16th September 2016[/editline]

No… It doesn’t work!

Are you aware that Archiving is used to save convars more than being able to run them via cfg?