Garry's Mod Wiki

game.ConsoleCommand

  game.ConsoleCommand( string stringCommand )

Description

Runs a console command. Make sure to add a newline ("\n") at the end of the command.

If you use data that were received from a client, you should avoid using this function because newline and semicolon (at least) allow the client to run arbitrary commands!

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

Arguments

1 string stringCommand
String containing the command and arguments to be ran.

Example

Changes the gravity to 400 (default 600).

game.ConsoleCommand("sv_gravity 400\n")