Upvote Upvoted 0 Downvote Downvoted
need help with tf2 scripting
posted in Q/A Help
1
#1
0 Frags +

i'm trying to make a viewmodel script so when i hit q to switch between active and last weapon slot (i.e. quick switch from original to shotgun), my original viewmodel is on, but my shotgun viewmodel is off, similar to a normal weapon slot switcher that uses 1, 2, and 3

i tried a bindtoggle using some aliases, but that did nothing, so help making it work would be great

alias "primary" "slot 1; r_drawviewmodel 1"
alias "secondary" "slot 2; r_drawviewmodel 0"
bindtoggle "q" "primary; secondary"

i'm trying to make a viewmodel script so when i hit q to switch between active and last weapon slot (i.e. quick switch from original to shotgun), my original viewmodel is on, but my shotgun viewmodel is off, similar to a normal weapon slot switcher that uses 1, 2, and 3

i tried a bindtoggle using some aliases, but that did nothing, so help making it work would be great

alias "primary" "slot 1; r_drawviewmodel 1"
alias "secondary" "slot 2; r_drawviewmodel 0"
bindtoggle "q" "primary; secondary"
2
#2
3 Frags +

alias "primary" "slot1;r_drawviewmodel 1;bind q secondary"
alias "secondary" "slot2;r_drawviewmodel 0;bind q primary"
bind q "primary"

alias "primary" "slot1;r_drawviewmodel 1;bind q secondary"
alias "secondary" "slot2;r_drawviewmodel 0;bind q primary"
bind q "primary"
3
#3
2 Frags +

That's not how bindtoggles work, they only work by changing cvars' values. They don't really work with straight up commands, or alternate between them, like you're trying to do.

You're sorta close with it if it were a regular bind actually, but the 'bind q "slot1;slot2"' trick (which is fine if you only do the slots) only works because of a quirk with switching weapons, which doesn't extend to aliases. The game would interpret pressing q as "try to switch weapons, set r_drawviewmodel to 1, try to switch weapons, set r_drawviewmodel to 0" and will always set it to r_drawviewmodel 0 because of that.

You'd need to add some actual toggle logic to it, such as:

alias "primary" "slot1; r_drawviewmodel 1; alias switch1and2 secondary"
alias "secondary" "slot2; r_drawviewmodel 0; alias switch1and2 primary"
alias "switch1and2" "secondary"
bind "q" "switch1and2"

That is assuming that you always use "primary" and "secondary" to go to that weapon, and you don't want your melee to change that up any (as it currently is: use primary, go to melee, pressing q will go to secondary).

My goto crosshair switcher for reference: http://gamebanana.com/scripts/8541
It doesn't immediately support what you're asking for but is a good base for that sorta thing.

smakersalias "primary" "slot1;r_drawviewmodel 1;bind q secondary"
alias "secondary" "slot2;r_drawviewmodel 0;bind q primary"
bind q "primary"

Binding within an alias is perfectly valid, but isn't really good practice. It'll fuck things up bad if someone ever wants to switch the bind and forgets within the alias, or wants to bind it to multiple keys. It's a pretty small adjustment to go through an alias, but is a lot more portable if you ever want to change things later or re-use it or anything like that.

That's not how bindtoggles work, they only work by changing cvars' values. They don't really work with straight up commands, or alternate between them, like you're trying to do.

You're sorta close with it if it were a regular bind actually, but the 'bind q "slot1;slot2"' trick (which is fine if you only do the slots) only works because of a quirk with switching weapons, which doesn't extend to aliases. The game would interpret pressing q as "try to switch weapons, set r_drawviewmodel to 1, try to switch weapons, set r_drawviewmodel to 0" and will always set it to r_drawviewmodel 0 because of that.

You'd need to add some actual toggle logic to it, such as:
[code]alias "primary" "slot1; r_drawviewmodel 1; alias switch1and2 secondary"
alias "secondary" "slot2; r_drawviewmodel 0; alias switch1and2 primary"
alias "switch1and2" "secondary"
bind "q" "switch1and2"[/code]
That is assuming that you always use "primary" and "secondary" to go to that weapon, and you don't want your melee to change that up any (as it currently is: use primary, go to melee, pressing q will go to secondary).

My goto crosshair switcher for reference: http://gamebanana.com/scripts/8541
It doesn't immediately support what you're asking for but is a good base for that sorta thing.

[quote=smakers]alias "primary" "slot1;r_drawviewmodel 1;bind q secondary"
alias "secondary" "slot2;r_drawviewmodel 0;bind q primary"
bind q "primary"[/quote]
Binding within an alias is perfectly valid, but isn't really good practice. It'll fuck things up bad if someone ever wants to switch the bind and forgets within the alias, or wants to bind it to multiple keys. It's a pretty small adjustment to go through an alias, but is a lot more portable if you ever want to change things later or re-use it or anything like that.
Please sign in through STEAM to post a comment.