Difference between revisions of "Scripting/pl"

From Team Fortress Wiki
Jump to: navigation, search
m (ohgodno, gonna fix that in a while, i thought i copied it from the edit)
m (fixed now, god what a mess that was)
Line 7: Line 7:
  
 
These scripts range in complexity from simple lists of commands to self-referential loops and nested aliases that redefine one another. With enough time and effort, you can use the tools to create almost any behavior available to the client at the press of a single key.
 
These scripts range in complexity from simple lists of commands to self-referential loops and nested aliases that redefine one another. With enough time and effort, you can use the tools to create almost any behavior available to the client at the press of a single key.
Contents
 
[hide]
 
  
    1 Podstawowe pliki skryptowania Basic Scripting Files
+
==Podstawowe pliki skryptowania==
    2 Składnia
+
Team Fortress 2 automatycznie czyta kilka plików gry i odtwarza bindy i aliasy w środku. Oto lista tych plików:
    3 Przypisywanie przycisków
 
        3.1 Lista nazw przycisków
 
    4 Podstawowe komendy
 
    5 Incrementvar
 
    6 Komendy + i -
 
    7 Komenda Wait
 
    8 Aliasy
 
        8.1 Złożone aliasy
 
        8.2 Pętle aliasów
 
    9 Przydatne komendy skryptów Useful Script Commands
 
        9.1 Komendy głosowe
 
            9.1.1 Argumenty komend głosowych for voice commands
 
        9.2 Szybkie przebrania szpiega
 
            9.2.1 Argumenty komend przebrań
 
        9.3 Szybkie budowanie Inżyniera
 
            9.3.1 Argumenty komend budowania for building commands
 
        9.4 Automatyczne wezwanie medyka
 
    10 Skrypty warte uwagi
 
        10.1 Naprawione skrypty
 
            10.1.1 Skrypty pistoletu
 
            10.1.2 Skrypt skręcania Tarczą Szarży
 
            10.1.3 Skrypt kucania w powietrzu
 
        10.2 Działające skrypty
 
            10.2.1 Skrypty chowania broni
 
            10.2.2 Skrypty skoków na działku strażniczym
 
            10.2.3 Skrypty Jednorękiego Bandyty
 
            10.2.4 Skrypty czułości myszy oraz poruszania się
 
            10.2.5 Charge Dash Scripts
 
            10.2.6 Skrypty Quickscope
 
    11 Zobacz też
 
    12 Linki zewnętrzne
 
  
[edit] Podstawowe pliki skryptowania
+
*config.cfg - Jest to domyślny plik konfiguracyjny, który jest edytowany kiedykolwiek gracz zmienia przypisania klawiszy lub opcje grafiki. Nawet jeżeli edytowanie tego pliku jest bezpieczne, najlepiej zostawić go w spokoju.
Team Fortress 2 automatycznie czyta kilka plików gry i odtwarza bindy i aliasy w środku. Oto lista tych plików: automatically reads several game files and executes any keybinds and aliases inside. Here is the list of those files:
 
  
    config.cfg - Jest to domyślny plik konfiguracyjny, który jest edytowany kiedykolwiek gracz zmienia przypisania klawiszy lub opcje grafiki. Nawet jeżeli edytowanie tego pliku jest bezpieczne, najlepiej zostawić go w spokoju.
+
*autoexec.cfg - Jest to domyślny plik konfiguracyjny używany do odtwarzania niestandardowych bindów i aliasów. Gracz może tu wpisać swoje bindy do tego pliku jednak często jest tak, że łatwiej jest stworzyć osobny plik .cfg do pozostałych skryptów, które poźniej można odtworzyć w tym pliku.  
  
    autoexec.cfg - Jest to domyślny plik konfiguracyjny używany do odtwarzania niestandardowych bindów i aliasów. Gracz może tu wpisać swoje bindy do tego pliku jednak często jest tak, że łatwiej jest stworzyć osobny plik .cfg do pozostałych skryptów, które poźniej można odtworzyć w tym pliku.  
+
*<klasa>.cfg - Każda klasa ma plik konfiguracyjny który automatycznie odtwarza się gdy gracz zaczyna grać jedną z tych klas. Można wpisać tam swoje bindy bezpośrednio do tego pliku, jednak często jest tak, że łatwiej jest stworzyć osobny plik .cfg który później odtwarza się w tym pliku.
  
    <klasa>.cfg - Każda klasa ma plik konfiguracyjny który automatycznie odtwarza się gdy gracz zaczyna grać jedną z tych klas. Można wpisać tam swoje bindy bezpośrednio do tego pliku, jednak często jest tak, że łatwiej jest stworzyć osobny plik .cfg który później odtwarza się w tym pliku.
+
==Składnia==
 
 
[edit] Składnia
 
  
 
Lista zasad składni:
 
Lista zasad składni:
  
    Żeby jakikolwiek bind czy alias działał poprawnie, musisz urzyć tego formatu: For any keybind or alias to work, you need to follow this format:  
+
*Żeby jakikolwiek bind czy alias działał poprawnie, musisz użyć tego formatu:  
  
    komenda <argument1> <argument2>  
+
:komenda <argument1> <argument2>  
  
        komenda jest typem skryptu którego chcesz użyć:
+
:*komenda jest typem skryptu którego chcesz użyć:
  
            bind - Używany do przypisania komendy do jakiegoś przycisku
+
:*bind - Używany do przypisania komendy do jakiegoś przycisku
            alias -  Used to execute commands when the alias is executed.
+
:*alias -  Used to execute commands when the alias is executed.
            exec - Używany do odtworzenia komend automatycznie po załadowaniu pliku konfiguracyjnego.
+
:*exec - Używany do odtworzenia komend automatycznie po załadowaniu pliku konfiguracyjnego.
  
        <argument1> może być albo przypisywanym przyciskiem lub nazwą stworzonego aliasu
+
:*<argument1> może być albo przypisywanym przyciskiem lub nazwą stworzonego aliasu
  
        <argument2> może być komendą przypisywaną do przycisku lub komendy odtwarzane przez alias. is either the command being bound or the commands executed by the alias.  
+
:*<argument2> może być komendą przypisywaną do przycisku lub komendy odtwarzane przez alias.  
  
    Aby użyć paru komend jednocześnie, musimy postawić cały argument w cudzysłowach oraz oddzielić komendy apostrofem:
+
*Aby uruchomić parę komend jednocześnie, musimy postawić cały argument w cudzysłowach oraz oddzielić komendy apostrofem:
  
    alias "walnaslepo" "+attack; wait 500; -attack"  
+
:alias "walnaslepo" "+attack; wait 500; -attack"  
    bind "mouse3" "walnaslepo"  
+
:bind "mouse3" "walnaslepo"  
  
        Podczas odtwarzania, alias zaczyna strzelać z broni gracza, kontynuuje przez 500 fizycznych klatek (jest to 5 sekund jeżeli gracz gra na serwerze który działa na 100 FPS) po czym przestaje strzelać. Alias jest przypisany aby rozpocząć strzelanie po wciśnięciu kółka myszy.  
+
:*Podczas odtwarzania, alias zaczyna strzelać z broni gracza, kontynuuje przez 500 fizycznych klatek (jest to 5 sekund jeżeli gracz gra na serwerze który działa na 100 FPS) po czym przestaje strzelać. Alias jest przypisany aby rozpocząć strzelanie po wciśnięciu kółka myszy.
 +
*To enclose something in quotes that already has quotes in it, you have to ''escape'' the internal quotes by using two consecutive quotes ("") in place of each one.
 +
:'''alias "saysomestuff" "say ""Some Stuff..."""'''
 +
:*When you type '''saysomestuff''' in the console, you will speak "Some Stuff..." in the chat. Without the internal quotes, the chat window will only show "Some".
  
    To enclose something in quotes that already has quotes in it, you have to escape the internal quotes by using two consecutive quotes ("") in place of each one.
+
==Keybinds==
  
    alias "saysomestuff" "say ""Some Stuff..."""
+
Team Fortress 2 allows scripts and aliases to be bound to any key on the keyboard.  The key you wish to bind a command to is placed after your bind command and before the action you want the key to execute, as in the section above.  Most keys are self-explanatory, as all alphanumerics (a-z, 0-9) and function keys are simply listed by typing that key ("bind a" binds a key to "a", "bind 5" binds to "5" and "bind f7" binds to "f7"). Other keys require you type specific names into your .cfg file in order to access them, and these names are not all obvious. A list of these keys is provided below:
  
        When you type saysomestuff in the console, you will speak "Some Stuff..." in the chat. Without the internal quotes, the chat window will only show "Some".
+
====List of Key Names====
 +
* Keyboard Keys: Names of Keybinds
 +
* Left Shift: SHIFT
 +
* Left Ctrl: CTRL
 +
* Left Alt: ALT
 +
* Right Shift: RSHIFT
 +
* Right Control: RCTRL
 +
* Right Alt: RALT
 +
* Tab: TAB
 +
* Backspace: BACKSPACE
 +
* ---
 +
* Insert: INS
 +
* Scroll Lock: SCROLLLOCK
 +
* Pause/Break: NUMLOCK
 +
* ---
 +
* Home: HOME
 +
* End: END
 +
* Delete: DEL
 +
* Page Up: PGUP
 +
* Page Down: PGDN
 +
* ---
 +
* Up Arrow: UPARROW
 +
* Down Arrow: DOWNARROW
 +
* Left Arrow: LEFTARROW
 +
* Right Arrow: RIGHTARROW
 +
* Numpad Keys: Names of Keybinds
 +
* 0: KP_INS
 +
* 1: KP_END
 +
* 2: KP_DOWNARROW
 +
* 3: KP_PGDN
 +
* 4: KP_LEFTARROW
 +
* 5: KP_5
 +
* 6: KP_RIGHTARROW
 +
* 7: KP_HOME
 +
* 8: KP_UPARROW
 +
* 9: KP_PGUP
 +
* Enter: KP_ENTER
 +
* ".": KP_DEL 
 +
* "+": KP_PLUS
 +
* "-": KP_MINUS
 +
* "*": KP_MULTIPLY
 +
* "/":KP_SLASH
 +
* Mouse Wheel Direction: Names of Keybinds
 +
* Mouse Wheel Up: MWHEELUP
 +
* Mouse Wheel Down: MWHEELDOWN
  
[edit] Keybinds
+
Using the above keynames you can place the following example command into one of your config files: <bind KP_ENTER "voicemenu 0 1">. When you hit Enter on your Numpad in-game you will trigger the "Thanks" voice command.
 
 
Team Fortress 2 allows scripts and aliases to be bound to any key on the keyboard. The key you wish to bind a command to is placed after your bind command and before the action you want the key to execute, as in the section above. Most keys are self-explanatory, as all alphanumerics (a-z, 0-9) and function keys are simply listed by typing that key ("bind a" binds a key to "a", "bind 5" binds to "5" and "bind f7" binds to "f7"). Other keys require you type specific names into your .cfg file in order to access them, and these names are not all obvious. A list of these keys is provided below:
 
[edit] List of Key Names
 
 
 
    Keyboard Keys: Names of Keybinds
 
    Left Shift: SHIFT
 
    Left Ctrl: CTRL
 
    Left Alt: ALT
 
    Right Shift: RSHIFT
 
    Right Control: RCTRL
 
    Right Alt: RALT
 
    Tab: TAB
 
    Backspace: BACKSPACE
 
    ---
 
    Insert: INS
 
    Scroll Lock: SCROLLLOCK
 
    Pause/Break: NUMLOCK
 
    ---
 
    Home: HOME
 
    End: END
 
    Delete: DEL
 
    Page Up: PGUP
 
    Page Down: PGDN
 
    ---
 
    Up Arrow: UPARROW
 
    Down Arrow: DOWNARROW
 
    Left Arrow: LEFTARROW
 
    Right Arrow: RIGHTARROW
 
    Numpad Keys: Names of Keybinds
 
    0: KP_INS
 
    1: KP_END
 
    2: KP_DOWNARROW
 
    3: KP_PGDN
 
    4: KP_LEFTARROW
 
    5: KP_5
 
    6: KP_RIGHTARROW
 
    7: KP_HOME
 
    8: KP_UPARROW
 
    9: KP_PGUP
 
    Enter: KP_ENTER
 
    ".": KP_DEL
 
    "+": KP_PLUS
 
    "-": KP_MINUS
 
    "*": KP_MULTIPLY
 
    "/":KP_SLASH
 
    Mouse Wheel Direction: Names of Keybinds
 
    Mouse Wheel Up: MWHEELUP
 
    Mouse Wheel Down: MWHEELDOWN
 
  
Using the above keynames you can place the following example command into one of your config files: <bind KP_ENTER "voicemenu 0 1">. When you hit Enter on your Numpad in-game you will trigger the "Thanks" voice command.
+
==Basic Commands==
[edit] Basic Commands
 
  
 
Most commands accept a single argument, which is whatever value you want to execute.
 
Most commands accept a single argument, which is whatever value you want to execute.
  
bind "q" "sv_alltalk 1"
+
'''bind "q" "sv_alltalk 1"'''
  
A handful of important commands accept multiple arguments. Here are some examples:
+
A handful of important commands accept multiple arguments. Here are some examples:
  
    disguise X Y - This disguises the Spy. X is the class numbered 1 through 9 and Y is the team numbered 1 or 2.  
+
* disguise X Y - This [[disguise]]s the [[Spy]]. X is the class numbered 1 through 9 and Y is the team numbered 1 or 2.
  
    voicemenu X Y - This executes a voice command. X is the number of the primary menu. Y is the command position in that menu.  
+
* voicemenu X Y - This executes a voice command. X is the number of the primary menu. Y is the command position in that menu.
  
 
Example: "voicemenu 1 1" is the command for Spy, so:
 
Example: "voicemenu 1 1" is the command for Spy, so:
  
bind "t" "voicemenu 1 1"
+
'''bind "t" "voicemenu 1 1"'''
  
 
This command will make your character yell Spy whenever you hit the key.
 
This command will make your character yell Spy whenever you hit the key.
[edit] Incrementvar
 
  
This command cycles through a range of specified values whenever it executes and applies those values to another command. This has the form of:
+
==Incrementvar==
  
    command "<argument1>" "incrementvar <argument2> X Y Z"
+
This command cycles through a range of specified values whenever it executes and applies those values to another command.  This has the form of:
  
        X and Y represent the range of values you want to execute with <argument2>.
+
:'''command "<argument1>" "incrementvar <argument2> X Y Z"'''
        Z is the size of the step you want to make while you cycle through the range.
 
  
If you wanted a value range of 1 through 10 and you wanted to increment your value by 2 each time the command was executed, you'd make X Y Z into 1 10 2. Then each time it executes, <argument2> will execute with an incrementing value of 2, 4, 6, 8, 10, 2, 4, 6, 8, 10... and so forth.
+
:*X and Y represent the range of values you want to execute with <argument2>.
 +
:*Z is the size of the step you want to make while you cycle through the range.
 +
 
 +
If you wanted a value range of 1 through 10 and you wanted to increment your value by 2 each time the command was executed, you'd make X Y Z into 1 10 2. Then each time it executes, <argument2> will execute with an incrementing value of 2, 4, 6, 8, 10, 2, 4, 6, 8, 10... and so forth.
  
 
Here is a real example of incrementvar in action:
 
Here is a real example of incrementvar in action:
  
    bind "n" "incrementvar net_graphpos 1 3 1"  
+
:'''bind "n" "incrementvar net_graphpos 1 3 1"'''
  
 
This binds the key "n" to cycle to the next position in the 3 available net_graph positions.
 
