This neat script allows you to cancel a vote of yes or no within five seconds. To cancel, press the opposite vote key. If you wish to skip the delay and vote straight away press the key twice. The best part is, if you cancel your vote you can still change your mind! Now, DES|GeneralDisarray made more than half of this but the basic idea is mine :D
http://gibstick.pastebin.com/p3DwBwmy
http://one.zeelot.webfactional.com/forum...post_25091
http://gibstick.pastebin.com/p3DwBwmy
http://one.zeelot.webfactional.com/forum...post_25091
[SELECT ALL] Code:
//Delayed vote script by DES|GeneralDisarray and Gibstick
// 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]
//Useless technical notes
//Script uses alias variables to determine the current voting state. If one is changed then the action is different, that is how the vote is "cancelled". But it is impossible to cancel a sleep and we ran into this problem. So GD came up with the miraculous and ingenious solution to use a timestamp to associate one F1/F2 with another. :D