|
|
Alternate binds when holding a key Difficulty: Advanced |
| Category: CS:S > Scripting | Author(s): J2K |

//===================================
//Alternate bindings when holding a key (Shift + Key)!
//===================================
Hey all! Jay is back with another cool scripting tutorial! This one will teach you how to make scripts that can change what a key does while holding Ctrl, Alt or Shift!
For example, in Microsoft Word if you hit the s key, the letter s is displayed on screen. If you hold the Ctrl key and press s, it will save the document. We are going to learn how to mimic this behavior with some innovative scripting!
//===================================
//Part 1 - Choose your keys and commands.
//===================================
I'll try to keep this as simple as possible.
First of all, decide what key you will hold to change what your second key will do. For this example, i will use Ctrl.
Then decide on what key you want to use for two different commands, depending on whether or not the Ctrl key is being held.
//===================================
//Part 2 - The script
//===================================
For this example, I will be using the P key to buy grenades. Holding the Ctrl key will change which grenade is purchased when i press P.
alias flashy "buy flashbang;"
alias nadey "buy hegrenade;"
The above two commands give us shortcuts to buying the weapons later in the script, to keep things tidy.
alias +alternatebuys "bind P flashy;"
alias -alternatebuys "bind P nadey;"
+alternatebuys binds the P key to buy a flashbang, until the Ctrl key is released.
-alternatebuys binds the P key back to buying a HE Grenade, when the control key is released.
//===================================
//Part 3 - The binds
//===================================
Now we have come to the part where we have to bind our script. Be sure to use your own key selections from the script if you did not use the example keys!
bind ctrl +alternatebuys
bind P nadey
As you can see, the ctrl key now gives us the opportunity to make an alternate buy menu on the same keys as our standard buy menu! For a bigger, better example, check out my personal alternate buy menu script below!
PS: Don't forget, this is in no way limited to buy menus, you can use this in conjunction with any commands you wish!
//===================================
//Double buy menu by J2K!
//===================================
//Buy menu shortcuts
alias dgl "buy deagle;"
alias usp "buy usp;"
alias m4ak "buy m4a1; buy ak47;"
alias augsig "buy aug; buy sg552;"
alias scout "buy scout;"
alias mp5 "buy mp5;"
alias mactmp "buy mac10; buy tmp;"
alias awp "buy awp;"
alias refill "buy vest; buy vesthelm; buy defuser; buy secammo; buy primammo;"
alias refillmax "refill; buy hegrenade; buy smokegrenade; buy flashbang; buy flashbang;"
//The alternator
alias +buymenu2 "bind f refill2; bind c dgl; bind x augsig; bind z scout;"
alias -buymenu2 "bind f refill; bind c usp; bind x m4ak; bind z awp;"
//The binds
bind f refill
bind c usp
bind x m4ak
bind z awp
bind alt +buymenu2
That script above gives me 8 different buy scripts on 4 keys, and as you practice it becomes second nature to hold alt when buying if you want to access the second half of the buy menu.
Hope people enjoy this one!
Jay.
|
| Added: 1 year ago | Tags: multiple, alternate, binds |
 Add Feedback Provide constructive feedback. What is "constructive"?You cannot post yet!Get involved on FPSB by posting your thoughts. Give authors your feedback to help them develop. To post in this submission register or login. |
 You cannot assess yet!Moderating FPSB is in your hands - when you assess a submission your vote determines its success or failure. To vote on this submission register or login. This Tutorial in a nutshell... Handy & Well Written 2 x Handy 1 x Well Written 1 x Useful You cannot stamp yet!Stamps let you apply characteristics to submissions to help others understand them. To stamp this submission register or login.
 |
Sabotage Studios Originality, Creativity, Simplicity |
| Membership: On Request |
| Primary Skills: ? |
| Inception: 2 years ago |
Want more? Find related tuts. |