Console commands only ran CS

I have a command



print("Is this shared?")
concommand.Add( "p_cashin", function(ply) if ply.pokertable then ply.pokertable:PlayerCashIn(ply) end end)



I want client to use the command and the function to be executed server side.

However it’s the oposite, it appears the concommand is CS only. I don’t understand why.
The command is in a shared file. “Is this shared?” gets printed on both server and client on script load.

-snip-

you can add it on only serverside and it will work from client consoles.
however it won’t show up in autocomplete.


if ( SERVER ) then
    concommand.Add( "p_cashin", function(ply) if ply.pokertable then ply.pokertable:PlayerCashIn(ply) end end)
else
    RunConsoelCommand("p_cashin")
end

This will run the command instantly on script load, I dont want it

When a client runs a console command, the game checks if the client has that console command. If so, the console command is executed clientside. Otherwise, it is networked to the server and executed serverside.

You can execute serverside console commands manually using the “cmd” command, but your best bet is to just have two separate commands or send a net message from the clientside command.

This solved my problem, thanks!