CreateClientConVar Not Working

I am trying to make something only happen when a console command is set to 0. Great, it works.
This is my autorun file.
[lua]if !ConVarExists(“my_command”) then
CreateClientConVar(“my_command”, ‘0’, true, false)
And to make it work, in my ent lua I have
[lua]if GetConVarNumber(“my_command”) == 0 then[/lua]
Great, it works like a charm, for me…
When I updated the workshop item, nobody had the console command, so they didn’t have an option to toggle the feature, only I did.
I included the autorun file, and the people restarted their games multiple times without any luck.
So why is it that only I get the command? This could be really obvious, but either way, I could use a hand here :tinfoil:

Nothing? :open_mouth:


Tried it, didn’t work :blush:

What way did you use it

[lua]GetConVar(“my_command”):GetBool() == 1 then
–stuff here
–more stuff here[/lua]
Gave me the same result with the “my_command 1” as “my_command 0”
A friend told me to do this :stuck_out_tongue:

GetBool will return a bool - it won’t be equal to 1 or 0.

Just do

if GetConVar( "my_command" ):GetBool( ) then

Or, since CreateClientConVar returns a convar object, do this:

my_command = CreateClientConVar( "my_command", "initial value" )

if my_command:GetBool( ) then

I’m not fully looking for an alternative, as I am to why the command doesn’t work for others.
I mean it works fine for me, but if I send the download/workshop link to someone else, and they goto the console, the command doesn’t work. Its only me.

You’ve been provided with an alternative, nobody here is obliged to help you and won’t want to help if you’re going to be stubborn.

I didn’t mean to sound “stubborn”.
Thats not the point, I’m just wondering if the alternative will fix the problem or not. My code works for me, but nobody else. If the alternative works, thats great. It still wouldn’t hurt to learn the original problem.

It may be worth downloading a copy of your addon from the workshop and using gmad to ensure the workshop version actually contains your updated code.

It may sound pointless, but I recently had to update a workshop addon of mine because the previous update somehow didn’t actually push the updates. That or I somehow didn’t move my updates into the gmad addon prior to updating it.

Anyway, this sounds like a user error and not something Lua-wise, so it’s worth at least looking into if you haven’t already. I hope you find the problem soon.

Thats a good idea, will give it a shot. Thanks!

So that wasn’t the problem, but that inspired me to re-upload the update separately. I then removed the developer folder from my addons location that way the game would have no way to know about the console commands, unless it was actually from the workshop. I had my friend test the separate workshop item, and he got the commands, so I re-uploaded the update on to the actual addon, and it worked this time. I KNOW the update went through last time, but for some reason the results have changed it worked! I’m not sure if this is a fault on my end but whatever it is, thanks for the idea :dance: