Sunday, October 10, 2010

How to script


Hi there. I'm gonna show you how to make scripts and binds.

All things mentioned here should be saved in your user config.
How you can make your own config? Where it should be placed?

Your TF2 cfg folder where you put all your configs should be located in:
C:\Program Files\Steam\steamapps\%accountame%\team fortress 2\tf\cfg
C:\Program Files\Valve\Steam\steamapps\%accountame%\team fortress 2\tf\cfg
Where %accountname% is your Steam login.

To save your config as a cfg file when you are saving file pick from file type dropdown All files (*.*), but when you are using this method you need to type file name and extension. For exapmle myconfig.cfg

Now open autoexec.cfg
and add a line 
exec configname
where configname is name of config that you have chosen recently.

In your CFG folder you can find configs with class names in titles, they are executed every time you select that class.

Numpad key names
"KP_MINUS"        Minus
"KP_PLUS"         Plus 
"KP_Enter"        Enter
"KP_DEL"          ,
"KP_INS"          0
"KP_END"          1
"KP_DOWNARROW"    2
"KP_PGDN"         3
"KP_LEFTARROW"    4
"KP_5"            5
"KP_RIGHTARROW"   6
"KP_HOME"         7
"KP_UPARROW"      8
"KP_PGUP"         9
"KP_SLASH"        /
"KP_MULTIPLY"     *

Binding is basically assigning commands to keys
bind "key" "command"

If you want to assign multiple commands divide them by ;
bind "key" "command; command; command"

Example №1: You want to bind reload to a specified key:
bind "key" "+reload"

Example №2: You want to bind taunt and explode commands to same key
bind "key" "taunt; wait 30; explode"

Incrementvar
That command allows you cycle between specified values on chosen range.
bind "key" "incrementvar command 1 12 3
(where 1 and 12 is range and 3 is jump between values)

Example №1: You want to change sensitivity from one to twenty with 2 points jump.
bind "key" "incrementvar sensitivity 1 20 2"
Example №2: You want to switch between 3 basic net_graph positions with one click.

bind "key" "incrementvar net_graphpos 1 3 1"


Aliasing
Alias command allows you to shorten very long commands into one short alias.
alias nameofyourscript "firstalias"
alias firstalias "command; command; alias nameofyourscript secondalias" 
alias secondalias "command; command; alias nameofyourscript thirdalias"
alias thirdalias "command; alias nameofyourscript firstalias" //last alias should point to first one

Note: you can use as many aliases as you want, same with commands. 

Example №1: Lets say that we want a name changing script.
alias namescr "firstname" 
alias firstname "setinfo name "First_name"; alias namescr secondname" 
alias secondname "setinfo name "Second_name"; alias namescr thirdname"
alias thirdname "setinfo name "Third-name"; alias namescr firstname"

bind "key" namescr

Note: That script does not allow spaces in names, if you want space in your nick look below.

Example №2: Duck script. Second example will be a duck script that will allow you to duck without holding a key.
alias duck "duckON"
alias duckON "+duck; alias duck duckOFF"
alias duckOFF "-duck; alias duck duckON"
bind "key" "duck"

10 comments:

  1. Wow thanks that was a really useful guide.

    ReplyDelete
  2. should be useful for all the scrubs that don't have experience scripting :)

    ReplyDelete
  3. Very interesting, too bad i honestly...didn't even get the jist but i will attempt too now thankyou!

    ReplyDelete
  4. thats a cool way of looking at it!

    ReplyDelete