Ulysses
General => Developers Corner => Topic started by: PAL-18 on October 31, 2014, 01:24:20 PM
-
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?
-
Hello there,
have you actually created the convars using CreateConVar (http://wiki.garrysmod.com/page/Global/CreateConVar)?
You can also define convars in your gamemode.txt:
"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"
}
}
Avoid
-
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.
-
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:
timer.Simple(0.1, function()
RunConsoleCommand("sk_barnacle_health", "500")
end)
-
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.
-
As I've written in my post earlier, simply put this into your Initialize (http://wiki.garrysmod.com/page/GM/Initialize) hook.
You can either overwrite the hook or simply add to it. :)
-
Oh.
I didn't notice; but i did add it to my GM:Initialize hook. It didn't work.
Here's part of what it looks like:
function GM:Initialize()
MsgN("Trouble In Terrorist Town gamemode initializing...")
ShowVersion()
-- Force friendly fire to be enabled. If it is off, we do not get lag compensation.
RunConsoleCommand("mp_friendlyfire", "1")
-- NPC Cvars
timer.Simple(0.1, function()
RunConsoleCommand("sk_barnacle_health", "1000")
RunConsoleCommand("sk_antlionguard_health", "300")
RunConsoleCommand("sk_antlionguard_dmg_charge", "7")
RunConsoleCommand("sk_antlionguard_dmg_shove", "2")
RunConsoleCommand("sk_antlion_health", "150")
RunConsoleCommand("sk_antlion_jump_damage", "5")
RunConsoleCommand("sk_antlion_swipe_damage", "1")
end)
-
Sooo ... any idea why it doesnt work?
-
Does it give an error?
-
Nope, no errors. It just doesn't seem to accept the cvar.
Oddly if i do the cvar through rcon remotely or ulx rcon it runs fine.
-
I managed to get it working myself by moving the timer from GM:Initialize function to BeginRound function.
Thanks for all the help :D