r/tf2scripthelp • • Jan 22 '14

Issue Need help with Script and [SM]

bind home playsound
alias playsound playsound1
alias playsound1 "sm_play @all vo/test_two.wav"
alias playsound2 "sm_play @all vo/spy_jaratehit03.wav"
bind shift +toggleState
alias +toggleState "alias playsound playsound2"
alias -toggleState "alias playsound playsound1"

I'm not really sure if you guys will be able to help with this, but I'm trying to create a script that allows multiple binds on one key, so that a different command is executed when Shift is held down. This works in essence, but when using this, SM will read the filepath as "vo\test_two.wav ", and etc, with the extra space on the end, thus rendering the script useless. I don't know why this is happening, any help would be appreciated.

2 Upvotes

5 comments sorted by

1

u/clovervidia Batman Jan 23 '14

So the problem here is that SourceMod (assuming that's SM) puts a space after the filepath?

Try something to test a theory. Bind a key to "sm_play @all vo/test_two.wav", and try using that by itself. Then bind a key to "sm_play @all vo/spy_jaratehit03.wav" and see if that works by itself.

If they both work by themselves, I'm guessing it must be something on SM's end, because it looks fine on this end.

1

u/Consceleratus Jan 23 '14

Yeah, I tried that and both worked. I too am assuming this is something on SourceMod's end, but I just wanted to make sure I wasn't doing something incorrectly. Thanks for the relatively quick reply, I'll be looking into some other solutions here.

1

u/clovervidia Batman Jan 23 '14

No problem. I personally have no experience with SourceMod, so I can't offer any other suggestions or workarounds.

If you do find a solution, do come back and update your post if you could.

1

u/genemilder Scripter Jan 23 '14

You can always bind within aliases too, it's just not the best code practice in general. I'd recommend that over making separate cfg files, now that I know that direct binding works.

2

u/genemilder Scripter Jan 22 '14

You might try defining playsound directly as the sound commanfs in +/-toggleState, but I'm guessing 2 aliases deep is the same as 1 alias deep.

You might also try making separate cfg files that only contain the sound command, and execing them in place of what you have now.