• ConVars: How do they work?
    4 replies, posted
Hello again my friends. I have one question about ConVars: how do they work? I happened to make ConVars using [URL="http://wiki.garrysmod.com/page/ConVars"]this[/URL] but what now? Isn't there anyway to actually make them do something? Thank you.
You can use them to toggle parts of your script on and off, and use them to adjust settings for different crap in your script. For instance, cvars like cl_weaponcolor and cl_playercolor are used to adjust your physgun and character colors. Other cvars like sv_allowcslua are toggles that turn on and off the ability to use lua scripts. You can also assign strings to cvars, something I use to customise my disconnect message.
Yes, but how do I make them so if they are set to "true" they do something?
For example, in your script you could have something like this: [CODE]local function functionname() if GetConVar("convarname"):GetInt() == 1 then -- Checking if the ConVar is 1 then ... -- code here end end hook.Add( "Think", "desc", functionname ) -- You can use which ever hook you like. (Think could be used to continuously check if the Convar is 1.) [/CODE]
Well actually I thought of that afther my second post on the thread. And I don't need that anymore, I made this differently, but thanks for telling me anyway, and sorry for wasting your time.
Sorry, you need to Log In to post a reply to this thread.