Developer console: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (categorization)
 
(114 intermediate revisions by 53 users not shown)
Line 1: Line 1:
[[Category:Level Design]][[Category:Programming]]
{{LanguageBar}}
[[Image:Developer-console.jpg]]


=Introduction=
[[File:Console.gif|right|Console output for Episode Two]]
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 <code>"~" </code> key.


The console is also enabled when the game executable is started with the <code>"-dev"</code> or <code>"-console"</code> parameters (developers should always start the game with <code>-dev</code>). If the Source Engine is started with an attached debugger, the console output is shown in you debug output window. Starting HL with <code>"-condebug"</code> will also log all console output in the text file <code>"console.log"</code> located in your game directory.
The '''console''' provides a [[Wikipedia:Command-line interface|command-line interface]] for the advanced configuration of {{gldsrc|1}}, {{source|1}} and {{src2|1}} games, aswell as the {{steamicon|1|nt=0}}. Just about any configuration task can be completed from the console, and in fact many ''have'' to be.


After entering a new command into the console, it is executed by hitting the <code>ENTER</code> 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.
== Enabling the console ==


The syntax is: <code>command <parameter1> [<parameter2>]<code> for example:
On Source and Source 2 games, console starts disabled by default. To enable it, load the game and visit ''Options > Keyboard > Advanced''. There will be a pop-up that will include two options, one of them labeled "Enable Developer Console". Once enabled, it can be opened and closed by pressing the button above {{key|Tab}}, known as the "tilde." {{key|~}}


<pre>
GoldSrc games starts with console enabled by default (since Steam was released), but the previous version (also known as retail/WON version), needs {{code|-console}} launch option. The previous version of GoldSrc games cannot use {{key|~}} key to open console (unless the player is in-game), instead player click on Console menu option.
]bind mouse1 +attack
]map dm_lockdown
</pre>


Command names are not allowed to contain spaces, if a parameter contains space characters, it must be encapsulated in quotes:
For {{steamicon|1}} client, to open developer console, you can use {{code|steam://nav/console}} or {{code|steam://open/console}} (simply click on it, or type this on "Run" command on Windows, or through your internet browser and submit). You can also launch Steam with {{code|-console}} to start Steam with "Console" option available on the client tabs, and in context menu.


<pre>
{{note|This should work ''regardless'' of your keyboard layout. If it doesn't, add <code>-console</code> to the game's launch options to force it to open. Once open, type <code>bind your_key toggleconsole</code> to add a new binding and fix it in the future. Replace your_key with the key you wish to open the console with.}}
]bind h "say hello world"
]name "Gordon Freeman"
</pre>


The console stores the last executed commands in a command history that is accessible with <code>UPARROW</code> and <code>DOWNARROW</code> 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. <code>map, load</code> etc) support auto completion for the first parameter too.
== Submitting ==


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. <code>cl_showfps</code>). To see the current value of a console variable just type the name without any parameters.
The grey box across the bottom of the console window is where commands are entered. They come in two forms: commands and variables. Commands are simply keywords, but variables ("cvars") require a value of some sort before they are accepted. When setting a [[cvar]] you might type something like this:


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.
<code>[[mat_wireframe]] 1</code>
 
When you've finished typing, hit {{key|Return}} or {{key|Enter}} to submit. You'll see everything you type 'echoed' to the console with a preceding <code>]</code>.
 
A few notes:
 
* Multiple values are separated with spaces. If a value contains a space, surround it with quote marks. (e.g. <code>say "Hello everyone on the server"</code>.)
* The console will suggest commands and sometimes values in a pop-out box beneath the input field. Press {{key|Up}}/{{key|Down}} to navigate the list and {{key|Tab}} to accept the highlighted suggestion.
* Only "archived" cvars are stored after the game closes. Use [[autoexec]] if you want to set any others when a game loads.
* Some commands are serverside, others clientside. In multiplayer you can only set clientside ones.
* There are many command prefixes. The most common are <code>cl</code> ("clientside") and <code>sv</code> ("serverside").
 
== Useful commands ==
{{seealso|[[List of console scripting commands]] - small command palette for scripting the console,<br>[[:Category:Source base console commands]]}}
 
=== The console window ===
 
;<code>con_enable <[[boolean]]></code>
:Allows the console to be activated.
 
