r/Tf2Scripts • u/Hatts456 • Aug 07 '20
Resolved creating multi-key binds (ie shift+alt=call for medic)
I am making my own spy.cfg file, and i have bound the keypad to the corresponding enemy disguises, but i want to make it so that if i press the 0 key on the keypad and then one of the numbers it disguises as a player on my team, i looked it up and put in the code it said i should, but whenever i press the key it crashes my game, this is the code i put in.
bind KP_END disguise
alias disguise disguise_enemy
alias disguise_enemy "disguise 1 -1"
alias disguise_friendly "disguise 1 -2"
bind shift +toggleState
alias +toggleState "alias disguise_friendly"
alias -toggleState "alias disguise_enemy"
1
u/tf2junior Aug 07 '20 edited Aug 07 '20
It crashes because you've created an infinite loop. "alias disguise disguise_enemy" overrides the disguise command, so disguise_enemy becomes "dusguise_enemy 1 -1". It calls itself over and over again until the game crashes.
Also you've got the +-toggleState aliases a bit wrong. Here's how it should have looked:
bind kp_end disguise_scout
bind shift +friendly_disguise // a bit more descriptive than toggleState
alias +friendly_disguise "alias disguise_scout disguise 1 -2; alias disguise_sniper disguise 2 -2"
alias -friendly_disguise "alias disguise_scout disguise 1 -1; alias disguise_sniper disguise 2 -1"
+friendly_disguise // so that disguise_scout is set even before you press shift for the first time
1
u/pdatumoj Aug 08 '20
As u/tf2junior notes, "disguise" is an existing command in the game - which you then try to use - and bad things happen. Also, you need rig the toggle to affect each disguise.
Anyway, I was hoping an alias could be used to just flip the -1 / -2 parts of it via how TF2 does alias substitution, but it doesn't seem to like that ... so the solution has to be spelled out more, apparently ... either that or I'm just too tired to get it right the other way right now. Anyway I brewed this up, but, fair warning, I just wrote this off the cuff for this reply and IT IS UNTESTED.
I wrote this with a literal interpretation of what you wrote above, BTW, so when you hit 0 on the keypad it'll change the team that's used for the disguising until the next time you hit 0, which will switch it again. If you want it to instead require 0 be held down while hitting the other key, that's an easy change. Also, as noted in the code, I laid this out to use the traditional TF2 class numbering - i.e. 2 gets you soldier, 8 gets you sniper, etc... Your initial post was vague on which layout you meant you wanted, so I went with the more common one.