dynamic key binding

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
{R.E.D}**Duke Justice**
Lance Corporal
Posts: 23
Joined: Thu Aug 07, 2003 9:09 pm

dynamic key binding

Post by {R.E.D}**Duke Justice** »

Hello y'all

I have a question regarding dynamic binding.

Suppose I have the keyboard key "k" bound to the "screenshot" command. But At times, I would like to have it bound to "dropweapon". I would like these dunctions to be toggled by the key "o".

Could anyone suggest me how to go about this.

Regards

Duke
Last edited by {R.E.D}**Duke Justice** on Thu Aug 21, 2003 12:47 am, edited 1 time in total.
Image
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

lol I don't know if you can use if statements in .cfg files... You'll need 2 keys that switch them. like this

bind k "screenshot"

bind a "bind k screenshot"
bind s "bind k dropweapon"
{R.E.D}**Duke Justice**
Lance Corporal
Posts: 23
Joined: Thu Aug 07, 2003 9:09 pm

Post by {R.E.D}**Duke Justice** »

Thank you Alcoholic for your prompt answer.

It works just fine.

Is there a way to use the same key and use it as a toggle? Like a fast nades script that exists?

Here is an example:
alias hf1 "hud_fastswitch 1"
alias hf0 "hud_fastswitch 0"
alias fgren grenadeon
alias grenadeon "bind mouse2 +gren; alias fgren grenadeoff; locationprint 10 360 "*****Fast-Nades-On*******"
alias grenadeoff "bind mouse2 +attacksecondary; alias fgren grenadeon; locationprint 10 360 "*****Fast-Nades-Off*******"
alias +gren "hf1; useweaponclass grenade; hf0"
alias -gren "hf1; uselast; hf0"
bind x "fgren"

Thanks in advance if you can help. And thanks again for your post.

Regards

Duke
Last edited by {R.E.D}**Duke Justice** on Thu Aug 21, 2003 12:47 am, edited 1 time in total.
Image
User avatar
CorporalPunishment
Sergeant
Posts: 62
Joined: Mon May 19, 2003 5:25 am

Post by CorporalPunishment »

You can use alias command to do it:


alias SSon "bind k screenshot: alias Switch SSoff"
alias SSoff "bind k dropweapon: alias Switch SSon"

alias Switch "SSon"

finally bind the Switch:

bind s "Switch"


So the S key becomes the toggle key
{R.E.D}**Duke Justice**
Lance Corporal
Posts: 23
Joined: Thu Aug 07, 2003 9:09 pm

Post by {R.E.D}**Duke Justice** »

Hey great idea.

Works like a charm.


Regards

Duke
Image
Post Reply