Sending argumets via ConCommand

I have failed miserably in creating arguments that are being sent to the server from the client and vice versa.
So I need an example how to send some args through ConCommand or RunConsoleCommand or some other way.

an explanation or example would really help.

First of all, you’ll need to know that RunConsoleCommand( cmd, args ) (http://wiki.garrysmod.com/page/Global/RunConsoleCommand) handles arguments a bit differently to Player:ConCommand( cmd ) (http://wiki.garrysmod.com/page/Player/ConCommand).

Unlike Player:ConCommand, with RunConsoleCommand you must pass each argument as a new string, not separating them with a space. For example:



RunConsoleCommand( "developer", "1" )


Compared to how you would do it with Player:ConCommand:



Player:ConCommand( "developer 1" )


I hope that helps. :slight_smile:

I’d recommend using net messages to communicate with the server and to receive responses. Here’s an example: https://dl.dropboxusercontent.com/u/26074909/tutoring/networking/networking_booleans.lua.html

[lua]//examples of args being sent to/from server

//1
//server to client via sendlua

local args = “you are gay”
for k, v in pairs(player.GetAll()) do
v:SendLua([[RunConsoleCommand(“say”, ]] args [[)]])
end

//2
// client to server via networking

//server
util.AddNetworkString(“a”)
net.Receive(“a”, function(len, ply)
local str = net.ReadString()
print(str)
end)
//client
net.Start(“a”)
net.WriteString(“true”)
net.SendToServer()
[/lua]

hope this might help somewhat