mIRC Home    About    Download    Register    News    Help

Print Thread
#255551 03/11/15 08:55 PM
Joined: Nov 2015
Posts: 7
Z
Zenoda Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
Z
Joined: Nov 2015
Posts: 7
Hi everybody,

Lately I´ve been making a simple bot for a streamer. Everything went according to plan but I have problems with a betting script.
I know that people here are only to help and not give answers, but any help would be appreciated. I´ve already done some work on the script but I can´t seem to get anything to work. Any help suggesting what is wrong and how I could fix it would be appreciated.

The things that the script would need to do:
-Let the user bet with their points, choose if the streamer wins or loses. If they lose, they lose their points. If they win, they get their points back in double.
-Let the moderators open, close and pick the outcome of the bet.

As I don't know how to paste the code here and I don't want to flood the message with text, I'll just post the link to a pastebin.

With kind regards,

Humble user of mIRC
Pastebin

Joined: Jul 2007
Posts: 6
K
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
K
Joined: Jul 2007
Posts: 6
You can click the # sign above the text box, and it'll input some code tags, you can enter your script in between them.

Joined: Nov 2015
Posts: 7
Z
Zenoda Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
Z
Joined: Nov 2015
Posts: 7
Quote:
You can click the # sign above the text box, and it'll input some code tags, you can enter your script in between them.


Thanks for that. Here´s the script for anybody willing to look.
Code:
alias -l addPoints {
  if ($1 !isnum) { echo 2 -st $1 is not a number. It needs to be a number. | halt }
  var %topic $+($chan,.,$nick)
  var %points $calc($readini(Points.ini,%topic,Points) + $1)
  writeini -n Points.ini %topic Points %points
  return %points
}

alias -l lookUpPoints {
  var %topic $+($chan,.,$nick)
  var %points $readini(Points.ini,%topic,Points)
  return %points
}
alias doaddpoints {
  if ($3 !isnum) { echo 2 -st $3 is not a number. It needs to be a number. | halt }
  var %topic $+($1,.,$2)
  var %points $calc($readini(Points.ini,%topic,Points) + $3)
  writeini -n Points.ini %topic Points %points
  echo -a Added points for %topic
}

alias dorempoints {
  var %topic $+($1,.,$2)
  remini -n Points.ini %topic Points
  echo -a Removed points for %topic
}

on *:text:!points:#:{
  if ((%floodpoints) || ($($+(%,floodpoints.,$nick),2))) { return }
  set -u10 %floodpoints. $+ $nick On
  msg # $nick has $readini(Points.ini,$+(#,.,$nick),Points) total points.
}

