Jump to page:
Sponsors:
-------------------------------------------------------------------------------
V. SCRIPTING
-------------------------------------------------------------------------------
The last two sections have shown you how to bind and make aliases, now it's time to show you how to properly use these tools to make more complex scripts than simple binds.
WHICH TO CHOOSE? A +ALIAS OR A NORMAL ALIAS?
îîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîî
First, to explain things a bit more in detail than in the Basics section, there are 2 states a key can have: pressed and depressed. The +function is associated with the pressed state of the key while the -function is associated with its depressed state. Both + and - functions aren't continuous, they are only executed once. Normal functions are essentially +functions without a - counterpart. They don't necessarily have to be bound to keys, they can be used within aliases or invoked directly from the console.
With that in mind, normal aliases should be used for "one shot" scripts such as buy scripts. Multi-state scripts such as ON/OFF scripts or scripts that cycle through several options before looping back to the beginning require chain aliasing (for the lack of a better term). Scripts modifying existing functions or scripts you want to be press & hold require +aliases.
Of course, nothing prevents you from mixing them all together, but you shouldn't do that until you're very comfortable with simpler scripts. You'll have to be careful when mixing normal aliases, +aliases: if you're using +functions/+aliases inside a normal alias, you'll have to remember that you must invoke the -function counterpart somewhere.
By the way, don't be too fancy with alias names. Use letters, numbers and undercases ( _ ) only.
CHAIN ALIASING
îîîîîîîîîîîîîî
Chain aliasing is simply making a bunch of aliases, each refering to the next one in the order you want them to cycle. For example:
alias "say_stuff" "text1" alias "text1" "say A; alias say_stuff text2" alias "text2" "say B; alias say_stuff text3" alias "text3" "say C; alias say_stuff text1" bind "X" "say_stuff"
would make the X key say A on the first press. B on the second. C on the third.
A on the fourth and so on.
How does this work? First, the X key calls say_stuff. The say_stuff alias then points to the text1 alias that says "A" and then overrides say_stuff with a new alias of the same name, but this one points to text2 instead. And so on.
If you want the aliases to cycle endlessly, make the last one point to the first one. This is how you make multistate and ON/OFF scripts.
ENABLING MULTI-FUNCTION KEYS & MAKING YOUR OWN MENUS
îîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîî
They are other ways than chain aliasing to give keys multi-functions. You can either enable SHIFT+KEY, CTRL+KEY and ALT+KEY support or make your own menus. But first, SHIFT+KEY support.
SHIFT+KEY isn't really supported by the Half-Life engine, but you can pseudo-enable it by yourself. The concept here isn't very complicated: when the SHIFT key is pressed, you bind all the keys to their new functions, and when the key is depressed, you rebind all the keys to their default ones.
Simple enough? Here's a template as an example:
bind "SHIFT" "+shift_on" alias "+shift_on" "secondary_x; secondary_y; secondary_z" alias "-shift_on" "primary_x; primary_y; primary_z" alias "primary_x" "bind x ..." alias "primary_y" "bind y ..." alias "primary_z" "bind z ..." alias "secondary_x" "bind x ..." alias "secondary_y" "bind y ..." alias "secondary_z" "bind z ..."
This would enable SHIFT support for the X, Y and Z keys. Replace ... with anything you want the keys to do. Note that while this work rather well, you might experience some problems if you bind/rebind too many keys at once. By the way, you don't really have to use SHIFT/CTRL/ALT, you can use any other key if you wish.
Making your own menus is practically the same thing with a little difference: printing text on the screen. Indeed, it might be helpful if you forgot what your menu does.
To print text, you need to use the 'echo' command. However, the text will only be displayed in your console unless you turn developer mode on (developer 1). Here's a modified version of the previous example to turn it into a menu:
bind "X" "+menu_on" alias "+menu_on" "bind1; bind2; bind3; bind4; print_choices" alias "-menu_on" "rebind1; rebind2; rebind3; rebind4" alias "print_choices" "d_on; print4; print3; print2; print1; d_off" alias "print4" "echo 4th_choice_text_here" alias "print3" "echo 3rd_choice_text_here" alias "print2" "echo 2nd_choice_text_here" alias "print1" "echo 1st_choice_text_here" alias "d_on" "developer 1" alias "d_off" "developer 0" alias "bind1" "bind 1 choice1" alias "bind2" "bind 2 choice2" alias "bind3" "bind 3 choice3" alias "bind4" "bind 4 choice4" alias "rebind1" "bind 1 slot1" alias "rebind2" "bind 2 slot2" alias "rebind3" "bind 3 slot3" alias "rebind4" "bind 4 slot4" alias choice1 "..." alias choice2 "..." alias choice3 "..." alias choice4 "..."
Lots of aliases, I know. print4, print3, print2, print1, d_on and d_off aren't really necessary, it was just to make the print_choices alias less lengthy so it could fit in the format of this FAQ.
You could also turn the SHIFT & menu buttons into toggles if you want, but
I personally find the press & hold format more practical.
To be completed......
Jump to page:
Sponsors:
Other files from this game:
- Half-Life - Counterstrike document by System on 14/03/2006, 06:30
- Half-Life - Counterstrike trainer by System on 14/03/2006, 06:30
- Half-Life - Counterstrike document by System on 14/03/2006, 06:30
Buy-Script - Half-Life - Counterstrike document by System on 14/03/2006, 06:30
- Half-Life - Counterstrike hints by System on 09/03/2006, 09:50
- Half-Life - Counterstrike hints by System on 09/03/2006, 09:50
Weapons and Tactics Guide - Half-Life - Counterstrike FAQ by System on 09/03/2006, 09:50
Scripting FAQ - Half-Life - Counterstrike FAQ by System on 09/03/2006, 09:50
- Half-Life - Counterstrike FAQ by System on 09/03/2006, 09:50
- Half-Life - Counterstrike solution by System on 09/03/2006, 09:50
De_Dust2 Strategy Guide - Half-Life - Counterstrike FAQ by System on 09/03/2006, 09:50
- Half-Life - Counterstrike FAQ by System on 09/03/2006, 09:50
Weapon Fix FAQ