This binds the key "n" to cycle to the next position in the 3 available net_graph positions.
[edit] The + and - commands
 
  
These commands have two states. While the bound key is pressed, the +command executes and continues to execute. When the key is released, the -command executes and continues to execute.
+
==The + and - commands==
 +
 
 +
These commands have two states. While the bound key is pressed, the +command executes and continues to execute. When the key is released, the -command executes and continues to execute.
  
 
Example:
 
Example:
 +
:'''bind "c" "+duck"
  
    bind "c" "+duck"
+
This +command is bound to "c" so whenever the key is pressed, the player ducks.  Whenever the key is released, +duck is swapped to -duck and the player stops ducking.
  
This +command is bound to "c" so whenever the key is pressed, the player ducks. Whenever the key is released, +duck is swapped to -duck and the player stops ducking.
+
In general, if a command or alias is bound to a key, a + tells the game to run the command as long as the key is held.  Similarly, if a command or alias is bound to a key, a - tells the game to run the command when the key is released.
  
In general, if a command or alias is bound to a key, a + tells the game to run the command as long as the key is held. Similarly, if a command or alias is bound to a key, a - tells the game to run the command when the key is released.
+
If an alias is defined with a + in front of it, the alias will be run whenever the key is pressed, as the key is pressed. The - command will then run as the key is released.
  
If an alias is defined with a + in front of it, the alias will be run whenever the key is pressed, as the key is pressed. The - command will then run as the key is released.
+
==Wait Command==
[edit] Wait Command
 
  
If you want the game to delay for a period of time during an alias, or if you want avoid client crashes caused by executing commands too quickly, use the wait command.
+
If you want the game to delay for a period of time during an alias, or if you want avoid client crashes caused by executing commands too quickly, use the '''wait''' command.
  
Wait tells the game to delay the next command in the script by one physics frame, something like a full turn in the TF2 rules. It accepts values such as "wait 50" which tells the game to wait fifty frames before the alias continues. "wait 100" is roughly a second on a 100 FPS server.
+
Wait tells the game to delay the next command in the script by one physics frame, something like a full turn in the TF2 rules. It accepts values such as "wait 50" which tells the game to wait fifty frames before the alias continues. "wait 100" is roughly a second on a 100 FPS server.
  
Some servers disable the wait command. While playing on them, wait commands will be ignored, making some scripts susceptible to crashes. A script containing an indeterminate loop spaced by wait commands will always immediately hang upon usage on such servers.
+
Some servers disable the wait command. While playing on them, wait commands will be ignored, making some scripts susceptible to crashes. A script containing an indeterminate loop spaced by wait commands will always immediately hang upon usage on such servers.
[edit] Aliases
+
==Aliases==
  
An alias is like a variable that stores a series of commands which can be executed as a group. A simple alias will take the form:
+
An alias is like a variable that stores a series of commands which can be executed as a group. A simple alias will take the form:
  
alias "aliasname" "command1; command2; command3"
+
'''alias "aliasname" "command1; command2; command3"'''
  
 
You can then execute the commands through a bound key:
 
You can then execute the commands through a bound key:
  
bind "key" "aliasname"
+
'''bind "key" "aliasname"'''
  
 
Whenever the key is pressed, command1, command2, and command3 are executed in order.
 
Whenever the key is pressed, command1, command2, and command3 are executed in order.
[edit] Complex Aliases
 
  
Aliases can execute any command including other aliases. Furthermore, an alias can execute an alias in order to redefine that alias's commands. This allows you to create cycling aliases. Here is a very simple example:
+
===Complex Aliases===
  
bind "key" namescroll
+
Aliases can execute any command including other aliases.  Furthermore, an alias can execute an alias in order to redefine that alias's commands.  This allows you to create cycling aliases.  Here is a very simple example:
alias namescroll "firstname"
+
 
alias firstname "setinfo name "First_name"; alias namescroll secondname"
+
'''bind "key" namescroll'''<br>
alias secondname "setinfo name "Second_name"; alias namescroll thirdname"
+
'''alias namescroll "firstname" '''<br>
alias thirdname "setinfo name "Third-name"; alias namescroll firstname"
+
'''alias firstname "setinfo name "First_name"; alias namescroll secondname" '''<br>
 +
'''alias secondname "setinfo name "Second_name"; alias namescroll thirdname"'''<br>
 +
'''alias thirdname "setinfo name "Third-name"; alias namescroll firstname"'''<br>
  
 
This is difficult to read, so break it down.
 
This is difficult to read, so break it down.
  
    The first line binds "key" to an alias "namescroll" which we have yet to define.
+
*The first line binds "key" to an alias "namescroll" which we have yet to define.
    The second line creates the alias "namescroll" which executes the command "firstname"
+
*The second line creates the alias "namescroll" which executes the command "firstname"
    The third line defines the "firstname" alias as two commands:  
+
*The third line defines the "firstname" alias as two commands:
 +
:*The first command sets your in-game name to "First_name"
 +
:*The second command redefines the alias "namescroll" as an alias for executing the alias "secondname"
 +
*The fourth line defines "secondname" in the same manner.  A different in-game name is set, and then "namescroll" is redefined to another alias "thirdname"
 +
*The fifth line defines "thirdname" just like the two before it, but with a twist.  It redefines the "namescroll" alias as executing the "firstname" alias.
  
        The first command sets your in-game name to "First_name"
+
This completes a loop.  Each press of the key executes a command and redefines the alias bound to the key, so that when it is next pressed it will execute a different command.  If there were no loop, then the alias "namescroll" wouldn't always have another alias to execute with each keypress.
        The second command redefines the alias "namescroll" as an alias for executing the alias "secondname"
 
  
    The fourth line defines "secondname" in the same manner. A different in-game name is set, and then "namescroll" is redefined to another alias "thirdname"
+
===Alias Loops===
    The fifth line defines "thirdname" just like the two before it, but with a twist. It redefines the "namescroll" alias as executing the "firstname" alias.  
+
Aliases can be used in conjunction with the Wait command to create looping aliases.<br>
  
This completes a loop. Each press of the key executes a command and redefines the alias bound to the key, so that when it is next pressed it will execute a different command. If there were no loop, then the alias "namescroll" wouldn't always have another alias to execute with each keypress.
+
[edit] Alias Loops
+
''Warning:Not having the wait in place, or being on a server with wait disabled will cause this example to crash TF2.''<br>
 +
'''alias "Loop" "echo Looping every 150 ticks.;wait 150;Loop"'''<br>
 +
'''Loop'''<br>
  
Aliases can be used in conjunction with the Wait command to create looping aliases.
+
Lets break this down into components:<br>
 +
Line 1<br>
 +
The echo displays a message to the console, just so you know it works.<br>
 +
The wait makes it wait 150 ticks between iterations<br>
 +
Loop calls the alias again, restarting at the echo.<br>
 +
<br>
 +
Line 2<br>
 +
Loop starts the looping alias.<br>
  
 +
You can also create loops of alias commands, like this example:<br>
 +
'''alias "Loop1" "echo Loop 1;wait 150;Loop2"'''<br>
 +
'''alias "Loop2" "echo Loop 2;wait 150;Loop1"'''<br>
  
Warning:Not having the wait in place, or being on a server with wait disabled will cause this example to crash TF2.
+
Loop1 calls Loop2 which in turn calls Loop1, etc...<br>
alias "Loop" "echo Looping every 150 ticks.;wait 150;Loop"
+
This method can also be used for breaking a loop without clearing the loop alias:<br>
Loop
+
'''alias "Loop1" "echo Loop1;wait 150;Loop2"'''<br>
 +
'''alias "Loop2" "Loop1"'''<br>
 +
This would create a loop, then<br>
 +
'''alias "Loop2"'''<br>
 +
would break it, by clearing the Loop2 alias.<br>
  
Lets break this down into components:
+
You can use these for button presses(Via the +/- prefixes covered earlier) like this:<br>
Line 1
+
'''alias "Loop2" "Loop1"'''<br>
The echo displays a message to the console, just so you know it works.
+
'''alias "Loop1" "echo Loop1;wait 150;Loop2"'''<br>
The wait makes it wait 150 ticks between iterations
+
'''alias "+Loop" "alias Loop2 Loop1;Loop2"'''<br>
Loop calls the alias again, restarting at the echo.
+
'''alias "-Loop" "alias Loop2"'''<br>
 +
'''bind "<Key>" "+Loop"'''<br>
 +
In order of what it's doing:<br>
 +
Make Loop2 point to Loop1<br>
 +
Make Loop1 echo 'Loop1' to the console, wait 150, then call Loop2<br>
 +
make +Loop point Loop2 to Loop1 and run Loop2<br>
 +
make -Loop clear Loop2's link, breaking the loop<br>
  
Line 2
+
== Useful Script Commands ==
Loop starts the looping alias.
+
There are literally hundreds of different arguments for your script that can make them do almost anything. Here's a list of a few of them.
 
 
You can also create loops of alias commands, like this example:
 
 
 
alias "Loop1" "echo Loop 1;wait 150;Loop2"
 
 
 
alias "Loop2" "echo Loop 2;wait 150;Loop1"
 
 
 
Loop1 calls Loop2 which in turn calls Loop1, etc...
 
This method can also be used for breaking a loop without clearing the loop alias:
 
  
alias "Loop1" "echo Loop1;wait 150;Loop2"
+
===Voice Commands===
 
 
alias "Loop2" "Loop1"
 
 
 
This would create a loop, then
 
 
 
alias "Loop2"
 
 
 
would break it, by clearing the Loop2 alias.
 
 
 
You can use these for button presses(Via the +/- prefixes covered earlier) like this:
 
 
 
alias "Loop2" "Loop1"
 
 
 
alias "Loop1" "echo Loop1;wait 150;Loop2"
 
 
 
alias "+Loop" "alias Loop2 Loop1;Loop2"
 
 
 
alias "-Loop" "alias Loop2"
 
 
 
bind "<Key>" "+Loop"
 
 
 
In order of what it's doing:
 
Make Loop2 point to Loop1
 
Make Loop1 echo 'Loop1' to the console, wait 150, then call Loop2
 
make +Loop point Loop2 to Loop1 and run Loop2
 
make -Loop clear Loop2's link, breaking the loop
 
[edit] Useful Script Commands
 
 
 
There are literally hundreds of different arguments for your script that can make them do almost anything. Here's a list of a few of them.
 
[edit] Voice Commands
 
  
 
Voice command is the act of making your class say something, this is often used in gameplay as a way of either signaling information or just for goofing-off.
 
Voice command is the act of making your class say something, this is often used in gameplay as a way of either signaling information or just for goofing-off.
Line 285: Line 236:
 
Voice commands are used with the following syntax;
 
Voice commands are used with the following syntax;
  
voicemenu <menu_number> <phrase_number>
+
'''voicemenu <menu_number> <phrase_number>
  
 
Where <menu_number> is the one of the 3 menus where voice commands are spread out through <phrase_number> is one of the 7 voice commands that are within each <menu_number> menu.
 
