Trying to get work GetInfoNum()/GetInfo()

Hello, I’m trying to get convars from clients. But I have a problem.

Client side code:



CreateClientConVar("team_remember", 0, true, true)
CreateClientConVar("team_cvar", 1, true, true)


Server side code:



Msg(ply:GetInfoNum("team_remember") .. " " .. ply:GetInfoNum("team_cvar")) -- For debug


But when I tested it, the server gets both zeros. No matters if I change my convars to another number :(.

Also tryed commands:



] lua_run CreateClientConVar('xman', 1, true, true)

] xman
"xman" = "1" server_can_execute clientcmd_can_execute

] rcon lua_run Msg(player.GetByID(1):GetInfoNum('xman'))
> Msg ( player.GetByID ( 1 ) : GetInfoNum ( ' xman ' ) )...
0

] rcon lua_run Msg(player.GetByID(1):Name())
> Msg ( player.GetByID ( 1 ) : Name ( ) )...
Dark'E

Are you setting the ClientConVars on the client or server? (Should throw an error on the server, but hey).

What you’re doing in the commands below is lua_run which should be lua_run_cl when running it on the client.

I’m running ClientConVars on client, it runs without errors, as you can see:


] lua_run CreateClientConVar('xman', 1, true, true)
] xman
"xman" = "1" server_can_execute clientcmd_can_execute


The problem is I can’t get CVar from client in server.

I don’t think there is a different of using lua_run or lua_run_cl in dedicated server(in client console).
I think there is when you create server in game.

Maybe its for only stools? or gamemodes?

There is a difference as in singleplayer you are both server *and *client and thus it works. In a dedicated server it must be _cl.

But still, the CVars are created on client side as you can see


] xman
"xman" = "1" server_can_execute clientcmd_can_execute


But I can’t get these CVars from client to server.
Maybe its one of update bugs? But then all others addons wont work :/.

Working perfectly fine for me.

on console, or you made lua files?

I noticed that it works perfect in singleplayer, but not in dedicated

Works fine on my dedicated server via console or lua files.

When I run code in luapad, that works fine, but when I run from file or “rcon lua_run”, it always returns zeros :(.

file: addons/<ADDONNAME>/lua/autorun/<NAME>_init.lua



if SERVER then
	AddCSLuaFile( "<NAME>_cl_init.lua" ) 
	
	function FirstSpawn( ply )
		Msg(ply:GetInfoNum("team_remember").. " " .. ply:GetInfoNum("team_cvar") .. " " .. ply:Name())
		...
	end
	hook.Add( "PlayerInitialSpawn", "<NAME>playerInitialSpawn", FirstSpawn  )

	...
end


file: addons//lua/autorun/_cl_init.lua



if CLIENT then
	CreateClientConVar("team_remember", 0, true, true)
	CreateClientConVar("team_cvar", 1, true, true)
	...
end


Maybe this is just me but GetInfoNum always returns 0 even if it is a number besides 0. Try tonumber(ply:GetInfo(“team_remember”) or 0)

Still 0 :frowning: