rendered paste bodyon *:text:!vote*:#: {
if ($1 == %c $+ vote) && ($nick == r0ad_2_h3ll $chan))
if ($2 == $null) { .msg $nick $cl Command incomplete. Syntax: %c $+ vote <question>. | halt }
if %vote [ $+ [ $chan ] ] !== $null { msg $chan A vote is currently held. | halt }
set %vote [ $+ [ $chan ] ] $2-
msg $chan $chan Please vote! Question: $2-
msg $chan To vote please use 3 $+ %c $+ Yes or 5 $+ %c $+ No. You have 35 seconds to do so.
.timer 1 35 _vote $chan
}
}
on *:text:*yes:#: {
if $1 == %c $+ yes {
if %vote [ $+ [ $chan ] ] == $null { halt }
if $istok($nick,%voted- [ $+ [ $chan ] ],32) { rep $nick has already voted | halt }
inc %yes [ $+ [ $chan ] ]
set %voted- [ $+ [ $chan ] ] %voted- [ $+ [ $chan ] ] $nick
}
}
on *:text:*no:#: {
if $1 == %c $+ no {
if %vote [ $+ [ $chan ] ] == $null { halt }
if $istok($nick,%voted- [ $+ [ $chan ] ],32) { rep $nick has already voted | halt }
inc %no [ $+ [ $chan ] ]
set %voted- [ $+ [ $chan ] ] %voted- [ $+ [ $chan ] ] $nick
}
}
alias _vote {
;Syntax: /_vote <#channel>
;Action: displays vote results for <#channel>
var %yes = %yes [ $+ [ $1 ] ]
var %no = %no [ $+ [ $1 ] ]
var %total = $calc(%yes + %no)
var %yes-p = $round($calc(%yes / %total * 100),2)
var %no-p = $round($calc(%no / %total * 100),2)
msg $1 Vote is over! Question was: %vote [ $+ [ $1 ] ]
msg $1 [7Total votes $+ $iif(%total == $null,0,%total) $+ ] 3Yes $+ $iif(%yes == $null,0,%yes) $+ ( $+ %yes-p $+ $chr(37) $+ ) 5No $+ $iif(%no == $null,0,%no) $+ ( $+ %no-p $+ $chr(37) $+ )
unset %vote [ $+ [ $1 ] ] %voted- [ $+ [ $1 ] ] %no [ $+ [ $1 ] ] %yes [ $+ [ $1 ] ]