Where <menu_number> is the one of the 3 menus where voice commands are spread out through <phrase_number> is one of the 7 voice commands that are within each <menu_number> menu.
[edit] Arguments for voice commands
 
  
    0 <phrase_number>
+
====Arguments for voice commands====
  
        0: Medic  
+
*0 <phrase_number>
        1: Thanks  
+
*:0: Medic
        2: Go  
+
*:1: Thanks
        3: Move Up  
+
*:2: Go
        4: Flank Left  
+
*:3: Move Up
        5: Flank Right  
+
*:4: Flank Left
        6: Yes  
+
*:5: Flank Right
        7: No  
+
*:6: Yes
 +
*:7: No
 +
*1 <phrase_number>
 +
*:0: Incoming
 +
*:1: Cloaked Spy
 +
*:2: Sentry Ahead
 +
*:3: Teleporter Here
 +
*:4: Dispenser Here
 +
*:5: Sentry Here
 +
*:6: Activate ÜberCharge
 +
*:7: (Medic Only) ÜberCharge Ready
 +
*2 <phrase_number>
 +
*:0: Help
 +
*:1: Battlecry
 +
*:2: Cheers
 +
*:3: Jeers
 +
*:4: Positive
 +
*:5: Negative
 +
*:6: Nice Shot
 +
*:7: Good Job
  
    1 <phrase_number>
+
===Quick Spy disguises===
 
 
        0: Incoming
 
        1: Cloaked Spy
 
        2: Sentry Ahead
 
        3: Teleporter Here
 
        4: Dispenser Here
 
        5: Sentry Here
 
        6: Activate ÜberCharge
 
        7: (Medic Only) ÜberCharge Ready
 
 
 
    2 <phrase_number>
 
 
 
        0: Help
 
        1: Battlecry
 
        2: Cheers
 
        3: Jeers
 
        4: Positive
 
        5: Negative
 
        6: Nice Shot
 
        7: Good Job
 
 
 
[edit] Quick Spy disguises
 
  
 
With these quick and easy commands, you can bind keys to specific disguises instead of having to flip through the disguise menu.
 
With these quick and easy commands, you can bind keys to specific disguises instead of having to flip through the disguise menu.
Line 329: Line 276:
 
Disguise commands are used with the following syntax;
 
Disguise commands are used with the following syntax;
  
disguise <class_number> <team_number>
+
'''disguise <class_number> <team_number>
  
 
Where <class_number> is the number of the class you wish to disguise as, and <team_number> the number of the team you wish to disguise as.
 
Where <class_number> is the number of the class you wish to disguise as, and <team_number> the number of the team you wish to disguise as.
[edit] Arguments for disguise commands
 
  
    1 <class_number>
+
====Arguments for disguise commands====
  
        1: Scout  
+
*1 <class_number>
        2: Sniper  
+
*:1: Scout
        3: Soldier  
+
*:2: Sniper
        4: Demoman  
+
*:3: Soldier
        5: Medic  
+
*:4: Demoman
        6: Heavy  
+
*:5: Medic
        7: Pyro  
+
*:6: Heavy
        8: Spy  
+
*:7: Pyro
        9: Engineer  
+
*:8: Spy
 +
*:9: Engineer
  
    2 <team_number>
+
*2 <team_number>
 +
*:1: BLU team
 +
*:2: RED team
 +
*:-1: Opposite team
 +
*:-2: Same team
  
        1: BLU team
+
===Engineer Quickbuilding===
        2: RED team
 
        -1: Opposite team
 
        -2: Same team
 
  
[edit] Engineer Quickbuilding
+
Similar to the [[Spy]]'s quick disguise, this allows the [[Engineer]] to bypass his [[PDA]] interface and instantly destroy an existing building type while simultaneously pulling up blueprints to place a new building of the same type.
 
 
Similar to the Spy's quick disguise, this allows the Engineer to bypass his PDA interface and instantly destroy an existing building type while simultaneously pulling up blueprints to place a new building of the same type.
 
  
 
Building commands are used with the following syntax:
 
Building commands are used with the following syntax:
  
build <building_number>
+
'''build <building_number><br>
destroy <building number>
+
'''destroy <building number>
  
 
Where <building_number> is the number of the building you wish to destroy or pull up blueprints for.
 
Where <building_number> is the number of the building you wish to destroy or pull up blueprints for.
[edit] Arguments for building commands
 
  
    Number: Building/Destroying
+
====Arguments for building commands====
 
+
*Number: Building/Destroying
        0: Dispenser  
+
*:0: Dispenser
        1: Teleporter Entrance  
+
*:1: Teleporter Entrance
        2: Sentry Gun/Minisentry  
+
*:2: Sentry Gun/Minisentry
        3: Teleporter Exit  
+
*:3: Teleporter Exit
  
 
An example of how to implement the above syntax is as follows:
 
An example of how to implement the above syntax is as follows:
  
 +
<pre>
 
alias sentry "destroy 2; build 2"
 
alias sentry "destroy 2; build 2"
 
alias dispenser "destroy 0; build 0"
 
alias dispenser "destroy 0; build 0"
Line 382: Line 328:
 
bind f3 entrance
 
bind f3 entrance
 
bind f4 exit
 
bind f4 exit
 +
</pre>
  
In this example buildings are bound to the f1-f4 keys so they do not interfere with weapon selection keys. When activated, the script will instantly and irreversibly destroy an existing building of the listed type while pulling up the Engineer's blueprints of the destroyed building's same type, ready to deploy. The script will still function if only one or two building types are used (in case you only want to map sentry quickbuilding to a single key).
+
In this example buildings are bound to the f1-f4 keys so they do not interfere with weapon selection keys. When activated, the script will instantly and irreversibly destroy an existing building of the listed type while pulling up the [[Engineer]]'s blueprints of the destroyed building's same type, ready to deploy. The script will still function if only one or two building types are used (in case you only want to map sentry quickbuilding to a single key).
[edit] Medic Autocall
 
  
 +
===Medic Autocall===
 
The Medic can control his autocall threshold through keybinds. The command is:
 
The Medic can control his autocall threshold through keybinds. The command is:
  
hud_medicautocallersthreshold <percentage>
+
'''hud_medicautocallersthreshold <percentage>
  
 
The percentage is the percent health below which the autocall is triggered; 0 will show nothing, while 150 will show all nearby allies (since 150% is the maximum possible health).
 
