Scripting guide - eirisocherry/cs2-editing GitHub Wiki
How to open a game console
- Add
-console
to the game launch options - Open the game and press [~] to open the game console
Must know commands
find <name>
Example: find ragdoll
// Echo every command that has ragdoll
in its name or description
All CS2 commands (press [F3] for searching): https://developer.valvesoftware.com/wiki/List_of_Counter-Strike_2_console_commands_and_variables
help <command>
Example: help host_timescale
// View information about host_timescale
command
echo <text>
Example: echo "hi, world"
// Print "hi, world"
into the console
exec <config_name>
Example: exec _core
// Execute/activate _core.cfg
Configs folder: ..\Counter-Strike Global Offensive\game\csgo\cfg
Configs must have .cfg
extension, not .txt
If you can't see the extensions: https://www.youtube.com/watch?v=5CJY7nbjpRk
clear
// Clear console
play <path to the sound>
Example: play "\sounds\buttons\bell1.vsnd_c"
// Play bell sound
All CS2 sounds: https://github.com/eirisocherry/cs2-editing/wiki/CS2-sounds
Making a config
- Open
..\Counter-Strike Global Offensive\game\csgo\cfg
folder - Create an empty txt file
- Enable file extensions: https://www.youtube.com/watch?v=5CJY7nbjpRk
Rename the empty txt file from<name>.txt
to_helloworld.cfg
Configs must have.cfg
extension, not.txt
(if you don't do this, you won't be able to execute the config via console) - Edit
_helloworld.cfg
with a notepad and type some commands, for example:
echo "Hello, world!"
echo "Hello, world2!"
echo "Hello, world3!"
- Open the game and activate your config by typing
exec <config_name>
in the game console
Example:exec _helloworld
// Execute_helloworld.cfg
The console will print all three lines
Edit _helloworld.cfg
with a notepad and paste these commands:
echo "Hello, world!" // Print first line
echo "Hello, world2!"
// echo "Hello, world3!"
As you can see, the console only printed first two lines (the third line was ignored, because it has //
at the start of the line)
Adding //
at the start of a line makes the console ignore it. This is called a comment.
If you add //
after a command, the command will still run, but everything after //
is ignored.
[1st way] Just type every command on a new line
Example:
echo "Hello, world!"
echo "Hello, world2!"
echo "Hello, world3!"
[2nd way]
Type all commands on a single line and separate them with a semicolon ;
echo "Hello, world!"; echo "Hello, world2!"; echo "Hello, world3!"
The first way works, because the game console automatically adds a semicolon ;
at the end of each line
Bind
Bind is a command you use to link a console command to a keyboard key
bind <key> "<command1; command2; commandN>"
Example #1: bind "j" "+jump"
// Bind jump action to j
Example #2: bind "m" "snd_voipvolume 0; echo Voice chat has been muted"
// Bind mute actions to m
Key codes: https://totalcsgo.com/binds/keys
Default binds: ..\Counter-Strike Global Offensive\game\csgo\cfg\user_keys_default.vcfg
Your current custom binds: ..\Steam\userdata\<ID>\730\local\cfg\cs2_user_keys_0_slot0.vcfg
Your current config: ..\Steam\userdata\<ID>\730\local\cfg\config.cfg
unbind <key>
Example: unbind "j"
// Unbind j
unbindall
// Unbind all keyboard keys
Alias
I would call it a trigger, it's the same thing as a bind, but for words that you type in the console, not for keyboard keys
alias <word> "<command1; command2; commandN>"
Example#1: alias lockfps "fps_max 120"
// Bind fps_max 120
command to word lockfps
lockfps
// Activate lockfps
alias (your framerate will be locked at 120 fps)
Example#2: alias gg "say Well played!; play \sounds\ui\beepclear.vsnd_c"
// Bind say Well played!; play \sounds\ui\beepclear.vsnd_c
to word gg
gg
// Activate gg
alias (it will make you say Well played!
in the chat and play a beepclear sound)
alias <word>
or you can simply rejoin the game
Example: alias lockfps
// Clear lockfps
alias
Double quotes
You need to use double quotes to group several words/commands and pass it as a single argument into a command
For example, if you print:
// alias <name> "<command1; command2; commandN>"
alias printHelloWorld echo Hello; echo World!
printHelloWorld
This console will interpret it as:
alias printHelloWorld "echo Hello";
echo World!;
printHelloWorld;
It will only bind echo Hello
to the printHelloWorld
alias, because once you type a semicolon ;
the console thinks you've done passing the argument and interprets the next symbols as an absolutely new command
But, if you type:
alias printHelloWorld "echo Hello; echo World!"
printHelloWorld
Everything will be okay, the whole echo Hello; echo World!
will be bounded to the printHelloWorld
alias
because once you type double quote "
the console will stop passing symbols into argument only if you type another double quote "
or create a new line
You can't echo a double quote "
You can't use double quotes inside of double quotes, it's not gonna work the way you expect it to
The only workaround for this is to execute another config inside of a config
For example, I want to clear sound filters
The only way to do this is by typing snd_filter ""
If I make an alias, such as:
alias clearSoundFilters "snd_filter """
clearSoundFilters
it's not gonna work, because the console will only pass snd_filter
without double quotes to the alias
The workaround:
- Create a config
clearSoundFilters.cfg
:
snd_filter ""
- Create another config
main.cfg
:
alias clearSoundFilters "exec _clearSoundFilters"
clearSoundFilters
This way it will work perfectly
Toggle alias
alias "function" "function_on"
alias "function_on" "<command1; command2; commandN>; alias function function_off"
alias "function_off" "<command1; command2; commandN>; alias function function_on"
function
Every time you type function
in the console
it will activate function_on
/function_off
alias
that will activate some commands and rebind function
alias, so it activates function_off
/function_on
alias next time
Example, nocliptoggle
toggle alias:
alias "nocliptoggle" "nocliptoggle_on"
alias "nocliptoggle_on" "noclip 1; alias nocliptoggle nocliptoggle_off"
alias "nocliptoggle_off" "noclip 0; alias nocliptoggle nocliptoggle_on"
Toggle bind
bind <key> "toggle <command> <value1> <value2>"
Example: bind "mouse5" "toggle host_timescale 0.3 1"
// Toggle game speed when pressing Side Mouse Button
Create a toggle alias and then just bind the main alias to a keyboard key
bind <key> "function" // Bind `function` toggle alias to a keyboard key
alias "function" "function_on"
alias "function_on" "<command1; command2; commandN>; alias function function_off"
alias "function_off" "<command1; command2; commandN>; alias function function_on"
Example, noclip toggle bind:
bind "v" "nocliptoggle"
alias "nocliptoggle" "nocliptoggle_on"
alias "nocliptoggle_on" "noclip 1; alias nocliptoggle nocliptoggle_off"
alias "nocliptoggle_off" "noclip 0; alias nocliptoggle nocliptoggle_on"
Hold bind
bind <key> "+function" // Bind '+function' alias to a key
alias "+function" "<command1; command2; commandN>" // Activate certain commands when holding a key
alias "-function" "<command1; command2; commandN>" // Activate another certain commands when unholding a key
Example, fast game speed hold bind:
bind "z" "+fast"
alias "+fast" "host_timescale 10"
alias "-fast" "host_timescale 1"
Advanced toggle bind
The huge peace of code below allows you to
- Toggle dof by pressing [/] or typing
dof1
/dof0
in the console - Move dof focus point 'closer to you/further away' by pressing [<] [>]
Try to undestand this code yourself (works only with HLAE in demo):
sv_cheats 1 // Allow cheat commands
mirv_cvar_unlock_sv_cheats // Unlock console commands that require 'sv_cheats 1'
mirv_cvar_unhide_all // Unhide all console commands
// DOF
bind "/" "dof"
alias "dof" "dof_on"
alias "dof_on" "alias dof dof_off; r_dof_override 1; echo DOF is ENABLED; play \sounds\ui\beepclear.vsnd_c"
alias "dof_off" "alias dof dof_on; r_dof_override 0; echo DOF is DISABLED; play \sounds\buttons\blip1.vsnd_c"
alias "dofState1" "r_dof_override_near_blurry -100; r_dof_override_near_crisp 0; r_dof_override_far_crisp 0; r_dof_override_far_blurry 50; alias next_dof_state dofState2;"
alias "dofState2" "r_dof_override_near_blurry -100; r_dof_override_near_crisp 0; r_dof_override_far_crisp 50; r_dof_override_far_blurry 150; alias next_dof_state dofState3; alias prev_dof_state dofState1"
alias "dofState3" "r_dof_override_near_blurry 0; r_dof_override_near_crisp 100; r_dof_override_far_crisp 150; r_dof_override_far_blurry 250; alias next_dof_state dofState4; alias prev_dof_state dofState2"
alias "dofState4" "r_dof_override_near_blurry 50; r_dof_override_near_crisp 150; r_dof_override_far_crisp 200; r_dof_override_far_blurry 300; alias next_dof_state dofState5; alias prev_dof_state dofState3"
alias "dofState5" "r_dof_override_near_blurry 16; r_dof_override_near_crisp 183; r_dof_override_far_crisp 350; r_dof_override_far_blurry 517; alias next_dof_state dofState6; alias prev_dof_state dofState4"
alias "dofState6" "r_dof_override_near_blurry 34; r_dof_override_near_crisp 218; r_dof_override_far_crisp 402; r_dof_override_far_blurry 586; alias next_dof_state dofState7; alias prev_dof_state dofState5"
alias "dofState7" "r_dof_override_near_blurry 54; r_dof_override_near_crisp 256; r_dof_override_far_crisp 458; r_dof_override_far_blurry 660; alias next_dof_state dofState8; alias prev_dof_state dofState6"
alias "dofState8" "r_dof_override_near_blurry 76; r_dof_override_near_crisp 298; r_dof_override_far_crisp 520; r_dof_override_far_blurry 742; alias next_dof_state dofState9; alias prev_dof_state dofState7"
alias "dofState9" "r_dof_override_near_blurry 100; r_dof_override_near_crisp 344; r_dof_override_far_crisp 588; r_dof_override_far_blurry 832; alias next_dof_state dofState10; alias prev_dof_state dofState8"
alias "dofState10" "r_dof_override_near_blurry 126; r_dof_override_near_crisp 394; r_dof_override_far_crisp 662; r_dof_override_far_blurry 930; alias next_dof_state dofState11; alias prev_dof_state dofState9"
alias "dofState11" "r_dof_override_near_blurry 154; r_dof_override_near_crisp 449; r_dof_override_far_crisp 744; r_dof_override_far_blurry 1039; alias next_dof_state dofState12; alias prev_dof_state dofState10"
alias "dofState12" "r_dof_override_near_blurry 184; r_dof_override_near_crisp 509; r_dof_override_far_crisp 834; r_dof_override_far_blurry 1159; alias next_dof_state dofState13; alias prev_dof_state dofState11"
alias "dofState13" "r_dof_override_near_blurry 216; r_dof_override_near_crisp 574; r_dof_override_far_crisp 932; r_dof_override_far_blurry 1290; alias next_dof_state dofState14; alias prev_dof_state dofState12"
alias "dofState14" "r_dof_override_near_blurry 250; r_dof_override_near_crisp 644; r_dof_override_far_crisp 1038; r_dof_override_far_blurry 1432; alias next_dof_state dofState15; alias prev_dof_state dofState13"
alias "dofState15" "r_dof_override_near_blurry 286; r_dof_override_near_crisp 719; r_dof_override_far_crisp 1152; r_dof_override_far_blurry 1585; alias next_dof_state dofState16; alias prev_dof_state dofState14"
alias "dofState16" "r_dof_override_near_blurry 324; r_dof_override_near_crisp 800; r_dof_override_far_crisp 1276; r_dof_override_far_blurry 1752; alias next_dof_state dofState17; alias prev_dof_state dofState15"
alias "dofState17" "r_dof_override_near_blurry 364; r_dof_override_near_crisp 888; r_dof_override_far_crisp 1412; r_dof_override_far_blurry 1936; alias next_dof_state dofState18; alias prev_dof_state dofState16"
alias "dofState18" "r_dof_override_near_blurry 406; r_dof_override_near_crisp 982; r_dof_override_far_crisp 1558; r_dof_override_far_blurry 2134; alias next_dof_state dofState19; alias prev_dof_state dofState17"
alias "dofState19" "r_dof_override_near_blurry 450; r_dof_override_near_crisp 1084; r_dof_override_far_crisp 1718; r_dof_override_far_blurry 2352; alias next_dof_state dofState20; alias prev_dof_state dofState18"
alias "dofState20" "r_dof_override_near_blurry 496; r_dof_override_near_crisp 1193; r_dof_override_far_crisp 1890; r_dof_override_far_blurry 2587; alias next_dof_state dofState21; alias prev_dof_state dofState19"
alias "dofState21" "r_dof_override_near_blurry 544; r_dof_override_near_crisp 1311; r_dof_override_far_crisp 2078; r_dof_override_far_blurry 2845; alias prev_dof_state dofState20"
alias "prev_dof_state" "dofState1"
alias "current_dof_state" "dofState2"
alias "next_dof_state" "dofState3"
bind "," "prev_dof_state; alias current_dof_state prev_dof_state; play \sounds\physics\concrete\rock_impact_soft3.vsnd_c"
bind "." "next_dof_state; alias current_dof_state next_dof_state; play \sounds\physics\concrete\rock_impact_soft2.vsnd_c"
Increment variable (incrementvar)
incrementvar
allows you to increase/descrease command value by a certain amount between two chosen values
bind "<key>" "incrementvar <command> <start_value> <end_value> <increase/decrease_value_by>"
For example, these binds allow you to decrease/increase FOV by 15 in the range of 0-75 by pressing [Up Arrow]/[Down Arrow]:
bind "uparrow" "incrementvar fov_cs_debug 0 75 -15"
bind "downarrow" "incrementvar fov_cs_debug 0 75 15"