Script Contest
#17
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
//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
Thanks given by:


Messages In This Thread
Script Contest - by Mael - 17 Jul 10, 11:23PM
RE: Script Contest - by V-Man - 17 Jul 10, 11:29PM
RE: Script Contest - by DrauL - 18 Jul 10, 05:06AM
RE: Script Contest - by Bukz - 18 Jul 10, 06:15AM
RE: Script Contest - by V-Man - 18 Jul 10, 02:29PM
RE: Script Contest - by Dreamer - 19 Jul 10, 03:04AM
RE: Script Contest - by #M|A#Wolf - 19 Jul 10, 03:10AM
RE: Script Contest - by V-Man - 19 Jul 10, 03:11AM
RE: Script Contest - by Mael - 19 Jul 10, 03:36AM
RE: Script Contest - by V-Man - 19 Jul 10, 06:35PM
RE: Script Contest - by Dreamer - 19 Jul 10, 08:09PM
RE: Script Contest - by V-Man - 19 Jul 10, 10:11PM
RE: Script Contest - by DrauL - 20 Jul 10, 07:25AM
RE: Script Contest - by Orynge - 20 Jul 10, 09:10AM
RE: Script Contest - by V-Man - 20 Jul 10, 08:47PM
RE: Script Contest - by Alien - 21 Jul 10, 11:50AM
RE: Script Contest - by Gibstick - 21 Jul 10, 11:31PM
RE: Script Contest - by DrauL - 22 Jul 10, 10:18AM
RE: Script Contest - by Ronald_Reagan - 26 Jul 10, 01:54AM
RE: Script Contest - by DrauL - 26 Jul 10, 03:21AM
RE: Script Contest - by |FmC|Aqua_3m - 26 Jul 10, 02:10PM
RE: Script Contest - by Ronald_Reagan - 26 Jul 10, 08:58PM
RE: Script Contest - by V-Man - 26 Jul 10, 09:29PM
RE: Script Contest - by Dreamer - 27 Jul 10, 05:09AM
RE: Script Contest - by DrauL - 27 Jul 10, 06:00AM
RE: Script Contest - by V-Man - 27 Jul 10, 02:37PM
RE: Script Contest - by RIPBillyMays - 27 Jul 10, 06:16PM
RE: Script Contest - by V-Man - 28 Jul 10, 11:34PM
RE: Script Contest - by Ronald_Reagan - 29 Jul 10, 05:53AM
RE: Script Contest - by DrauL - 01 Aug 10, 07:48AM