Upvote Upvoted 1 Downvote Downvoted
Scripting help
posted in Q/A Help
1
#1
0 Frags +

First off, Sorry if this should be posted somewhere else.

So right now my soldier cfg has this line in it
"bind "mwheelup" "slot1;r_drawviewmodel 0"
Which obviously means that mwheel up will select my primary weapon and also hide the viewmodel. Well I want to be able to change that bind to bind "mwheelup" "slot1;r_drawviewmodel 1" So that instead mwheelup selects the primary and shows the viewmodel. I could just type it into console but instead I want to just be able to toggle between the two commands with the push of a button.

In other words "bind "mwheelup" "slot1;r_drawviewmodel 0"
push the 1 button so it changes to
bind "mwheelup" "slot1;r_drawviewmodel 1"
push 1 button again and it changes back to
bind "mwheelup" "slot1;r_drawviewmodel 0"

If it works out that I have to use a different button to change back to the original setting then that is also fine.

First off, Sorry if this should be posted somewhere else.

So right now my soldier cfg has this line in it
"bind "mwheelup" "slot1;r_drawviewmodel 0"
Which obviously means that mwheel up will select my primary weapon and also hide the viewmodel. Well I want to be able to change that bind to bind "mwheelup" "slot1;r_drawviewmodel 1" So that instead mwheelup selects the primary and shows the viewmodel. I could just type it into console but instead I want to just be able to toggle between the two commands with the push of a button.

In other words "bind "mwheelup" "slot1;r_drawviewmodel 0"
push the 1 button so it changes to
bind "mwheelup" "slot1;r_drawviewmodel 1"
push 1 button again and it changes back to
bind "mwheelup" "slot1;r_drawviewmodel 0"

If it works out that I have to use a different button to change back to the original setting then that is also fine.
2
#2
3 Frags +

bind <key> +toggle1 //(name this whatever, just make sure it doesn't interfere with anything you already have)
alias +toggle1 "mwheelup" "slot1;r_drawviewmodel 1;bind <key> toggle0"
alias +toggle0 "mwheelup" "slot1;r_drawviewmodel 0;bind <key> toggle1"

I haven't tested this, but I think it should work. Someone who is more familiar with scripting should correct me.

bind <key> +toggle1 //(name this whatever, just make sure it doesn't interfere with anything you already have)
alias +toggle1 "mwheelup" "slot1;r_drawviewmodel 1;bind <key> toggle0"
alias +toggle0 "mwheelup" "slot1;r_drawviewmodel 0;bind <key> toggle1"

I haven't tested this, but I think it should work. Someone who is more familiar with scripting should correct me.
3
#3
2 Frags +

Tested and working.

bind MWHEELUP prim
bind 1 primt

alias prim prim0
alias primt primt1
alias primt0 "alias prim prim0; alias primt primt1"
alias primt1 "alias prim prim1; alias primt primt0"

alias prim0 "slot1;r_drawviewmodel 0"
alias prim1 "slot1;r_drawviewmodel 1"
mr64bitbind <key> +toggle1 //(name this whatever, just make sure it doesn't interfere with anything you already have)
alias +toggle1 "mwheelup" "slot1;r_drawviewmodel 1;bind <key> toggle0"
alias +toggle0 "mwheelup" "slot1;r_drawviewmodel 0;bind <key> toggle1"

I haven't tested this, but I think it should work. Someone who is more familiar with scripting should correct me.

What you have here is close, "mwheelup" "slot1;r_drawviewmodel 1;bind <key> toggle0" isn't valid syntax(you need a "bind" first), you can only bind one command to a key or alias when binding inside an alias(so you bind an alias to an alias), and you should never use the "bind" command in an alias, it makes them hard to modify and is bad form(pull them out to the top with an alias instead, you only need to change one binding, and you don't need to know how the scipt works to change the key its bound on)

Tested and working.
[code]bind MWHEELUP prim
bind 1 primt

alias prim prim0
alias primt primt1
alias primt0 "alias prim prim0; alias primt primt1"
alias primt1 "alias prim prim1; alias primt primt0"

alias prim0 "slot1;r_drawviewmodel 0"
alias prim1 "slot1;r_drawviewmodel 1"
[/code]

[quote=mr64bit]bind <key> +toggle1 //(name this whatever, just make sure it doesn't interfere with anything you already have)
alias +toggle1 "mwheelup" "slot1;r_drawviewmodel 1;bind <key> toggle0"
alias +toggle0 "mwheelup" "slot1;r_drawviewmodel 0;bind <key> toggle1"

I haven't tested this, but I think it should work. Someone who is more familiar with scripting should correct me.[/quote]

What you have here is close, "mwheelup" "slot1;r_drawviewmodel 1;bind <key> toggle0" isn't valid syntax(you need a "bind" first), you can only bind one command to a key or alias when binding inside an alias(so you bind an alias to an alias), and you should never use the "bind" command in an alias, it makes them hard to modify and is bad form(pull them out to the top with an alias instead, you only need to change one binding, and you don't need to know how the scipt works to change the key its bound on)
4
#4
0 Frags +

Thank you arknoid and thank you mr64bit for trying.

Thank you arknoid and thank you mr64bit for trying.
Please sign in through STEAM to post a comment.