Garry's Mod Wiki

Player:ConCommand

  Player:ConCommand( string command, boolean skip_queue = false )

Description

Runs the console command on the player. This does not work on bots.

If used clientside, always runs the command on the local player. You should use RunConsoleCommand in client realm instead.

If you wish to directly modify the movement input of bots, use GM:StartCommand instead.

Some commands/convars are blocked from being run/changed using this function, usually to prevent harm/annoyance to clients. For a list of blocked commands, see Blocked ConCommands.
If you use data that were received from a client, you should avoid using this function because semicolon (at least) allow the client to run arbitrary commands!

For safety, you are urged to prefer using Player:RunConsoleCommand in this case.

Arguments

1 string command
The console command to run.
2 boolean skip_queue = false
Whether to skip the command queue and send the command immediately. Clientside only.

Example

Kills the player using the concommand

Entity( 1 ):ConCommand( "kill" )
Output: The Player1 dies.