Mattbot3 Raffle Script

This script was used for the 2008 Neveron Holiday Raffle, but could be used for any raffle you desire (IRC ones anyway) with a few modifications.

Pre-requisites - Usage - Script

Pre-requisites:

mIRC

mattbuck's Other Aliases script

mattbuck's Maths functions aliases

A command chooser script (or replace "$comchoose" with "msg #neveron_holiday_raffle")

A prize list "rafdon.txt" in the main mIRC directory ($mircdir) formatted as follows (note that all fields must be one word only - it will replace underscores with spaces):

(Prize item) (Number in current lot) (Donator) (Clarifying message, use N/A for blank) (Cash value) (Empire)

eg:

STR-00 36 ShadowMasterCM N/A 180000000 Loserville_/_Hells_Dragoons_of_Sin
Strikers 12 Tobias_Moon STR-00_or_STR-01 48000000 -

A possible winner list "rafuser.txt" in the main mIRC directory ($mircdir), blank other than ENDAVWIN written on line 1.

 

 

Usage:

The script is designed to work in #neveron_holiday_raffle, but you can just go through and replace that with whatever channel you want.

To use the script, make sure you have all prerequisites, then copy the script below into a new section of the remotes tab of mIRC script editor.

 

As people join the channel they are automatically added to the possible winners list. They can also be manually added using ~adduser NICK. The bot takes addresses so cannot be fooled by people using two different nicks. You can also add all users in #neveron_holiday_raffle to the prize list using ~addchannel. Note that it will not add either X3 or itself to the list of users.

Before starting the raffle, type ~rafflereset

To draw a prize, type ~raffle.

The raffle is done in rounds - once people have won once they are no longer eligible to win until everyone else in the user pool has won. After this the user pool is repopulated and the next round begins. New people joining are not eligible for prizes in the current round, but are added to the user pool when the next round begins.

 

 

Script:

;raffle
;help

on *:JOIN:#Neveron_Holiday_Raffle:{
  if ($nick == X3 || $nick == $me) { halt }
  if ($address($nick,4) == *!*@*.users.afternet.org) { var %address = $address($nick,2) }
  else { var %address = $address($nick,3) }
  var %temp = $read(rafuser.txt,s,ENDAVWIN), %lstart = $in($readn,1), %temp2 = $read(rafuser.txt,w,* $+ %address $+ *,%lstart)
  if (%temp2 == $null) {
    write -il $+ %lstart rafuser.txt $nick %address
    notice @#Neveron_Holiday_Raffle $nick added to nick pool
  }
  elseif ($wret(%temp2,1) != $nick) {
    msg #Neveron_Holiday_Raffle $+ $nick $+ : You have been identified as $wret(%temp2,1) $+ . Please change your nick to that name in order to facilitate prize giving.
  }
  else { msg #Neveron_Holiday_Raffle $+ $nick $+ : You have been identified as $wret(%temp2,1) $+ . }
}

on *:TEXT:~addchannel:#Neveron_Holiday_Raffle:{
  if ($nick isop #Neveron_Holiday_Raffle) {
    $comchoose Checking raffle entry status of all users on $chan $+ .
    addrafchan $chan
  }
}

on *:TEXT:~adduser *:*:{
  if ($nick isop #Neveron_Holiday_Raffle) {
    $comchoose Checking raffle entry status of $2 $+ .
    addrafuser $2
  }
}

alias addrafuser {
  if ($address($1,1) == $null && !$2) { whois $1 | echo No address found for $1 - whoising | timer 1 3 addrafuser $1 end }
  elseif ($address($1,1) == $null && $2) { msg #Neveron_Holiday_Raffle Unable to add $1 $+ . | halt }
  else {
    echo Address found for $1
    if ($address($1,4) == *!*@*.users.afternet.org) { var %address = $address($1,2) }
    else { var %address = $address($1,3) }
    var %temp = $read(rafuser.txt,s,ENDAVWIN), %lstart = $in($readn,1), %temp2 = $read(rafuser.txt,w,* $+ %address $+ *,%lstart)
    if (%temp2 == $null) {
      write -il $+ %lstart rafuser.txt $1 %address
      write -il1 rafuser.txt $1
      notice @#Neveron_Holiday_Raffle $1 added to nick pool
      notice $1 You have been added to the nick pool. You will not be eligible for a prize this round (when # of possible winners reaches 1), but you will be eligible for prizes thereafter.
    }
  }
}

alias addrafchan {
  var %user = 1, %rneeded = $false
  :crep
  var %nick = $nick($1,%user)
  echo checking $nick($1,%user)
  if (%nick == X3 || %nick == $me) { inc %user 1 }
  elseif ($address(%nick,1) == $null) { whois %nick | var %rneeded = $true | inc %user 1 | echo No address found for $nick($1,%user) - whoising }
  else {
    echo Address found for $nick($1,%user)
    if ($address(%nick,4) == *!*@*.users.afternet.org) { var %address = $address(%nick,2) }
    else { var %address = $address(%nick,3) }
    var %temp = $read(rafuser.txt,s,ENDAVWIN), %lstart = $in($readn,1), %temp2 = $read(rafuser.txt,w,* $+ %address $+ *,%lstart)
    if (%temp2 == $null) {
      write -il $+ %lstart rafuser.txt %nick %address
      write -il1 rafuser.txt %nick
      notice @#Neveron_Holiday_Raffle %nick added to nick pool
    }
  inc %user 1
  }
  if (%user > $nick($1,0) || %user > 100) {
    msg $1 Check complete.
    if (%rneeded == $true) { timer 1 10 addrafchan $1 }
  }
  else { goto crep }
}

on *:TEXT:~rafflereset:#Neveron_Holiday_Raffle:{
  if ($nick isop $chan) {
    unset %rafnum
    set %rafround 1
    $comchoose Raffle reset.
  }
}

on *:TEXT:~rafflestatus:#Neveron_Holiday_Raffle:{




}

