GetConVar (Clientside and Serverside)

Is it possible to use GetConVar on a Clientside code while getting a Serverside ConVar?

I know I can use network strings but I just wanted to know if there’s a simpler way

If the convar has the FCVAR_REPLICATED flag it will send its value to all clients.

Tried that, still couldn’t do GetConVar( “blah_blah_blah” ) on clientside.

Post the code.

Create the convar on the client as well. that should do the job.

] lua_run_cl print(GetConVar( "testcvar" ):GetInt())

[ERROR] LuaCmd:1: attempt to index a nil value
  1. unknown - LuaCmd:1

] lua_run_cl CreateConVar( "testcvar", 1, FCVAR_REPLICATED )
] lua_run_cl print(GetConVar( "testcvar" ):GetInt())

[editline]3rd August 2015[/editline]

You can keep on disagreeing… but creating the convar on the client as well works.

use: CreateConVar on server and client with FCVAR_REPLICATED.

Yeah can’t disagree with the results… would using CreateConVar() in the shared realm work well enough, for reducing lines used?

Using it in shared Lua will reduce the lines used yes no problems.

Dank je, I’d run into this problem a few times before but just employed other workarounds when needed.

I have run into the same bug. It seems like you will need to create the convar on the client as well also using FCVAR_REPLICATED. So put your CreateConVars into a shared file.

I ended up using Network strings anyways, but wouldn’t creating a ConVar on a shared file make it possible to change clientside?

Replicated prevents this, or is it archive? Someone care to correct me there?

Highly doubt Archive would prevent that

FCVAR_REPLICATED prevents clients from changing the value.

Thanks! I hate using Think hooks just to retrieve values that I need to use for like 1 second