;<code>showconsole</code>
;<code>hideconsole</code>
;<code>toggleconsole</code>
:Simple command that opens/closes/toggles the console. <code>toggleconsole</code> is bound to {{key|`}} by default.
 
=== Find commands ===
 
;<code>[[find]] <term></code>
:The ever-useful <code>find</code> command searches console command names and descriptions for the term you provide.{{note|Use <code>[[cvarlist]]</code> in GoldSource.}}
 
;<code>help <command name></code>
:Displays any help text for a command, without affecting its value.
 
=== Controlling console output ===
 
;<code>clear</code>
:Clear console output, i. e. empties the console. This is useful to execute before other commands to tell where some text starts and ends such as after <code>find <string></code>.
 
;<code>echo <string></code>
:Display user-defined text in the console.
 
;<code>con_log <file></code>
;<code>condump</code>
: Use one of these commands if you want to record what goes on in the console for later use. <code>con_log</code> writes output constantly, while <code>condump</code> records the current text in the console when invoked. {{tip|The console only displays 241 lines at a time. Use <code>con_log</code> if you run up against this.}}
 
;<code>con_filter_enable <0-2></code>
: Filters console output based on the setting of <code>con_filter_text</code> and <code>con_filter_text_out</code>. If set to <code>1</code>, all other console output is not shown at all. If set to <code>2</code>, all other console output is printed in gray to highlight the filtered text.
;<code>con_filter_text <string></code>
: If this is not the empty string and <code>con_filter_enable</code> is not 0, then any console output is filtered out if it does not match this.
;<code>con_filter_text_out <string></code>
: If this is not the empty string and <code>con_filter_enable</code> is not 0, then any console output is filtered out if it does match this.
 
=== Cheats and debugging tools ===
 
;<code>[[developer]] <0-2></code>
:Developer mode enables more verbose console output, enables cheats and the console automatically, and makes various other useful changes. If set to <code>2</code>, the last few lines of console output will be printed at the top of the screen as well.
 
;<code>[[sv_cheats]] <[[boolean]]></code>
:Most cvars that affect gameplay, especially in multiplayer games, are flagged as "cheats". Submit <code>sv_cheats 1</code> to unlock them. {{Note|[[logic_achievement|Achievements]] will be disabled when cheats is enabled.}} {{note|You will never be [[Valve Anti-Cheat|VAC]] banned for using built-in cheat commands.}}
 
;<code>[[noclip]]</code>
:Allows you to fly trough your level without player collisions. Requires <code>sv_cheats</code> to be set to 1.
 
;<code>[[getpos]]</code>
:Prints the current position of the local player to the console. <code>[[cl_showpos]] <0-1></code> can be used to show the position on the screen continuously.
 
;<code>[[cl_showfps]] <0-2></code>
:Display the current frames per second. If set to "2", will also show the lowest and highest FPS, and the latency.
 
;<code>find_ent <term></code>
:Similar to the <code>find</code> command above, but searches for entities within the map by name.
 
;<code>[[impulse]] <number></code>
:A generic client command with various game dependent uses, both cheat and not cheat.
 
=== Game related ===
 
;<code>[[map]] <mapname></code>
:Starts a game on a map.
 
;<code>connect <address></code>
:Tries to connect to a server and load its current map.
 
;<code>disconnect</code>
:Disconnects the game from the current server.
 
;<code>[[status]]</code>
:Shows information about the server that a client is connected to.
 
;<code>quit</code>
:Closes the game.
 
== Command prefixes ==
 
Most console commands and variables have prefixes in their name to show the subsystem they belong to, but this 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:
Commonly used console command prefixes are:
{|
{| class="wikitable mw-collapsible mw-collapsed"
|+ style="color:#bbb; white-space:nowrap; text-align:left"| Command prefixes
| <code>ai_</code> || single player AI
| <code>ai_</code> || single player AI
|-
| <code>bot_</code> || [[bot]] system
|-
|-
| <code>cc_</code> || close caption system
| <code>cc_</code> || close caption system
|-
|-
| <code>cl_</code> || multiplayer client
| <code>cl_</code> || multiplayer game (client; see also <code>mp_</code>)
|-
|-
| <code>demo_</code> || demo playback
| <code>demo_</code> || [[Demo Recording Tools|demo playback]]
|-
|-
| <code>disp_</code> || terrain displacement maps
| <code>disp_</code> || terrain displacement maps
|-
|-
| <code>dsp_</code> || audio DSP settings
| <code>dsp_</code> || audio [[DSP]] settings
|-
|-
| <code>ent_</code> || entity control/debug
| <code>ent_</code> || entity control/debug
Line 47: Line 136:
| <code>fire_</code> || firing entity events
| <code>fire_</code> || firing entity events
|-
|-
| <code>fog_</code> || fog renderer
| <code>fog_</code> || [[Dust,_Fog,_%26_Smoke|fog]] override parameters for the  [[fogui]]
|-
|-
| <code>g_</code> || single player game
| <code>g_</code> || single player game
|-
|-
| <code>hltv_</code> || Half-Life TV
| <code>hltv_</code> || {{obs}} [[HLTV|Half-Life TV]] (see <code>tv_</code> for [[SourceTV]])
|-
|-
| <code>host_</code> || host system
| <code>host_</code> || host system
|-
|-
| <code>hud_</code> || client HUD
| <code>hud_</code> || client [[:Category:HUD|HUD]]
|-
|-
| <code>joy_</code> || joystick input
| <code>joy_</code> || joystick input
Line 63: Line 152:
| <code>m_</code> || mouse input
| <code>m_</code> || mouse input
|-
|-
| <code>mat_</code> || material system
| <code>mat_</code> || [[material]] system
|-
|-
| <code>mp_</code> || multiplayer game (server)
| <code>mp_</code> || multiplayer game (server; see also <code>cl_</code>)
|-
|-
| <code>nav_</code> || navigation graphs
| <code>nav_</code> || [[Nav Mesh|navigation meshes]]
|-
|-
| <code>net_</code> || engine networking
| <code>net_</code> || engine [[:Category:Networking|networking]]
|-
|-
| <code>npc_</code> || single player game NPCs
| <code>npc_</code> || single player game [[NPC]]s
|-
|-
| <code>phys_</code> || physics system
| <code>phys_</code> || [[physics]] system
|-
|-
| <code>r_</code> || video renderer
| <code>r_</code> || video renderer
|-
|-
| <code>rcon_</code> || remote control access
| <code>rcon_</code> || [[Source RCON Protocol|remote control access]]
|-
|-
| <code>sk_</code> || player skill / difficulty
| <code>sk_</code> || player skill / difficulty
|-
|-
| <code>snd_</code> || sound system
| <code>snd_</code> || [[Sound and Music|sound system]]
|-
|-
| <code>sv_</code> || server settings (engine)
| <code>sv_</code> || server settings (engine)
|-
| <code>tv_</code> || [[SourceTV]]
|-
|-
| <code>v_</code> || client view
| <code>v_</code> || client view
Line 94: Line 185:
|-
|-
| <code>wc_</code> || WorldCraft/Hammer helpers
| <code>wc_</code> || WorldCraft/Hammer helpers
|}
|}


== See also ==


If you forgot the exact name of a command or variable, <code>find <substring></code> shows all commands containing a given substring. The command <code>help <command></code> shows help text for a given command (if available).
* [[Developer Console Control]] - for programmers
* [[Console Command List]] - partial list of console commands and variables available in all GoldSrc, Source and Source 2 games
* [[List_of_Valve_Games_console_commands_and_variables|Game Specific Console Command List]] - List of all cvars for each game
* [[:Category:Console commands]] - list of written articles for console commands
* [[:Category:Console variables]] - list of written articles for console variables
[[Category:Source_SDK_FAQ]]
[[Category:Modding]]
[[Category:Dedicated Server]]

Latest revision as of 07:03, 27 August 2025

English (en)Deutsch (de)Español (es)Français (fr)Italiano (it)日本語 (ja)Polski (pl)Português do Brasil (pt-br)Русский (ru)中文 (zh)中文(臺灣) (zh-tw)Translate (Translate)
Console output for Episode Two

The console provides a command-line interface for the advanced configuration of GoldSrc, Source and Source 2 games, aswell as the Steam client. Just about any configuration task can be completed from the console, and in fact many have to be.

Enabling the console

On Source and Source 2 games, console starts disabled by default. To enable it, load the game and visit Options > Keyboard > Advanced. There will be a pop-up that will include two options, one of them labeled "Enable Developer Console". Once enabled, it can be opened and closed by pressing the button above Tab , known as the "tilde." ~

GoldSrc games starts with console enabled by default (since Steam was released), but the previous version (also known as retail/WON version), needs -console launch option. The previous version of GoldSrc games cannot use ~ key to open console (unless the player is in-game), instead player click on Console menu option.

For Steam client, to open developer console, you can use steam://nav/console or steam://open/console (simply click on it, or type this on "Run" command on Windows, or through your internet browser and submit). You can also launch Steam with -console to start Steam with "Console" option available on the client tabs, and in context menu.

Note.pngNote:This should work regardless of your keyboard layout. If it doesn't, add -console to the game's launch options to force it to open. Once open, type bind your_key toggleconsole to add a new binding and fix it in the future. Replace your_key with the key you wish to open the console with.

Submitting

The grey box across the bottom of the console window is where commands are entered. They come in two forms: commands and variables. Commands are simply keywords, but variables ("cvars") require a value of some sort before they are accepted. When setting a cvar you might type something like this:

mat_wireframe 1

When you've finished typing, hit Return or Enter to submit. You'll see everything you type 'echoed' to the console with a preceding ].

A few notes:

  • Multiple values are separated with spaces. If a value contains a space, surround it with quote marks. (e.g. say "Hello everyone on the server".)
  • The console will suggest commands and sometimes values in a pop-out box beneath the input field. Press / to navigate the list and Tab to accept the highlighted suggestion.
  • Only "archived" cvars are stored after the game closes. Use autoexec if you want to set any others when a game loads.
  • Some commands are serverside, others clientside. In multiplayer you can only set clientside ones.
  • There are many command prefixes. The most common are cl ("clientside") and sv ("serverside").

Useful commands

See also:  List of console scripting commands - small command palette for scripting the console,
Category:Source base console commands

The console window

con_enable <boolean>
Allows the console to be activated.
showconsole
hideconsole
toggleconsole
Simple command that opens/closes/toggles the console. toggleconsole is bound to ` by default.

Find commands

find <term>
The ever-useful find command searches console command names and descriptions for the term you provide.
Note.pngNote:Use cvarlist in GoldSource.
help <command name>
Displays any help text for a command, without affecting its value.

Controlling console output

clear
Clear console output, i. e. empties the console. This is useful to execute before other commands to tell where some text starts and ends such as after find <string>.
echo <string>
Display user-defined text in the console.
con_log <file>
condump
Use one of these commands if you want to record what goes on in the console for later use. con_log writes output constantly, while condump records the current text in the console when invoked.
Tip.pngTip:The console only displays 241 lines at a time. Use con_log if you run up against this.
con_filter_enable <0-2>
Filters console output based on the setting of con_filter_text and con_filter_text_out. If set to 1, all other console output is not shown at all. If set to 2, all other console output is printed in gray to highlight the filtered text.
con_filter_text <string>
If this is not the empty string and con_filter_enable is not 0, then any console output is filtered out if it does not match this.
con_filter_text_out <string>
If this is not the empty string and con_filter_enable is not 0, then any console output is filtered out if it does match this.

Cheats and debugging tools

developer <0-2>
Developer mode enables more verbose console output, enables cheats and the console automatically, and makes various other useful changes. If set to 2, the last few lines of console output will be printed at the top of the screen as well.
sv_cheats <boolean>
Most cvars that affect gameplay, especially in multiplayer games, are flagged as "cheats". Submit sv_cheats 1 to unlock them.
Note.pngNote:Achievements will be disabled when cheats is enabled.
Note.pngNote:You will never be VAC banned for using built-in cheat commands.
noclip
Allows you to fly trough your level without player collisions. Requires sv_cheats to be set to 1.
getpos
Prints the current position of the local player to the console. cl_showpos <0-1> can be used to show the position on the screen continuously.
cl_showfps <0-2>
Display the current frames per second. If set to "2", will also show the lowest and highest FPS, and the latency.
find_ent <term>
Similar to the find command above, but searches for entities within the map by name.
impulse <number>
A generic client command with various game dependent uses, both cheat and not cheat.

Game related

map <mapname>
Starts a game on a map.
connect <address>
Tries to connect to a server and load its current map.
disconnect
Disconnects the game from the current server.
status
Shows information about the server that a client is connected to.
quit
Closes the game.

Command prefixes

Most console commands and variables have prefixes in their name to show the subsystem they belong to, but this 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:

Command prefixes
ai_ single player AI
bot_ bot system
cc_ close caption system
cl_ multiplayer game (client; see also mp_)
demo_ demo playback
disp_ terrain displacement maps
dsp_ audio DSP settings
ent_ entity control/debug
fire_ firing entity events
fog_ fog override parameters for the fogui
g_ single player game
hltv_ Obsolete Half-Life TV (see tv_ for SourceTV)
host_ host system
hud_ client HUD
joy_ joystick input
log_ logging system
m_ mouse input
mat_ material system
mp_ multiplayer game (server; see also cl_)
nav_ navigation meshes
net_ engine networking
npc_ single player game NPCs
phys_ physics system
r_ video renderer
rcon_ remote control access
sk_ player skill / difficulty
snd_ sound system
sv_ server settings (engine)
tv_ SourceTV
v_ client view
vgui_ VGUI
voice_ ingame player voice
vprof_ code profiler
wc_ WorldCraft/Hammer helpers

See also