The developer console an essential tool for game developers for debugging their code and also for players to customize their settings. The console is a text-based input/output interface to execute commands or change global settings during runtime. To enable the console, start the game, and go to "Options"-> "Keyboard" -> "Advanced" and check "Enable developer console". By default the console can be opened/closed with the "~" key.
The console is also enabled when the game executable is started with the "-dev" or "-console" parameters (developers should always start the game with -dev). If the Source Engine is started with an attached debugger, the console output is shown in you debug output window. Starting HL with "-condebug" will also log all console output in the text file "console.log" located in your game directory.
After entering a new command into the console, it is executed by hitting the ENTER key or pressing the 'Submit' button. A command has a unique name and an optional list of parameters where each parameter is separated by a space character.
The syntax is: command <parameter1> [<parameter2>] for example:
bind mouse1 +attack
Command names are not allowed to contain spaces, if a parameter contains space characters, it must be encapsulated in quotes:
bind h "say hello world"
name "Gordon Freeman"
The console stores the last executed commands in a command history that is accessible with UPARROW and DOWNARROW keys. You can auto complete a command by pressing TAB and choose from a list of available commands if the console found multiple matches. Some commands (e.g. map, load etc) support auto completion for the first parameter too.
The console differs between console commands and console variables. Console commands usually pass the parameters to some code function and execute it, but they don't remember these parameters. Console variables store the last parameters like a global setting. Console variables can only have one parameter, which can be a number or string; it depends on the game code how these values are interpreted. A lot of console variables act like triggers, 0 usually means off and 1 means on (e.g. cl_showfps). To see the current value of a console variable just type the name without any parameters.
Most console commands and variables have prefixes in their name to show the subsystem they belong to. That isn't always the case especially for commands coming from Half-Life 1, where the old name was kept unchanged.
Commonly used console command prefixes are:
If you forgot the exact name of a command or variable, find <substring> shows all commands containing a given substring. The command help <command> shows help text for a given command (if available).