mIRC Home    About    Download    Register    News    Help

Print Thread
#247029 19/07/14 11:16 AM
Joined: Aug 2013
Posts: 22
A
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Aug 2013
Posts: 22
HI I need help to find a way to Deduct 20 or even 50 points her ticket instead of just 1 point

Code:
on *:text:!ticket *:#:{
  var %owner firestonetv
  var %hash $+(ticket.,#)
  if !$istok(%owner,$nick,32) && $istok(open close roll end,$2,32) { msg # You cant use this command. | return }
  if !$hget(%hash) && ($istok(close roll end,$2,32) || $2 isnum) {  msg # There is no open ticket. | return }
  if !$hget(%hash,close) && $istok(roll end,$2,32) { msg # !ticket is not closed yet. | return }
  if $hget(%hash,close) && ($2 == close || $2 isnum) { msg # !ticket is already closed by $hget(%hash,close) $+ . | return }  
  if $2 == open {
    if $hget(%hash) { msg # !ticket is still active | return }
    hmake %hash 
    msg # Ticket now is open. Use !ticket <point> to join.
  }
  if $2 isnum && $2 > 0 {
    var %topic $+(#,.,$nick), %point $readini(points.ini,%topic,points)
    if %point < $2 { msg # $nick Sorry, you only have %point points | return }
    var %p $calc(%point - $2)
    writeini points.ini %topic points %p 
    var %i $hget(%hash,0).item, %t $calc(%i + $2) 
    msg # $nick $+ , You bought $2 ticket ( no. $calc(%i + 1) - %t ), you now have %p points
    while %i < %t { inc %i | hadd %hash %i $nick }
  }
  if $2 == close {
    var %i 1 | while $hget(%hash,%i).data { var %d $addtok(%d,$v1,32) | inc %i }  
    msg # !ticket now is closed. ( total entries : $calc(%i - 1) tickets - $numtok(%d,32) users )
    hadd %hash close $nick
  }
  if $2 == roll {
    var %c $hget(%hash,close)
    hdel %hash close
    var %d $hget(%hash,0).item
    if !%d { msg # There is no ticket to draw. }
    else {
      var %i $rand(1,%d), %w $hget(%hash,%i).item
      msg # The winner is ticket no. %w ( $hget(%hash,%w) ) $+ .
      hdel %hash %w 
    }
    hadd %hash close %c
  }
  if $2 == end {
    hfree %hash
    msg # All tickets data now is cleared.
  }
}

Joined: Jul 2014
Posts: 48
A
Ameglian cow
Offline
Ameglian cow
A
Joined: Jul 2014
Posts: 48
It's most likely going to be with this part of your code:
Code:
var %p $calc(%point - $2)
    writeini points.ini %topic points %p 

I'm assuming your syntax for getting a ticket is "!ticket #oftickets"?

if so, your %p variable needs to calculate if they have $point - ($2 x 20). Or whatever number is cost of 1 ticket. I'm not sure if that is correct syntax for multiplication, so I would look it up and verify.

This way, you are checking if they have #oftickets multiplied by the cost of those tickets in their remaining points.

now you want to also writeini points of $2 x #costofeachticket (20 or 50 or etc.) but if adding, add it as a NEGATIVE number. Otherwise, use the remove points reference.


Hopefully this can help you figure it out.
-Aeon





edit: I just looked up the syntax for multiplication. It is the "*" character. So related more specifically to your code example I would do something like: %totalprice = $2 * 20 for a 20$ ticket.
Then check %point < %totalprice.
Then %p $calc(%point - %totalprice)
then writeini %p.

Last edited by AeonPsych; 22/07/14 06:22 AM.
Joined: Jul 2014
Posts: 3
C
Self-satisified door
Offline
Self-satisified door
C
Joined: Jul 2014
Posts: 3
Hey thank your for your reply i tried to have a go and figure it out but i cant seem to get it right i think i got it totally wrong as i said i am very inexperience can u make a code for it and show me so i can disect it and learn from it THANKS!


Link Copied to Clipboard