on *:TEXT:~raffle:#Neveron_Holiday_Raffle:{
  if ($nick isop $chan) {
    if (!%rafnum) { set %rafnum 1 }
    :raftest
    var %temp = $read(rafdon.txt,%rafnum), %rafmax = $lines(rafdon.txt)
    if ($wret(%temp,0) = 7) { inc %rafnum 1 | goto raftest }
    var %temp = $read(rafuser.txt,s,ENDAVWIN), %cmax = $de($readn,1), %pline = $read(rafdon.txt,%rafnum), %winner, %roll, $&
    %item = $replace($wret(%pline,1),_,$chr(32)), %num = $wret(%pline,2), %don = $wret(%pline,3), %notes = $replace($wret(%pline,4),_,$chr(32)), $&
      %cashval = $comma($wret(%pline,5),3)

    if (%notes == N/A) { %notes = $null }
    else { %notes = Notes: %notes $+ . }
    if ($wret(%pline,0) = 6) { %don = %don of the empire $replace($wret(%pline,6),_,$chr(32)) }
    msg #Neveron_Holiday_Raffle Item %rafnum of %rafmax $+ : %num %item donated by %don $+ . %notes $&
    Estimated cash value for this prize is $chr(36) %cashval $+ .

;If only one available winner:

    if (%cmax = 1) {
      %winner = $wret($read(rafuser.txt,1),1) | %roll = 1
      write -dl1 rafuser.txt
      var %line = 2

;Repopulate winner list

      :repeat
      write -il1 rafuser.txt $wret($read(rafuser.txt,%line),1)
      if ($in(%line,1) < $lines(rafuser.txt)) { inc %line 2 | goto repeat }

;Check donator != winner, start next round

      if (%don != %winner) {
        msg #Neveron_Holiday_Raffle Only one person able to win. Congratulations to %winner $+ ! Starting a new round.
        write -l $+ %rafnum rafdon.txt %pline %winner
        inc %rafnum 1
        inc %rafround 1
      }
      elseif (%rafnum < %rafmax) {
        msg #Neveron_Holiday_Raffle Only winner is the prize's donator, we'll come back to this one...
        var %rafnum2 = $in(%rafnum,1)
        :efix
        if ($wret($read(rafdon.txt,%rafnum2),3) == %winner && %rafnum2 < %rafmax) { inc %rafnum2 1 | goto efix }
        elseif (%rafnum2 = %rafman) { All remaining prizes were donated by the one available winner, %winner $+ . Someone find %winner a new $&
          prize please. Starting new round. }
        else {
          var %pline2 = $read(rafdon.txt,%rafnum2), %item2 = $replace($wret(%pline2,1),_,$chr(32)), %num2 = $wret(%pline2,2), %don2 = $wret(%pline2,3), $&
            %notes2 = $replace($wret(%pline2,4),_,$chr(32))
          if (%notes2 == N/A) { %notes2 = $null }
          else { %notes2 = Notes: %notes2 }
          msg #Neveron_Holiday_Raffle Item %rafnum2 of %rafmax $+ : %num2 %item2 donated by %don2 $+ . %notes2
          msg #Neveron_Holiday_Raffle Only one person able to win. Congratulations to %winner $+ ! Starting a new round.
          inc %rafround 1
          write -l $+ %rafnum2 rafdon.txt %pline2 %winner
        }
      }
    else { msg #Neveron_Holiday_Raffle Only winner is the prize's donator, and this is the last prize. I'm afraid you'll have to sort this one out yourselves... }
    }

    else {
      :repwin
      %roll = $rand(1,%cmax) | %winner = $wret($read(rafuser.txt,%roll),1)
      if (%winner == $wret(%pline,3)) { goto repwin }
      msg #Neveron_Holiday_Raffle %cmax available winners, rolling dice... roll is a %roll $+ . Congratulations to %winner $+ !
      write -dl $+ %roll rafuser.txt
      if ($wret(%pline,0) < 6) { %pline = %pline - }
      write -l $+ %rafnum rafdon.txt %pline %winner
      inc %rafnum 1
    }
    if (%rafnum >= %rafmax) { msg #Neveron_Holiday_Raffle That's the last prize. A list of winners will be posted shortly on the forums and mattbuck's website. Merry Christmas! }
  }
}

/raffix {
  var %line = 1
  :rafrep
  var %read = $read(rafdon.txt,%line)
  write raf1.txt $wret(%read,1)
  write raf2.txt $wret(%read,2)
  write raf3.txt $wret(%read,3)
  write raf4.txt $wret(%read,4)
  write raf5.txt $wret(%read,5)
  if (%line < $lines(rafdon.txt)) { inc %line 1 | goto rafrep }
  echo Finished
}


Click to return to the mattbot index.