Advertisement
Iire

LewisNewson's Raffle System (edit)

Nov 6th, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. on *:TEXT:!buyticket &:#:{
  2.   if (%open == 1) {
  3.     if ($isfile(Raffle.txt)) {
  4.       filter -ff Raffle.txt NUL $nick
  5.     }
  6.     if ($filtered == 10) {
  7.       msg # Sorry, $nick $+ , but you cannot buy any more tickets.
  8.     }
  9.     elseif ($calc($v1 + $2) > 10) {
  10.       msg # $nick $+ , you cannot buy that many tickets!
  11.     }
  12.     else {
  13.       var %i = 0
  14.       var %count = $2
  15.       var %topic = $+(#,.,$nick)
  16.       var %user = $readini(Points.ini,%topic,Points)
  17.       var %final = 10 * %count
  18.       var %remove = %user - %final
  19.       if (%remove >= 0) {
  20.         writeini -n Points.ini %topic Points %remove
  21.         while (%i < %count) {
  22.           write Raffle.txt $nick
  23.           %i = %i + 1
  24.         }
  25.         msg $chan $nick $+ , has bought %count tickets spending %final points!
  26.       }
  27.       else {
  28.         msg $chan Sorry $nick but you don't have enough points to buy %count tickets!
  29.       }
  30.     }
  31.   }
  32. }
  33.  
  34. on *:TEXT:!chances:#:{
  35.   if (%open == 1) && ($isfile(Raffle.txt)) {
  36.     filter -ff Raffle.txt NUL $nick
  37.     var %chance = $calc($filtered / $lines(Raffle.txt)) * 100
  38.     msg # $nick $+ , You have a %chance $+ % chance of winning the raffle!
  39.     if (%chance == 0) msg # Why don't you buy some tickets? !buyticket NUMBER_OF_TICKETS
  40.   }
  41. }
  42.  
  43. on *:TEXT:*:#:{
  44.   if ($nick isop #) {
  45.     if ($1 == !raffle) {
  46.       if ($2 == open) {
  47.         msg $chan /me [RAFFLE STARTED]
  48.         set %open 1
  49.         write -c Raffle.txt
  50.         echo -a Raffle Started
  51.       }
  52.       elseif ($2 == close) {
  53.         msg $chan /me [RAFFLE CLOSED]
  54.         set %open 0
  55.         write -c Raffle.txt
  56.         echo -a Raffle Closed
  57.       }
  58.       elseif ($2 == cancel) && ($isfile(Raffle.txt)) {
  59.         set %open 0
  60.         window -hls @raffle
  61.         var %matches, %topic
  62.         loadbuf @raffle Raffle.txt
  63.         while ($line(@raffle, 1) != $null) {
  64.           %matches = $fline(@raffle, $v1, 0)
  65.           %topic = $+(#,.,$v1)
  66.           writeini -n points.ini %topic points $calc(%matches * 10 + $readini(points.ini, n, %topic, points))
  67.           dline @raffle 1- $+ %matches
  68.         }
  69.         describe # The raffle has been cancelled by $nick $+ ; all points have been refunded.
  70.         write -c Raffle.txt
  71.         close -@ @raffle
  72.       }
  73.     }
  74.     elseif ($1 == !draw) {
  75.       if (%open == 1) {
  76.         var %user = $read(Raffle.txt,n)
  77.         write -c Raffle.txt
  78.         set %open 0
  79.         msg $chan /me And the winner is... %user $+ !!! Well Done!
  80.         echo -a Raffle Closed
  81.       }
  82.     }
  83.   }
  84.   if ($1 == !tickets) {
  85.     if (%open == 1) {
  86.       msg $chan There are currently $lines(Raffle.txt) tickets entered into the raffle!
  87.     }
  88.   }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement