logo Scripting for Enemy Territory

Menu


Home
Tutorials
Downloads
Forum
Contact

Friends





Advanced tutorial 1

Two commands under one key.

I often hear a lot of people complaining about having so many binds, but they still want to add more. Well you can. You'll need to know how to use the +vstr command explained in the tenth tutorial of the basic scripting tutorial section.

Let's say you have 6 basic vsay commands in your config at this moment:
bind 1 "vsay hi"
bind 2 "vsay bye"
bind 3 "vsay sorry"
bind 4 "vsay Affirmative"
bind 5 "vsay Negative"
bind 6 "vsay Oops"

These are all global chats and thus heard by everyone. Maybe you sometimes want use these for your team only. If you have a lot of scripts and binds, you might not even have another 6 keys left. You actually only need 1 extra, so we can make a key combination. Just like being able to cut text in Word with CTRL + x.

For this example I'll use CTRL as that extra key. So we want to create a script that makes it possible to use the 6 binds in combination with CTRL and make the binds teams vsays instead of vsays. My way of doing this is the easiest imo, but not the only way.



First we start of by placing the vsays above in a seperate cfg file. Let's call it vsay.cfg. We also place all the team vsays in a seperate cfg file. We will call that vsayteam.cfg. So we now have 2 files with the following content:

vsay.cfg

bind 1 "vsay hi"
bind 2 "vsay bye"
bind 3 "vsay sorry"
bind 4 "vsay Affirmative"
bind 5 "vsay Negative"
bind 6 "vsay Oops"

vsayteam.cfg

bind 1 "vsay hi"
bind 2 "vsay_team bye"
bind 3 "vsay_team sorry"
bind 4 "vsay_team Affirmative"
bind 5 "vsay_team Negative"
bind 6 "vsay_team Oops"

Now we have to make the script to activate these cfg files. We want vsay.cfg to be activated when CTRL is NOT pressed down and we want vsayteam.cfg to be activated when CTRL is pressed down. So we have to bind CTRL to a +vstr command. This little script can either be placed in your autoexec.cfg or in a seperate cfg file which you of course then exec from your autoexec file as well. This script is as followed:
bind CTRL "+vstr ctrldown ctrlup"
set ctrldown "exec vsayteam.cfg"
set ctrlup "exec vsay.cfg"

So now when you keep CTRL pressed down, the vsayteam.cfg file is executed and thus all binds in that cfg are activated. If you let go of CTRL again, vsay.cfg will be executed and thus all binds in vsay.cfg will be activated. That's all there is to it.

Note:This script is in the download section too.

Back to the tutorial list