Selects a random winner from the channel to win whatever prize you specify.
!winner to choose a winner
!prize * to set prize
!clprize to clear prize
;###### RANDOM WINNER SELECTOR SCRIPT - BY HENRY COLE ######
;###### MORE INFO & HELP IN #HENCO ON IRC.INFINITYIRC.COM ######
on *:text:!winner:#: {
set %nick1 $nick($chan,$rand(1,$nick($chan,0)))
if (%nick1 == $me) { set %nick1 $nick($chan,$rand(1,$nick($chan,0))) }
msg $chan Randomly selecting a winner........
timerlawl 1 1 msg $chan The winner is %nick1 $+ ! Congratulations %nick1 :) You win... %prize. [ $+ [ $network ] $+ ] . [ $+ [ $chan ] ]
}
on *:text:!prize *:#: {
if ($nick isop $chan) {
set %prize. [ $+ [ $network ] $+ ] . [ $+ [ $chan ] ] $2-
msg $chan New prize set!
}
}
on *:text:!clprize:#: {
if ($nick isop $chan) {
set %prize. [ $+ [ $network ] $+ ] . [ $+ [ $chan ] ] Nothing
msg $chan Prize cleared!
}
}
Jethro, can you do the script so only ops can use it and it just says The Winner Is: (nick) leaving out the prize details, thanks :)
on *:text:$($iif(!winner = $strip($1),$1)):#:{
if ((!%f) && ($nick isop #)) {
inc -u2 %f
:r
var %x 1
while $nick(#,$r(%x,$nick(#,0,a,r))) {
if $v1 = $me { goto r }
else {
tokenize 32 $v1
scon -r .msg $!chan Congratulations, the winner is $* $!+ !
}
inc %x
}
}
}
Syntax: !winner
I don't know why you see them as symbols, but the point is, it works. Though I understand why you said that. I've seen and heard people say the same thing when they don't understand something, such as regular expressions for instance, which use achors, octal numbers, etc... The scripting language that can only be interpreted by a regex processor. For those who don't have a clue about regex, they wind up seeing them as a "load of craps."
You only need one text event, and here is my take on your script:
on $*:text:/^!((cl)?prize|winner)/iS:#: {
if (!%f) { set -u3 %f $true | goto $iif($replace($regml(1),winner,w,prize,p,clprize,clp),$ifmatch)
:w | var %x = 1 | while ($nick(#,$r(%x,$nick(#,0)))) { if ($ifmatch = $me) { goto r }
else { set -e %a $ifmatch | tokenize 32 %a | .msg # Congratulations, the winner is $str($*,1) , $&
and you win the prize: $iif($($+(%,prize.,$network,.,#),2),$ifmatch,nothing) } | inc %x | halt }
:p | if ($nick isop #) { set $+(%,prize.,$network,.,#) $$2- | .msg # New prize set for $+(",$2,") | halt }
:clp | if ($nick isop #) { unset $+(%,prize.,$network,.,#) | .msg # Prize Cleared! | halt }
:r | .msg # Congratulations, the winner is %a , and you win the prize: $iif($($+(%,prize.,$network,.,#),2),$ifmatch,nothing) | halt
}
}
A trigger flood control is needed in case people tamper with this script to flood out the client running the code. (can only be triggered every 3 seconds)