I wrote this code some time ago. someone asked me to help him/her to turn this raffle into giveaway where users can buy tickets using points they have and also the user can buy more than one time.

Here is the code.
Code:
on *:text:!ticket *:#:{
  var %owner NICK1 NICK2 NICK3
  var %hash $+(ticket.,#) 
  if $istok(%owner,$nick,32) && $2 == on && !$hget(%hash) { 
    hmake %hash 
    msg # Ticket now is open. Use !ticket <point> to join.
  }
  elseif $2 isnum && $2 > 0 && $hget(%hash) {
    var %topic $+(#,.,$nick), %point $readini(points.ini,%topic,points)
    if %point >= $2 {
      var %p $calc(%point - $2)
      writeini points.ini %topic points %p 
      var %i $hget(%hash,0).item, %t $calc(%i + $2) 
      while %i < %t { inc %i | hadd %hash %i $nick }
      msg # $nick $+ , You bought $2 ticket, you now have %p points
    }
    else { msg # $nick Sorry, you only have %point points }
  }
  elseif $istok(%owner,$nick,32) && $2 == roll && $hget(%hash) {
    var %i $rand(1,$hget(%hash,0).data)
    msg # The winner is $hget(%hash,%i).data $+ . 
    hfree %hash
  }
}

change NICK1 NICK2 NICK3 with yournick, yourfriendnick, othernickyoutrust to do !ticket on and !ticket roll

here is how the script works.
user1 buy 20 ticket
bot will give him ticket no 1-20 (20 tickets)
user2 buy 70 ticket
bot will give him ticket no 21-90 (70 tickets)
user1 buy again 10 ticket
bot will give him ticket no 91-100 (10 tickets)
.. so on..

when you close it.
user1 has 30/100 = 30% chance to win
user2 has 70/100 = 70% chance to win

The code was tested by him/her and he/she said it works fine.