Volume control script
Posted: Mon Sep 08, 2008 11:31 pm
To easily control volume (or other variable) levels, cyclical aliasing works best: (hint: you can place the following code into a script file, such as your userconfig or hldj_custom.cfg)
This is something I just created now, so you may want to test it out and feel free to change the alias names or echos to anything you'd like. There may be better, more fancier "volume" scripts out there, but this one should get the job done nicely. You can copy/paste the same script and change all instances of "volume" to "voice_scale" if you wanted to adjust microphone volume only for example.
If you notice, the reason why they are called cyclic is because the alias "game_volume_up" and "game_volume_down" cycle through different values. This is just one example of how powerful cyclic aliases are (they are used extensively in many advanced scripts I've seen), and in general how powerful HL/HL2 scripting can be, especially when used in conjuction with HLDJ commands (although the above example contains only HL commands).
Code: Select all
// Renegade's volume script
// set initial volume to 0.5 (or whatever you want)
volume 0.5
// set initial up/down aliases to 75/25 (or whatever you want)
alias game_volume_up vol_75
alias game_volume_down vol_25
// for each volume level, set a new volume, echo what the current level is,
// and specifiy which is the next level up and down.
alias vol_0 "volume 0.00; echo volume 0%; alias game_volume_up vol_25; alias game_volume_down vol_0"
alias vol_25 "volume 0.25; echo volume 25%; alias game_volume_up vol_50; alias game_volume_down vol_0"
alias vol_50 "volume 0.50; echo volume 50%; alias game_volume_up vol_75; alias game_volume_down vol_25"
alias vol_75 "volume 0.75; echo volume 75%; alias game_volume_up vol_100; alias game_volume_down vol_50"
alias vol_100 "volume 1.00; echo volume 100%; alias game_volume_up vol_100; alias game_volume_down vol_75"
// binds keypad up/down arrows to volume up/down
// set to whatever keys you want
bind KP_UPARROW game_volume_up
bind KP_DOWNARROW game_volume_down
If you notice, the reason why they are called cyclic is because the alias "game_volume_up" and "game_volume_down" cycle through different values. This is just one example of how powerful cyclic aliases are (they are used extensively in many advanced scripts I've seen), and in general how powerful HL/HL2 scripting can be, especially when used in conjuction with HLDJ commands (although the above example contains only HL commands).