on $*:text:/!points (add|remove)/Si:#:{
  if ($nick isop #) {
    if ($0 < 3) { msg # Insufficient parameters: Use !points <add|remove> <user> [amount] | return }
    writeini -n Points.ini $+(#,.,$3) Points $calc($readini(Points.ini,$+(#,.,$3),Points) $iif($2 == add,+,-) $iif($4 isnum,$4,1))
    { msg $chan $3 now has $readini(Points.ini,$+(#,.,$3),Points) total points. }
    else { msg $chan This command is for moderators only. }
  }
  on !*:join:#:{
    $+(.timerpoints.,#,.,$nick) 0 900 add1.pts $+(#,.,$nick)
    add1.pts $+(#,.,$nick)
  }
  on !*:part:#:$+(.timerpoints.,#,.,$nick) off
  alias -l add1.pts {
    writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 10)
  }
  alias -l add.pts {
    writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 3)
  }
  on *:TEXT:*:*: {
    if (%messages. [ $+ [ $nick ] ] == 4) {
      set %messages. $+ $nick 0
      add.pts $+(#,.,$nick)
    }
    else { inc %messages. $+ $nick }
  }

  on $*:text:/!bet (win|lose)/Si:#:{
    if ($3 isnum) {
      var %i = 0
      var %ticket = $3
      var %betoutcome = $2
      var %topic = $+(#,.,$nick)
      var %user = $readini(Points.ini,%topic,Points)
      var %end = 1 * %ticket
      var %delete = %user - %end
      if (%delete > 0) {
        writeini -n Points.ini %topic Points %delete
        while (%i < %ticket) {
          write Bet.txt $nick $2
          %i = %i + 1
        }
        msg $chan $nick you have betted %betoutcome with %end points.
      }
      if (%delete < 0) {
        msg $chan Sorry $nick you don't have enough points to bet.
      }
    }
    if (%raffle == 0) {
      msg $chan Betting currently can't be done.
    }
  }

on *:text:!betstart:#:{
  if ($nick isop) {
  /set %bet 0
      if (%bet == 0) {
        msg $chan You can now start betting.
        write -c Bet.txt
        /set %bet 1
      }
    }
    else msg $chan This command is for moderators only.
    }

on *:text:!betstop:#:{
if ($nick isop) {
  if (%bet == 1) {
      msg $chan Betting has now stopped.
      /set %bet 0
      write -c Bet.txt
} 
  else msg $chan This command is for moderators only.
}   
  }  

on $*:text:/!betoutcome (win|lose):#:{
  if ($nick isop) {
  else msg $chan This command is for moderators only.
  }
  }

Joined: Nov 2015
Posts: 7
Z
Zenoda Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
Z
Joined: Nov 2015
Posts: 7
Hi again,

As I just finished the bet script I saw some flaws in it. The flaws are that somebody could in theory put multiple bets in either win or lose or both. Is there a way to stop this? I don't care if they can still bet multiple times, just as long as they only bet on one outcome.

Here is the code for anyone interested:
Code:
on *:text:!betstart:#: {
    if ($nick isop #) {
    if (%bet == 0) {
    msg $chan You can now start betting.
    set %bet 1
    }
    else { msg $chan This command is for moderators only. }
      }
    }

  on *:text:!betwin *:#: {
    if (%bet == 1) {
    if ($2 !isnum) { echo 2 -st $2 is not a number. It needs to be a number. | halt }
    var %topic $+($chan,.,$nick)
    var %pluspoints $calc($readini(BetWin.ini,%topic,Points) + $2)
    var %minuspoints $calc($readini(Points.ini,%topic,Points) - $2)
    var %points $readini(Points.ini,$+(#,.,$nick),Points)
    var %subtract $calc(%points - $2)
    if (%subtract < 0) {
      msg $chan You don't have enough points for that.
    }
    Else if (%subtract >= 0) { 
      writeini -n BetWin.ini %topic Points %pluspoints
      writeini -n Points.ini %topic Points %minuspoints
      msg $chan Your bet has been accepted as a win.
    }
    }
    }
            
    on *:text:!betlose *:#: {
    if (%bet == 1) {
    if ($2 !isnum) { echo 2 -st $2 is not a number. It needs to be a number. | halt }
    var %topic $+($chan,.,$nick)
    var %pluspoints $calc($readini(BetLose.ini,%topic,Points) + $2)
    var %minuspoints $calc($readini(Points.ini,%topic,Points) - $2)
    var %points $readini(Points.ini,$+(#,.,$nick),Points)
    var %subtract $calc(%points - $2)
    if (%subtract < 0) {
      msg $chan You don't have enough points for that.
    }
    Else if (%subtract >= 0) {
      writeini -n BetLose.ini %topic Points %pluspoints
      writeini -n Points.ini %topic Points %minuspoints
      msg $chan Your bet has been accepted as a lose.
    }
    }
    }  
      
    on *:text:!betclose:#: {
    if ($nick isop #) {
    if (%bet == 1) {
      msg $chan Betting has stopped.
      set %bet 2
    }
    else { msg $chan This command is for moderators only. }
      }
    }
    
    on *:text:!betoutcomewin:#: {
      if ($nick isop #) {
        if (%bet == 2) {
          var %topic $+($chan,.,$nick)
          var %points $readini(BetWin.ini,%topic,Points)
          var %result $calc(%points * 2)
          writeini -n Points.ini %topic Points $calc($readini(Points.ini,%topic,Points) + %result)
          set %bet 0
          write -c BetWin.ini
          write -c BetLose.ini
        }
      }
      Else { msg $chan You don't have permission for this. }
    }
   
    on *:text:!betoutcomelose:#: {
      if ($nick isop #) {
        if (%bet == 2) {
          var %topic $+($chan,.,$nick)
          var %points $readini(BetLose.ini,%topic,Points)
          var %result $calc(%points * 2) 
          writeini -n Points.ini %topic Points $calc($readini(Points.ini,%topic,Points) + %result)
          set %bet 0
          write -c BetWin.ini
          write -c BetLose.ini
        }
      }
      Else { msg $chan You don't have permission for this. }
    }


Greetz,

Average? user of mIRC

Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
You can also have a look and at this addon maybe is that you want: http://hawkee.com/snippet/16209/


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Nov 2015
Posts: 7
Z
Zenoda Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
Z
Joined: Nov 2015
Posts: 7
I have looked at that addon in the past, but the fact that there are symbols which are non existent on my pc is a big turn off. And with that addon people can only bet 25 points. While my script actually allows them to bet as much as they want.

Joined: Nov 2015
Posts: 7
Z
Zenoda Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
Z
Joined: Nov 2015
Posts: 7
I have completed the code, there still exists the "problem" of being able to put multiple points after the first bet. But I don't see this as a really big problem.

Here is the code for anyone looking:
Code:
  on *:text:!betwin *:#: {
    if (%bet == 1) {
    if ($2 !isnum) { echo 2 -st $2 is not a number. It needs to be a number. | halt }
    var %topic $+($chan,.,$nick)
    var %pluspoints $calc($readini(BetWin.ini,%topic,Points) + $2)
    var %minuspoints $calc($readini(Points.ini,%topic,Points) - $2)
    var %points $readini(Points.ini,$+(#,.,$nick),Points)
    var %subtract $calc(%points - $2)
    var %betlose $readini(BetLose.ini,$+(#,.,$nick),Points)
    if (%betlose > 0) {
      msg $chan You have already bet for lose.
    }
    Else if (%subtract < 0) {
      msg $chan You don't have enough points for that.
    }
    Else if (%subtract >= 0) {
      writeini -n BetWin.ini %topic Points %pluspoints
      writeini -n Points.ini %topic Points %minuspoints
      msg $chan Your bet has been accepted as a win.
    }
    }
    }
            
    on *:text:!betlose *:#: {
    if (%bet == 1) {
    if ($2 !isnum) { echo 2 -st $2 is not a number. It needs to be a number. | halt }
    var %topic $+($chan,.,$nick)
    var %pluspoints $calc($readini(BetLose.ini,%topic,Points) + $2)
    var %minuspoints $calc($readini(Points.ini,%topic,Points) - $2)
    var %points $readini(Points.ini,$+(#,.,$nick),Points)
    var %subtract $calc(%points - $2)
    var %betwin $readini(BetWin.ini,$+(#,.,$nick),Points)
    if (%betwin > 0) {
      msg $chan You have already bet for win.
    }
    Else if (%subtract < 0) {
      msg $chan You don't have enough points for that.
    }
    Else if (%subtract >= 0) {
      writeini -n BetLose.ini %topic Points %pluspoints
      writeini -n Points.ini %topic Points %minuspoints
      msg $chan Your bet has been accepted as a lose.
    }
    }
    }

The only thing that has been done is putting in a line which checks if there is already a value in the BetWin/BetLose file and if so, put out a message that they can't vote for the opposite side.


Link Copied to Clipboard