Raffle-Holding Bot Snippet

By Kerli on Apr 07, 2010

This is a simple bot raffle code snippet, and my first code snippet posted on Hawkee. All channel members may start a raffle, and only they and the bot's master can end it. Many features to keep this script very user-friendly. Thanks to |Anthony| on Chat-Addict for a lot of help on this script, especially the method of policing those who join raffles multiple times. **Note that your bot should have a 'txt' folder, otherwise you should modify this script before use.

;lottery scripting
on 1000:text:*lottery*:#:{
  if ($1 == %c $+ lottery) {
    if ($2 == on) { .enable #lottochan | set %raffle 0 | .msg $chan $chan $+ : Lottery Mode has been enabled. Type %c $+ lottery off to disable this mode. Type %c $+ lottoinfo for a list of commands. }
    if ($2 == off) { .disable #lottochan | .msg $chan $chan $+ : Lottery Mode has been disabled. }
    else { .notice $nick 10Incorrect: Use %c $+ lottery <on/off> | halt }
  }
  else { halt }
}

#lottochan on
on *:text:*raffle*:#: {
  if ($1 == %c $+ raffle) {
    if (%raffle == 0) {
      set %raffle 1
      set %raffler $nick
      set %prize $2-
      .msg $chan $nick has called for a raffle. The prize being raffled is %prize $+ . To enter, type %c $+ join.
    }
    else { .notice $nick 10A raffle is already opened. Wait until it ends to open another raffle. | halt }
  }
}
on *:text:*join*:#: {
  if ($1 == %c $+ join) {
    if (%raffle.join. [ $+ [ $nick ] ] == 1) {
    .notice $nick 10You've already entered this raffle. Wait until another raffle is opened before trying again. | halt }
    if (%raffle == 0) {
    .notice $nick 10There is no raffle opened at this time. Try again once someone opens a raffle. | halt }
    else {
      if ($nick == %raffler) {
      .notice $nick 10You can't enter your own raffle. | halt }
      if (%raffle == 1) {
        set %raffle.join. [ $+ [ $nick ] ] 1
      .notice $nick 10You have successfully entered in the current raffle. Wait until the %raffler ends the entry session to find out if you are receiving a prize. | .write txt\raffle.txt $nick $+ ! | halt }
    }
  }
}

on *:text:*end*:#: {
  if ($1 == %c $+ end) {
    if (%raffle == 1) {
      if (%raffler == $nick) {
        .msg $chan $chan $+ : The winner of %raffler $+ 's raffle of %prize is...
        .msg $chan $read txt\raffle.txt To claim your prize, make sure you speak to %raffler $+ .
        /write -c txt\raffle.txt
        set %raffle 0
        unset %raffler
        unset %raffle.join.*
      }
      elseif ($nick != %raffler) {
      .notice $nick 10You did not open the current raffle. Therefore, you cannot end it. | halt }
    }
    else {
    .notice $nick 10There is no raffle going on right now, $nick $+ . | halt }
  }
}

on *:text:*lottoinfo*:#: {
  if ($1 == %c $+ lottoinfo) {
    .notice $nick 6*Master* Commands:
    .notice $nick 10Type %c $+ end to end a raffle.
    .notice $nick 10Type %c $+ lottery <on/off> to enable or disable Lottery Mode.
    .notice $nick 6-------------------------
    .notice $nick 6*User* Commands:
    .notice $nick 10Type %c $+ raffle <prize> to open a raffle. Make sure the prize is a phrase without punctuation at the end, and it does not start with a capital letter for best visual results (ie: oatmeal raisin cookies).
    .notice $nick 10Type %c $+ join to join an opened raffle.
    .notice $nick 10Type %c $+ end to end your own raffle.
    .notice $nick 10Type %c $+ lottoinfo to show this command list again.
  }
}

#lottochan end

Comments

Sign in to comment.
MashhitDK   -  May 23, 2010

Thanks...

Am gonna use this I think...

 Respond  
Kerli   -  Apr 08, 2010

Um...

Hm. It works fine when I test it. Try ending a raffle. Otherwise, I don't know. .-.

EDIT:

Open the variables tab in the mIRC scripts editor and check to see if %raffle is set to 1.

 Respond  
Jenny   -  Apr 08, 2010

When I try to start a raffle I get a error command that theres already a raffle although theres nothing

 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.