Delayed vote script: gives you a 5 second grace period to cancel your vote. To cancel, press the opposite vote button. To vote before then, just vote again.
[SELECT ALL] Code:
// Reset the aliases just in case
cancelallvotes = [ votingno = 0; votingyes = 0; votetimestamp = 0]
cancelallvotes
vote_exec1 = [ vote 1; echo "0You voted yes"; cancelallvotes ]
vote_exec2 = [ vote 2; echo "3You voted no"; cancelallvotes ]
// $arg1 = millis
delayed_vote = [
// only bother if we're actually due
if (= ($votetimestamp) ($arg1) ) [
if (= ($votingyes) 1) [ vote_exec1 ]
if (= ($votingno) 1) [ vote_exec2 ]
] [
echo "All this wait for nothing..."
]
]
delayed_vote_start = [ votetimestamp = (millis); sleep 5000 [ delayed_vote votetimestamp ] ]
delayvote1 = [
if (= ($votingyes) 1) [
// voting yes when already have voted yes, do it immediately
vote_exec1
] [
if (= ($votingno) 1) [
// changed mind, cancel
echo "6You cancelled your F2"; cancelallvotes
] [
// normal/first vote
echo "Voting YES in five seconds!"; votingyes = 1; delayed_vote_start
]
]
]
delayvote2 = [
if (= ($votingno) 1) [
// voting no when already have voted no, do it immediately
vote_exec2
] [
if (= ($votingyes) 1) [
// changed mind, cancel
echo "6You cancelled your F1"; cancelallvotes
] [
// normal/first vote
echo "Voting NO in five seconds!"; votingno = 1; delayed_vote_start
]
]
]
bind "F1" [delayvote1]
bind "F2" [delayvote2]