I need assistance with this raffle code

By HeyThatsMatthew- on Nov 21, 2014

Hey guys i was wondering if someone can lend me their knowledge. I have here a raffle code but it needs some tinkering. I need the Max amount of tickets purchased to be 3 even if the command is entered again. So if I bought 3 the first time and i tried to buy 2 the next it wont allow me to. The last time i used this everyone could buy as many tickets as they wanted, all they had to do was repeat the command, i want to prevent that from happening. Any help is appreciated. Thank you in advance.

on *:TEXT:!buyticket &:#:{
  if (%open == 1) {
    if ($2 > 3) {
      msg $chan Sorry $nick but you can only buy a maximum of 3 tickets!
    }
    if ($2 < 4) {
      var %i = 0
      var %count = $2
      var %topic = $+(#,.,$nick)
      var %user = $readini(Points.ini,%topic,Points)
      var %final = 10 * %count
      var %remove = %user - %final
      if (%remove > 0) {
        writeini -n Points.ini %topic Points %remove
        while (%i < %count) {
          write Raffle.ini $nick
          %i = %i + 1
        }
        msg $chan $nick you have bought %count tickets spending %final of your points leaving you with %remove left!
      }

      if (%remove < 0) {
        msg $chan Sorry $nick but you dont have enough points to buy %count tickets!
      }
    }
  }
}

on *:TEXT:*:#:{
  if ($nick isop #) {
    if ($1 == !raffle) {
      if ($2 == open) {
        msg $chan /me [**RAFFLE STARTED**]-----[**RAFFLE STARTED**]
        set %open 1
        write -c Raffle.ini
        echo -a Raffle Started
      }
      if ($2 == close) {
        msg $chan /me [**RAFFLE CLOSED**]-----[**RAFFLE CLOSED**]
        set %open 0
        write -c Raffle.ini
        echo -a Raffle Closed
      }
    }
    if ($1 == !winner) {
      if (%open == 1) {
        var %user = $read(Raffle.ini,n)
        write -c Raffle.ini
        set %open 0
        msg $chan /me [**CONGRATS**] The winner of the Raffle is %user [**CONGRATS**]
        set %open 0
        write -c Raffle.ini
        echo -a Raffle Closed
      }
    }
  }
  if ($1 == !tickets) {
    if (%open == 1) {
      msg $chan There are currentley $lines(Raffle.txt) tickets entered into the raffle! 
    }
  }
}

Comments

Sign in to comment.
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.