r/tf2scripthelp • • Oct 09 '14

Question Voice Commands

Making a medic script and I want to bind certain keys for voice commands, but I also want them to say stuff in team chat

This is what I have, but it wont work

bind "mouse2" "+attack2; say_team ">>> UBER OR KRITZ USED<<<""

Also have stuff like ...

bind "f" "voicemenu 0 0; say_team ">>> I HAVE UBER<<<"" bind "shift" "voicemenu 1 7; say_team ">>> FAKE CALL<<<""

Can anyone help me and tell me why they do not work if you could that would be great!

1 Upvotes

3 comments sorted by

View all comments

Show parent comment

1

u/genemilder Scripter Oct 09 '14

It's tied into the way TF2 recognizes commands that are directly bound. Consider directly binding to a single + command/alias like this:

bind mouse2 +attack2

Pressing mouse2 activates +attack2 and releasing activates -attack2. When you have the bind only to +attack2 like above, TF2 also recognizes the spectator command (when in spectator mode).

Consider an alias bound like this:

bind mouse2 atk2
alias atk2 +attack2

You might think that this is the same as the above but it isn't; pressing mouse2 will activate +attack2 but releasing will do nothing because the + command is no longer directly bound. No spectator functionality is present for this version.

Note that the automatic +/- press/release for directly bound + commands is only for the first in the list, so consider this example:

bind mouse2 "+attack2; +jump"

In this, pressing mouse2 activates +attack2 and +jump, but releasing only activates -attack2 (and also +jump again for whatever reason). -jump is never called. IIRC the spectator functionality works here. Because of this odd behavior you want to avoid adding anything extra to a direct bind that starts with a + command and instead make a new +/- alias as I did earlier.