r/Tf2Scripts • • Oct 07 '19

Answered Sapper Script Not Working.

So recently I started getting into scripting so that I could make a script that when pressing "2" on my keyboard I pull out the sapper, use it, then switch back.

bind 2 "+sap"
    alias +sap "-attack; slot2; +attack"
    alias -sap "lastinv; -attack"

This is what I came up with. It works perfectly unless I swung my knife or shot my gun right before switching. It will pull out the sapper, but not use it unless I click. How can I fix this? (By the way I am very new to scripting.)

EDIT:

Here's my solution:

bind mouse1 "+normal_attack"
    alias +normal_attack "+attack; alias -normal_attack -attack"
    alias -normal_attack "-attack"
bind 2 "+sap"
    alias +sap_attack "+attack"
    alias -sap_attack "-attack"
    alias +sap "slot2; alias -normal_attack none; +sap_attack"
    alias -sap "lastinv; -sap_attack; alias -normal_attack -attack"

Here's Skaib1's solution:

bind "mouse1" "+imp_attack_m"
bind "<SAP BUTTON>" "+imp_attack_s"

alias "+imp_attack_m" "+attack; spec_next; alias check1 question_no"
alias "-imp_attack_m" "alias check1 none; stop_check"

alias "+imp_attack_s" "slot2; +attack; alias check2 question_no"
alias "-imp_attack_s" "lastinv; alias check2 none; stop_check"

alias "check2" "none"
alias "check1" "none"
alias "question_no" "alias stop_question none"
alias "stop_check" "alias stop_question -attack; check1; check2; stop_question"
6 Upvotes

5 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Oct 08 '19 edited Oct 08 '19

Thanks for helping me! The script didn't work though. Instead, I couldn't shoot my gun or swing my knife. But holding out my sapper would work until I switched back. Then, it would keep shooting.

EDIT: After looking through your script, I tried to come up with my own and it works! Here's what I got:

bind mouse1 "+normal_attack"
	alias +normal_attack "+attack; alias -normal_attack -attack"
	alias -normal_attack "-attack"
bind 2 "+sap"
	alias +sap_attack "+attack"
	alias -sap_attack "-attack"
	alias +sap "slot2; alias -normal_attack none; +sap_attack"
	alias -sap "lastinv; -sap_attack; alias -normal_attack -attack"

Thanks for the help!

2

u/Skaib1 Oct 08 '19

I found the typo! Here is a version that should work. Still on mobile... congrats on figuring it out yourself! This script allows sap->knife aswell and all possible combinations.

bind "mouse1" "+imp_attack_m"
bind "<SAP BUTTON>" "+imp_attack_s"

alias "+imp_attack_m" "+attack; spec_next; alias check1 question_no"
alias "-imp_attack_m" "alias check1 none; stop_check"

alias "+imp_attack_s" "slot2; +attack; alias check2 question_no"
alias "-imp_attack_s" "lastinv; alias check2 none; stop_check"

alias "check2" "none"
alias "check1" "none"
alias "question_no" "alias stop_question none"
alias "stop_check" "alias stop_question -attack; check1; check2; stop_question"