Jethro commented on a Page, Random winner selector  -  Mar 29, 2010

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)

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.