Half-Life Console Help


Lag-Proofing Your Scripts
Replace wait statements in all of your scripts with an alias, say w1, and multiple occurances of wait (places you wanted a little more delay than one wait) with another alias, say w2, and so on (the example below only goes up to w12, but the idea can be expanded easily if you need to).

Place the following script in your autoexec.cfg. Change 'x' to any key or button you like, then use that key to cycle through normal, slow, and fast script execution depending on your connection speed and quality. 

alias w5 "wait; wait; wait; wait; wait"
alias w10 "w5; w5"
alias w20 "w10; w10; "
alias w30 "w20; w10"

alias b1 "wait"
alias b2 "wait; wait"
alias b3 "wait; wait; wait"
alias b4 "wait; wait; wait; wait"

alias w1 "b1"
alias w3 "b3"
alias w6 "w3; w3"
alias w9 "w3; w6"
alias w12 "w6; w6"

alias switch1 "bind / switch2; alias w3 b2; alias w1 b1"
alias switch2 "bind / switch3; alias w3 b3; alias w1 b1"
alias switch3 "bind / switch1; alias w3 b4; alias w1 b2"

switch2 // starts off with "normal" speeds
bind x switch3

Just in case this is hard to follow, here's exactly what happens:

When you're in "normal" speed mode, anywhere you use the alias w1 (instead of one or more wait's) will result in one wait, w3 produces 3 waits, etc. In "slow" speed mode, however, w1 results in TWO waits (because w1 = b2, and b2 = "wait; wait") and w3 results in FOUR waits, etc. "Fast" speed mode leaves w1 as one wait, but reduces w2 to two waits. So, you have five different relative wait times (w1, w3, w6, w9, w12) to use in your scripts, and you can vary how much delay these wait times provide by pressing a key in-game. Just in case you're still confused, the following table shows exactly how many wait's you get for each of the aliases (w1 - w12) under each of the three network conditions (which you can select with the 'x' key).
 

 
network speed
alias fast normal slow
w1 1 wait 1 wait 2 waits
w3 2 waits 3 waits 4 waits
w6 4 waits 6 waits 8 waits
w9 8 waits 9 waits 12 waits
w12 8 waits 12 waits 16 waits

If you've ever tweaked a script to perfection, and then had it fail miserably one day when your ping was higher than normal, you'll immediately appreciate the usefulness of this method. 

If you're paying attention, you might be wondering "How can I keep track of which speed mode I'm in?" Easy -- just make your script talk to you. We'll enhance the lag-proofing script with some feedback messages in the next section after we learn how to do that.
 
[Previous Page] [Back to Console Index] [Next Page]