General > Developers Corner
Setting Engine Cvars?
PAL-18:
I have a bunch of engine cvars im trying to set to custom valid values (sk_barnacle_health, etc.) and i'm unable to get them to set. In server.cfg it isin't applying and they even fail when added to init.lua in the gamemode.
I've tried the following code:
RunConsoleCommand("sk_barnacle_health", "1000")
Any idea how i can get it to apply?
Avoid:
Hello there,
have you actually created the convars using CreateConVar?
You can also define convars in your gamemode.txt:
--- Code: --- "settings"
{
1
{
"name" "sk_maxfrags"
"text" "Max Frags"
"help" "The maxiumum number of frags before a map change"
"type" "Numeric"
"default" "20"
}
2
{
"name" "sk_grenades"
"text" "Allow Grenades"
"help" "If enabled ) then grenades are enabled"
"type" "CheckBox"
"default" "1"
}
}
--- End code ---
Avoid
PAL-18:
They aren't custom cvars though. They're cvars common to the SRCDS engine (they work in Gmod too).
I just tried that and it didnt work either.
Avoid:
Ah, I see.
Sorry I didn't know such a convar existed! :')
Use a timer when setting the convar in the Initialize hook and it worked fine on my end:
--- Code: --- timer.Simple(0.1, function()
RunConsoleCommand("sk_barnacle_health", "500")
end)
--- End code ---
PAL-18:
Do you have the full code you used to get it to work? I tried adding that timer to several places and i couldnt get it working.
Navigation
[0] Message Index
[#] Next page
Go to full version