blackvenomm666 commented on a Page, Lottery Script  -  Jun 19, 2011
alias start {
  set %chan $$?="What channel will the lottery game be played in?"
  set %master $$?="Who will run the lottery game? (The user, not the bot. This user will be the only one who can add powerusers.)
}
on *:text:*:%chan: {
  tokenize 32 $strip($1-)
  if ($1 == !lottoregister) {
    if (!%points [ $+ [ $nick ] ]) {
      set %points [ $+ [ $nick ] ] 5
      notice $nick You have registered successfully! You will start with 5 points. Type 4!lottostart to start a lottery drawing!
    }
    elseif (%points [ $+ [ $nick ] ]) {
      notice $nick You are already registered in the lottery.
    }
  }
  if ($1 == !lottostart) {
    if (%points [ $+ [ $nick ] ] && %lottery != on) {
      msg # A lottery drawing has started! A ticket costs 1 point! To buy a ticket, 4!lottobuy.
      set %lottery on
      set %amount 5
    }
  }
  if ($1 == !lottobuy) { 
    if (%amount > 0 && %points [ $+ [ $nick ] ] > 0 && %lottery == on && $nick !isin %people) {
      dec %points $+ $nick
      notice $nick You have successfully bought a ticket! You have %points [ $+ [ $nick ] ] points left!
      set %people %people $nick
      dec %amount
      msg # $nick has joined the lottery! There are %amount spot(s) open!
    }
    elseif ($nick isin %people) {
      notice $nick You are already in the lottery
    }
    elseif (%points [ $+ [ $nick ] ] == 0) {
      msg # $nick is bankrupt! Contact a poweruser if you are bankrupt.
    }
    if (%amount == 0) {
      draw
    }
    elseif (%points [ $+ [ $nick ] ] < 1) {
      notice $nick You don't have enough points to join the lottery. You might be bankrupt, or you have haven't registered. To register, type 4!lottoregister. If you are bankrupt, contact a poweruser.
    }
  }

  if ($1 == !lottoscore) {
    notice $nick You have %points [ $+ [ $nick ] ] points!
  }
  if ($1 == !lottomemb) {
    if (%people) {
      msg # Users in the current lottery: %people $+ .
    }
    elseif (!%people) {
      msg # Users in the current lottery: None.
    }
  }
  if ($1 == !lottoend) {
    if ($nick isin %poweruser && %lottery == on) {
      tokenize 32 %people
      if ($1 != $null) {
        inc %points [ $+ [ $1 ] ]
      }
      if ($2 != $null) {
        inc %points [ $+ [ $2 ] ]
      }
      if ($3 != $null) {
        inc %points [ $+ [ $3 ] ]
      }
      if ($4 != $null) {
        inc %points [ $+ [ $4 ] ]
      }
      if ($5 != $null) {
        inc %points [ $+ [ $5 ] ]
      }
      unset %amount
      unset %people
      unset %lottery
      msg # the lottery was ended by $nick $+ !
    }
  }
  if ($1 == !poweruser) {
    if ($nick == %master && $2 !isin %poweruser) {
      set %poweruser %poweruser $2
      msg # $2 was added as a poweruser!
    }
  }
  if ($1 == !points) {
    if ($nick isin %poweruser) {
      msg # $$3 $+ reased $$2 $+ 's points by $$4 $+ !
      $$3 %points [ $+ [ $$2 ] ] $$4
    }
    elseif ($nick !isin %poweruser) {
      msg # You can't use that command
    }
  }
}
alias draw {
  unset %lottery
  set %winner $gettok(%people,$r(1,5),32)
  msg # Drumroll please...
  timer 1 5 msg # %winner has won the lottery! They will get 5 points.
  inc %points [ $+ [ %winner ] ] 5
  unset %amount
  unset %people
  unset %lottery
  unset %winner
}

^^^^this version will strip colors so people dont have to turn them off. And also groups your on text events

 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.