concommand.Add
concommand.Add( string name , function callback, string helpstring, number flags )
Arguments:
- 1) string name The command name to be used in console.
- 2) function callback The function to run when the concommand is executed.
- CBasePlayer ply - The player that ran the concommand. NULL entity if command was entered with the dedicated server console.
- string cmd - The concommand string (if one callback is used for several concommands).
- string arg - The arguments as a string.
- 3) string helpstring The function to run when the concommand is executed.
- 4) number flags The function to run when the concommand is executed.
This cannot be a name of existing console command or console variable. It will silently fail if it is.
Function callback arguments are:
Example:
concommand.Add("ConsoleCommand", function(ply, cmd, arg) print("ConCommand is Working!") if arg ~= nil then print(ply:GetPlayerName().." executed command: "..cmd.." with "..arg.." as argument. ") end end)
Output:
ConCommand is Working!
Dim1xs executed command: ConsoleCommand with 1 as argument.