The percentage is the percent health below which the autocall is triggered; 0 will show nothing, while 150 will show all nearby allies (since 150% is the maximum possible health).
  
This command can be used to make the popular "Medic Radar" script: This set of aliases and commands will temporarily boost the Medic's autocall threshold to 150% (a fully-overhealed player)for as long as they hold a key down, allowing him to see where all of his teammates are by their Medic autocall speech bubbles in the event he finds himself alone.
+
This command can be used to make the popular "Medic Radar" script:
 +
This set of aliases and commands will temporarily boost the [[Medic]]'s autocall threshold to 150% (a fully-overhealed player)for as long as they hold a key down, allowing him to see where all of his teammates are by their [[Medic]] autocall speech bubbles in the event he finds himself alone.
  
alias "autocall_default" "hud_medicautocallersthreshold "75""
+
  '''alias "autocall_default" "hud_medicautocallersthreshold "75""<br>
 +
  '''alias "autocall_all" "hud_medicautocallersthreshold "150""<br>
 +
  '''alias "+radar" "autocall_all"<br>
 +
  '''alias "-radar" "autocall_default"<br>
 +
  '''bind mouse3 "+radar"<br>
  
alias "autocall_all" "hud_medicautocallersthreshold "150""
+
The default autocall value, or the autocall threshold when this command is not in use, can be adjusted to any desired number (in the example it is listed as 75% health) and the keybind to activate it can be changed as well (the example is bound to mouse3).
  
alias "+radar" "autocall_all"
+
==Noteworthy scripts==
  
  alias "-radar" "autocall_default"
+
There are several notable scripts that have affected gameplay. Some of these are patched out.  Others remain functional.
  
bind mouse3 "+radar"
+
===Patched Scripts===
  
The default autocall value, or the autocall threshold when this command is not in use, can be adjusted to any desired number (in the example it is listed as 75% health) and the keybind to activate it can be changed as well (the example is bound to mouse3).
+
====Pistol Scripts====
[edit] Noteworthy scripts
 
  
There are several notable scripts that have affected gameplay. Some of these are patched out. Others remain functional.
+
Originally, the [[Pistol]] could be fired almost as fast as the human hand could press a key.  Realizing this, some people created scripts that made the Pistol fire as rapidly as possible as long as you held down the fire button. This not only allowed the [[Scout]] and [[Engineer]] to fire faster than most people could manage, but it was easier to aim because you weren't mashing any keys.
[edit] Patched Scripts
 
[edit] Pistol Scripts
 
  
Originally, the Pistol could be fired almost as fast as the human hand could press a key. Realizing this, some people created scripts that made the Pistol fire as rapidly as possible as long as you held down the fire button. This not only allowed the Scout and Engineer to fire faster than most people could manage, but it was easier to aim because you weren't mashing any keys.
+
Valve eventually leveled the playing field.  They patched the Pistol to have a lower max firing rate, which was reached by default whenever a player held down the attack key. The Pistol scripts were no longer necessary.
  
Valve eventually leveled the playing field. They patched the Pistol to have a lower max firing rate, which was reached by default whenever a player held down the attack key. The Pistol scripts were no longer necessary.
+
====Targe Turn Scripts====
[edit] Targe Turn Scripts
 
  
Originally, the keyboard commands to turn your viewpoint left and right were not treated the same as the mouse commands. The Chargin' Targe was the first weapon to create a restriction on how quickly you could turn your viewpoint, therefore Valve put a limit on mouse turn-speed but forgot to apply the same restriction to the keyboard command that resulted in the same action.
+
Originally, the keyboard commands to turn your viewpoint left and right were not treated the same as the mouse commands. The [[Chargin' Targe]] was the first weapon to create a restriction on how quickly you could turn your viewpoint, therefore Valve put a limit on mouse turn-speed but forgot to apply the same restriction to the keyboard command that resulted in the same action.
  
Players made scripts that rebound keys whenever a player charged, allowing them to turn at full speed. The most sophisticated examples temporarily rebound the mouse x-axis inputs to the keyboard turn commands, then unbound them when the player attacked at the end of the charge.
+
Players made scripts that rebound keys whenever a player charged, allowing them to turn at full speed. The most sophisticated examples temporarily rebound the mouse x-axis inputs to the keyboard turn commands, then unbound them when the player attacked at the end of the charge.
  
 
Valve eventually capped the keyboard turn commands as they did with the mouse commands, thus conferring no advantage to individuals who used the script.
 
Valve eventually capped the keyboard turn commands as they did with the mouse commands, thus conferring no advantage to individuals who used the script.
  
 
However, it is still possible to write a script that will toggle Sensitivity between insanely high values when charging and normal value when the player performs an attack. It is also possible to turn easily while using a gamepad's analog sticks.
 
However, it is still possible to write a script that will toggle Sensitivity between insanely high values when charging and normal value when the player performs an attack. It is also possible to turn easily while using a gamepad's analog sticks.
[edit] Air Crouching Scripts
 
  
Originally, you could crouch as many times as you liked in a single jump. By binding a script to crouch and uncrouch as rapidly as possible, you could exploit the engine and make it difficult to properly register shots on jumping targets.
+
====Air Crouching Scripts====
 +
 
 +
Originally, you could crouch as many times as you liked in a single jump. By binding a script to crouch and uncrouch as rapidly as possible, you could exploit the engine and make it difficult to properly register shots on jumping targets.
  
 
Valve patched it so you could only crouch twice in a single jump.
 
Valve patched it so you could only crouch twice in a single jump.
[edit] Current Scripts
 
[edit] Weapon Hiding Scripts
 
  
There are a large number of scripts which toggle the weapon display option depending on which weapon slot is selected for a class. Players often make their guns invisible to clear up the screen, but make items like melee weapons, PDAs, watches and so forth visible because these models indicate important information. For example, the Spy relies heavily on his visible model to determine when he is cloaked, when his Cloak is disturbed, and when the Dead Ringer activates. Other classes use the melee animations to judge when their attacks will hit.
+
===Current Scripts===
[edit] Sentry Jumping Scripts
+
 
 +
====Weapon Hiding Scripts====
 +
 
 +
There are a large number of scripts which toggle the weapon display option depending on which weapon slot is selected for a class. Players often make their guns invisible to clear up the screen, but make items like melee weapons, PDAs, watches and so forth visible because these models indicate important information. For example, the [[Spy]] relies heavily on his visible model to determine when he is cloaked, when his Cloak is disturbed, and when the [[Dead Ringer]] activates. Other classes use the melee animations to judge when their attacks will hit.
  
Since the Engineer update, Engineers have been able to pack up and carry their Sentry Guns. Simultaneously, the Wrangler allowed Engineers to Sentry jump with their Sentry rockets. With extremely fast inputs, it was discovered that a player could Sentry jump and successfully pack up their Sentry before they were launched away.
+
====Sentry Jumping Scripts====
  
While a human can repeat this feat, it's difficult and sometimes inconsistent. Some players made scripts which could reliably execute the commands in the right order at the right speed. They can make a Sentry jump while carrying their Sentry every time.
+
Since the [[Engineer]] update, Engineers have been able to pack up and carry their [[Sentry Gun]]s.  Simultaneously, the [[Wrangler]] allowed Engineers to [[Sentry jump]] with their Sentry rockets.  With extremely fast inputs, it was discovered that a player could Sentry jump and successfully pack up their Sentry before they were launched away.
[edit] Gunslinger Scripts
+
 
 +
While a human can repeat this feat, it's difficult and sometimes inconsistent. Some players made scripts which could reliably execute the commands in the right order at the right speed. They can make a Sentry jump while carrying their Sentry every time.
 +
 
 +
====Gunslinger Scripts====
  
 
Since it can be troublesome to destroy then rebuild a Combat Mini-Sentry in the heat of battle through the PDA, some players have scripted the destruction and rebuilding of their Mini-Sentry with the click of one or two mouse buttons.
 
Since it can be troublesome to destroy then rebuild a Combat Mini-Sentry in the heat of battle through the PDA, some players have scripted the destruction and rebuilding of their Mini-Sentry with the click of one or two mouse buttons.
[edit] Sensitivity and Control Scripts
 
  
Some players prefer different mouse sensitivities and control schemes for some classes (for example, changing from Demo, which doesn't require fine aiming, to Sniper, which encourages low sensitivity for precise aiming so a hand twitching inadvertently won't ruin your aim too much). These scripts alter their control schemes and mouse settings on a per class or even per weapon basis.
+
====Sensitivity and Control Scripts====
[edit] Charge Dash Scripts
+
 
 +
Some players prefer different mouse sensitivities and control schemes for some classes (for example, changing from Demo, which doesn't require fine aiming, to Sniper, which encourages low sensitivity for precise aiming so a hand twitching inadvertently won't ruin your aim too much). These scripts alter their control schemes and mouse settings on a per class or even per weapon basis.
 +
 
 +
====Charge Dash Scripts====
 +
Since timing the charge and jump can be difficult, some may use a quick script that binds the two actions to a button so that the charge dash will do the maximum amount of distance possible.  The user is still required to swing their melee weapon normally to end the charge though.
  
Since timing the charge and jump can be difficult, some may use a quick script that binds the two actions to a button so that the charge dash will do the maximum amount of distance possible. The user is still required to swing their melee weapon normally to end the charge though.
+
====Quickscope Scripts====
[edit] Quickscope Scripts
 
  
 
Many players find it difficult to scope in, and fire right after to get a quick head shot. There are scripts that will zoom in, and fire just by clicking one mouse button. It may be harder to aim for some people, because you must aim outside of the scope, but it speeds up how fast you fire if you can aim well.
 
Many players find it difficult to scope in, and fire right after to get a quick head shot. There are scripts that will zoom in, and fire just by clicking one mouse button. It may be harder to aim for some people, because you must aim outside of the scope, but it speeds up how fast you fire if you can aim well.
[edit] See Also
 
  
    List of useful console commands
+
==See Also==
    Customizing - config_default.cfg: The default key-binds within TF2.  
+
* [[List of useful console commands]]
 +
* [[Customizing#tf.5Ccfg.5Cconfig default.cfg|Customizing - config_default.cfg]]: The default key-binds within TF2.
  
[edit] External Links
+
==External Links==
  
    Steam Users' Forums - TF2 Scripting Tutorial. This covers the basics of scripting, using numerous useful, approachable examples.
+
*[http://forums.steampowered.com/forums/showthread.php?t=709568 Steam Users' Forums - TF2 Scripting Tutorial]. This covers the basics of scripting, using numerous useful, approachable examples.
    TF2 scripting tutorial - Warrior Nation Network. This is a much more advanced article, which requires pre-requisite knowledge of the basic scripting syntax.
+
*[http://warriornation.net/Forum/showthread.php?t=568008 TF2 scripting tutorial - Warrior Nation Network]. This is a much more advanced article, which requires pre-requisite knowledge of the basic scripting syntax.  
    Gamebanana.com - TF2 scripts. Hundreds of scripting examples for TF2.
+
*[http://www.gamebanana.com/scripts/games/297 Gamebanana.com - TF2 scripts]. Hundreds of scripting examples for TF2.
 +
[[Category:Customization]]

Revision as of 11:38, 13 August 2011

'Skryptowanie' jest użyciem plików konfiguracyjnych do tworzenia nowych bindów oraz aliasów do tworzenia złożonych operacji oraz sekwencji konsolowych komend. Scripting is the use of configuration files to create new keybinds and aliases automating complex behaviors and console command sequences.

  • Keybind przypisuje przycisk do komendy konsolowej, na przykład: wybieranie slotu broni czy w celu szybkiego napisania wcześniej oskrypotwanego tekstu.
  • Aliasy tworzą nowe komendy poprzez realizowanie paru komend jednocześnie. Aliasu można użyć do np: wykonania skoku i kucnięcia przy użyciu jednego przycisku.

These scripts range in complexity from simple lists of commands to self-referential loops and nested aliases that redefine one another. With enough time and effort, you can use the tools to create almost any behavior available to the client at the press of a single key.

Podstawowe pliki skryptowania

Team Fortress 2 automatycznie czyta kilka plików gry i odtwarza bindy i aliasy w środku. Oto lista tych plików:

  • config.cfg - Jest to domyślny plik konfiguracyjny, który jest edytowany kiedykolwiek gracz zmienia przypisania klawiszy lub opcje grafiki. Nawet jeżeli edytowanie tego pliku jest bezpieczne, najlepiej zostawić go w spokoju.
  • autoexec.cfg - Jest to domyślny plik konfiguracyjny używany do odtwarzania niestandardowych bindów i aliasów. Gracz może tu wpisać swoje bindy do tego pliku jednak często jest tak, że łatwiej jest stworzyć osobny plik .cfg do pozostałych skryptów, które poźniej można odtworzyć w tym pliku.
  • <klasa>.cfg - Każda klasa ma plik konfiguracyjny który automatycznie odtwarza się gdy gracz zaczyna grać jedną z tych klas. Można wpisać tam swoje bindy bezpośrednio do tego pliku, jednak często jest tak, że łatwiej jest stworzyć osobny plik .cfg który później odtwarza się w tym pliku.

Składnia

Lista zasad składni:

  • Żeby jakikolwiek bind czy alias działał poprawnie, musisz użyć tego formatu:
komenda <argument1> <argument2>
  • komenda jest typem skryptu którego chcesz użyć:
  • bind - Używany do przypisania komendy do jakiegoś przycisku
  • alias - Used to execute commands when the alias is executed.
  • exec - Używany do odtworzenia komend automatycznie po załadowaniu pliku konfiguracyjnego.
  • <argument1> może być albo przypisywanym przyciskiem lub nazwą stworzonego aliasu
  • <argument2> może być komendą przypisywaną do przycisku lub komendy odtwarzane przez alias.
  • Aby uruchomić parę komend jednocześnie, musimy postawić cały argument w cudzysłowach oraz oddzielić komendy apostrofem:
alias "walnaslepo" "+attack; wait 500; -attack"
bind "mouse3" "walnaslepo"
  • Podczas odtwarzania, alias zaczyna strzelać z broni gracza, kontynuuje przez 500 fizycznych klatek (jest to 5 sekund jeżeli gracz gra na serwerze który działa na 100 FPS) po czym przestaje strzelać. Alias jest przypisany aby rozpocząć strzelanie po wciśnięciu kółka myszy.
  • To enclose something in quotes that already has quotes in it, you have to escape the internal quotes by using two consecutive quotes ("") in place of each one.
alias "saysomestuff" "say ""Some Stuff..."""
  • When you type saysomestuff in the console, you will speak "Some Stuff..." in the chat. Without the internal quotes, the chat window will only show "Some".

Keybinds

Team Fortress 2 allows scripts and aliases to be bound to any key on the keyboard. The key you wish to bind a command to is placed after your bind command and before the action you want the key to execute, as in the section above. Most keys are self-explanatory, as all alphanumerics (a-z, 0-9) and function keys are simply listed by typing that key ("bind a" binds a key to "a", "bind 5" binds to "5" and "bind f7" binds to "f7"). Other keys require you type specific names into your .cfg file in order to access them, and these names are not all obvious. A list of these keys is provided below:

List of Key Names

  • Keyboard Keys: Names of Keybinds
  • Left Shift: SHIFT
  • Left Ctrl: CTRL
  • Left Alt: ALT
  • Right Shift: RSHIFT
  • Right Control: RCTRL
  • Right Alt: RALT
  • Tab: TAB
  • Backspace: BACKSPACE
  • ---
  • Insert: INS
  • Scroll Lock: SCROLLLOCK
  • Pause/Break: NUMLOCK
  • ---
  • Home: HOME
  • End: END
  • Delete: DEL
  • Page Up: PGUP
  • Page Down: PGDN
  • ---
  • Up Arrow: UPARROW
  • Down Arrow: DOWNARROW
  • Left Arrow: LEFTARROW
  • Right Arrow: RIGHTARROW
  • Numpad Keys: Names of Keybinds
  • 0: KP_INS
  • 1: KP_END
  • 2: KP_DOWNARROW
  • 3: KP_PGDN
  • 4: KP_LEFTARROW
  • 5: KP_5
  • 6: KP_RIGHTARROW
  • 7: KP_HOME
  • 8: KP_UPARROW
  • 9: KP_PGUP
  • Enter: KP_ENTER
  • ".": KP_DEL
  • "+": KP_PLUS
  • "-": KP_MINUS
  • "*": KP_MULTIPLY
  • "/":KP_SLASH
  • Mouse Wheel Direction: Names of Keybinds
  • Mouse Wheel Up: MWHEELUP
  • Mouse Wheel Down: MWHEELDOWN

Using the above keynames you can place the following example command into one of your config files: <bind KP_ENTER "voicemenu 0 1">. When you hit Enter on your Numpad in-game you will trigger the "Thanks" voice command.

Basic Commands

Most commands accept a single argument, which is whatever value you want to execute.

bind "q" "sv_alltalk 1"

A handful of important commands accept multiple arguments. Here are some examples:

  • disguise X Y - This disguises the Spy. X is the class numbered 1 through 9 and Y is the team numbered 1 or 2.
  • voicemenu X Y - This executes a voice command. X is the number of the primary menu. Y is the command position in that menu.

Example: "voicemenu 1 1" is the command for Spy, so:

bind "t" "voicemenu 1 1"

This command will make your character yell Spy whenever you hit the key.

Incrementvar

This command cycles through a range of specified values whenever it executes and applies those values to another command. This has the form of:

command "<argument1>" "incrementvar <argument2> X Y Z"
  • X and Y represent the range of values you want to execute with <argument2>.
  • Z is the size of the step you want to make while you cycle through the range.

If you wanted a value range of 1 through 10 and you wanted to increment your value by 2 each time the command was executed, you'd make X Y Z into 1 10 2. Then each time it executes, <argument2> will execute with an incrementing value of 2, 4, 6, 8, 10, 2, 4, 6, 8, 10... and so forth.

Here is a real example of incrementvar in action:

bind "n" "incrementvar net_graphpos 1 3 1"

This binds the key "n" to cycle to the next position in the 3 available net_graph positions.

The + and - commands

These commands have two states. While the bound key is pressed, the +command executes and continues to execute. When the key is released, the -command executes and continues to execute.

Example:

bind "c" "+duck"

This +command is bound to "c" so whenever the key is pressed, the player ducks. Whenever the key is released, +duck is swapped to -duck and the player stops ducking.

In general, if a command or alias is bound to a key, a + tells the game to run the command as long as the key is held. Similarly, if a command or alias is bound to a key, a - tells the game to run the command when the key is released.

If an alias is defined with a + in front of it, the alias will be run whenever the key is pressed, as the key is pressed. The - command will then run as the key is released.

Wait Command

If you want the game to delay for a period of time during an alias, or if you want avoid client crashes caused by executing commands too quickly, use the wait command.

Wait tells the game to delay the next command in the script by one physics frame, something like a full turn in the TF2 rules. It accepts values such as "wait 50" which tells the game to wait fifty frames before the alias continues. "wait 100" is roughly a second on a 100 FPS server.

Some servers disable the wait command. While playing on them, wait commands will be ignored, making some scripts susceptible to crashes. A script containing an indeterminate loop spaced by wait commands will always immediately hang upon usage on such servers.

Aliases

An alias is like a variable that stores a series of commands which can be executed as a group. A simple alias will take the form:

alias "aliasname" "command1; command2; command3"

You can then execute the commands through a bound key:

bind "key" "aliasname"

Whenever the key is pressed, command1, command2, and command3 are executed in order.

Complex Aliases

Aliases can execute any command including other aliases. Furthermore, an alias can execute an alias in order to redefine that alias's commands. This allows you to create cycling aliases. Here is a very simple example:

bind "key" namescroll
alias namescroll "firstname"
alias firstname "setinfo name "First_name"; alias namescroll secondname"
alias secondname "setinfo name "Second_name"; alias namescroll thirdname"
alias thirdname "setinfo name "Third-name"; alias namescroll firstname"

This is difficult to read, so break it down.

  • The first line binds "key" to an alias "namescroll" which we have yet to define.
  • The second line creates the alias "namescroll" which executes the command "firstname"
  • The third line defines the "firstname" alias as two commands:
  • The first command sets your in-game name to "First_name"
  • The second command redefines the alias "namescroll" as an alias for executing the alias "secondname"
  • The fourth line defines "secondname" in the same manner. A different in-game name is set, and then "namescroll" is redefined to another alias "thirdname"
  • The fifth line defines "thirdname" just like the two before it, but with a twist. It redefines the "namescroll" alias as executing the "firstname" alias.

This completes a loop. Each press of the key executes a command and redefines the alias bound to the key, so that when it is next pressed it will execute a different command. If there were no loop, then the alias "namescroll" wouldn't always have another alias to execute with each keypress.

Alias Loops

Aliases can be used in conjunction with the Wait command to create looping aliases.


Warning:Not having the wait in place, or being on a server with wait disabled will cause this example to crash TF2.
alias "Loop" "echo Looping every 150 ticks.;wait 150;Loop"
Loop

Lets break this down into components:
Line 1
The echo displays a message to the console, just so you know it works.
The wait makes it wait 150 ticks between iterations
Loop calls the alias again, restarting at the echo.

Line 2
Loop starts the looping alias.

You can also create loops of alias commands, like this example:

alias "Loop1" "echo Loop 1;wait 150;Loop2"
alias "Loop2" "echo Loop 2;wait 150;Loop1"

Loop1 calls Loop2 which in turn calls Loop1, etc...
This method can also be used for breaking a loop without clearing the loop alias:

alias "Loop1" "echo Loop1;wait 150;Loop2"
alias "Loop2" "Loop1"

This would create a loop, then

alias "Loop2"

would break it, by clearing the Loop2 alias.

You can use these for button presses(Via the +/- prefixes covered earlier) like this:

alias "Loop2" "Loop1"
alias "Loop1" "echo Loop1;wait 150;Loop2"
alias "+Loop" "alias Loop2 Loop1;Loop2"
alias "-Loop" "alias Loop2"
bind "<Key>" "+Loop"

In order of what it's doing:
Make Loop2 point to Loop1
Make Loop1 echo 'Loop1' to the console, wait 150, then call Loop2
make +Loop point Loop2 to Loop1 and run Loop2
make -Loop clear Loop2's link, breaking the loop

Useful Script Commands

There are literally hundreds of different arguments for your script that can make them do almost anything. Here's a list of a few of them.

Voice Commands

Voice command is the act of making your class say something, this is often used in gameplay as a way of either signaling information or just for goofing-off.

Voice commands are used with the following syntax;

voicemenu <menu_number> <phrase_number>

Where <menu_number> is the one of the 3 menus where voice commands are spread out through <phrase_number> is one of the 7 voice commands that are within each <menu_number> menu.

Arguments for voice commands

  • 0 <phrase_number>
    0: Medic
    1: Thanks
    2: Go
    3: Move Up
    4: Flank Left
    5: Flank Right
    6: Yes
    7: No
  • 1 <phrase_number>
    0: Incoming
    1: Cloaked Spy
    2: Sentry Ahead
    3: Teleporter Here
    4: Dispenser Here
    5: Sentry Here
    6: Activate ÜberCharge
    7: (Medic Only) ÜberCharge Ready
  • 2 <phrase_number>
    0: Help
    1: Battlecry
    2: Cheers
    3: Jeers
    4: Positive
    5: Negative
    6: Nice Shot
    7: Good Job

Quick Spy disguises

With these quick and easy commands, you can bind keys to specific disguises instead of having to flip through the disguise menu.

Disguise commands are used with the following syntax;

disguise <class_number> <team_number>

Where <class_number> is the number of the class you wish to disguise as, and <team_number> the number of the team you wish to disguise as.

Arguments for disguise commands

  • 1 <class_number>
    1: Scout
    2: Sniper
    3: Soldier
    4: Demoman
    5: Medic
    6: Heavy
    7: Pyro
    8: Spy
    9: Engineer
  • 2 <team_number>
    1: BLU team
    2: RED team
    -1: Opposite team
    -2: Same team

Engineer Quickbuilding

Similar to the Spy's quick disguise, this allows the Engineer to bypass his PDA interface and instantly destroy an existing building type while simultaneously pulling up blueprints to place a new building of the same type.

Building commands are used with the following syntax:

build <building_number>
destroy <building number>

Where <building_number> is the number of the building you wish to destroy or pull up blueprints for.

Arguments for building commands

  • Number: Building/Destroying
    0: Dispenser
    1: Teleporter Entrance
    2: Sentry Gun/Minisentry
    3: Teleporter Exit

An example of how to implement the above syntax is as follows:

alias sentry "destroy 2; build 2"
alias dispenser "destroy 0; build 0"
alias entrance "destroy 1; build 1"
alias exit "destroy 3; build 3"
bind f1 sentry
bind f2 dispenser
bind f3 entrance
bind f4 exit

In this example buildings are bound to the f1-f4 keys so they do not interfere with weapon selection keys. When activated, the script will instantly and irreversibly destroy an existing building of the listed type while pulling up the Engineer's blueprints of the destroyed building's same type, ready to deploy. The script will still function if only one or two building types are used (in case you only want to map sentry quickbuilding to a single key).

Medic Autocall

The Medic can control his autocall threshold through keybinds. The command is:

hud_medicautocallersthreshold <percentage>

The percentage is the percent health below which the autocall is triggered; 0 will show nothing, while 150 will show all nearby allies (since 150% is the maximum possible health).

This command can be used to make the popular "Medic Radar" script: This set of aliases and commands will temporarily boost the Medic's autocall threshold to 150% (a fully-overhealed player)for as long as they hold a key down, allowing him to see where all of his teammates are by their Medic autocall speech bubbles in the event he finds himself alone.

 alias "autocall_default" "hud_medicautocallersthreshold "75""
alias "autocall_all" "hud_medicautocallersthreshold "150""
alias "+radar" "autocall_all"
alias "-radar" "autocall_default"
bind mouse3 "+radar"

The default autocall value, or the autocall threshold when this command is not in use, can be adjusted to any desired number (in the example it is listed as 75% health) and the keybind to activate it can be changed as well (the example is bound to mouse3).

Noteworthy scripts

There are several notable scripts that have affected gameplay. Some of these are patched out. Others remain functional.

Patched Scripts

Pistol Scripts

Originally, the Pistol could be fired almost as fast as the human hand could press a key. Realizing this, some people created scripts that made the Pistol fire as rapidly as possible as long as you held down the fire button. This not only allowed the Scout and Engineer to fire faster than most people could manage, but it was easier to aim because you weren't mashing any keys.

Valve eventually leveled the playing field. They patched the Pistol to have a lower max firing rate, which was reached by default whenever a player held down the attack key. The Pistol scripts were no longer necessary.

Targe Turn Scripts

Originally, the keyboard commands to turn your viewpoint left and right were not treated the same as the mouse commands. The Chargin' Targe was the first weapon to create a restriction on how quickly you could turn your viewpoint, therefore Valve put a limit on mouse turn-speed but forgot to apply the same restriction to the keyboard command that resulted in the same action.

Players made scripts that rebound keys whenever a player charged, allowing them to turn at full speed. The most sophisticated examples temporarily rebound the mouse x-axis inputs to the keyboard turn commands, then unbound them when the player attacked at the end of the charge.

Valve eventually capped the keyboard turn commands as they did with the mouse commands, thus conferring no advantage to individuals who used the script.

However, it is still possible to write a script that will toggle Sensitivity between insanely high values when charging and normal value when the player performs an attack. It is also possible to turn easily while using a gamepad's analog sticks.

Air Crouching Scripts

Originally, you could crouch as many times as you liked in a single jump. By binding a script to crouch and uncrouch as rapidly as possible, you could exploit the engine and make it difficult to properly register shots on jumping targets.

Valve patched it so you could only crouch twice in a single jump.

Current Scripts

Weapon Hiding Scripts

There are a large number of scripts which toggle the weapon display option depending on which weapon slot is selected for a class. Players often make their guns invisible to clear up the screen, but make items like melee weapons, PDAs, watches and so forth visible because these models indicate important information. For example, the Spy relies heavily on his visible model to determine when he is cloaked, when his Cloak is disturbed, and when the Dead Ringer activates. Other classes use the melee animations to judge when their attacks will hit.

Sentry Jumping Scripts

Since the Engineer update, Engineers have been able to pack up and carry their Sentry Guns. Simultaneously, the Wrangler allowed Engineers to Sentry jump with their Sentry rockets. With extremely fast inputs, it was discovered that a player could Sentry jump and successfully pack up their Sentry before they were launched away.

While a human can repeat this feat, it's difficult and sometimes inconsistent. Some players made scripts which could reliably execute the commands in the right order at the right speed. They can make a Sentry jump while carrying their Sentry every time.

Gunslinger Scripts

Since it can be troublesome to destroy then rebuild a Combat Mini-Sentry in the heat of battle through the PDA, some players have scripted the destruction and rebuilding of their Mini-Sentry with the click of one or two mouse buttons.

Sensitivity and Control Scripts

Some players prefer different mouse sensitivities and control schemes for some classes (for example, changing from Demo, which doesn't require fine aiming, to Sniper, which encourages low sensitivity for precise aiming so a hand twitching inadvertently won't ruin your aim too much). These scripts alter their control schemes and mouse settings on a per class or even per weapon basis.

Charge Dash Scripts

Since timing the charge and jump can be difficult, some may use a quick script that binds the two actions to a button so that the charge dash will do the maximum amount of distance possible. The user is still required to swing their melee weapon normally to end the charge though.

Quickscope Scripts

Many players find it difficult to scope in, and fire right after to get a quick head shot. There are scripts that will zoom in, and fire just by clicking one mouse button. It may be harder to aim for some people, because you must aim outside of the scope, but it speeds up how fast you fire if you can aim well.

See Also

External Links