mIRC Home    About    Download    Register    News    Help

Print Thread
#247720 23/08/14 06:31 PM
Joined: Aug 2014
Posts: 3
S
Setebos Offline OP
Self-satisified door
OP Offline
Self-satisified door
S
Joined: Aug 2014
Posts: 3
Hey guys, I'm pretty new to mIRC scripting, but I'm trying to make a challenge type system for my Twitch chat bot. I want to be able to type !challenge <user> and then when that person types !accept it will randomly pick either rock, paper or scissors for each person and type the results into the chat.

I have tested it quite a few times, and I can get it to work usually the first time, but then it stops working, so I have no idea what is wrong with it.

Here is what I have so far, obviously this is not complete as there are only two outcomes, but it is enough for my testing purposes. If someone could figure out what's wrong or show me how to make this work it'd be very much appreciated.

Edit: I should mention that it isn't the entire script that doesn't work. I can get the challenge part to work, and then the other person accepts and it says they accepted but it doesn't execute the rpschallenge alias every time.

Code:
alias challengestop { 
  unset %player1 %player2 %challenge %player1choice %player2choice
}
alias rpschallenge {
  if (%challenge == on) {   
    if (%player1choice == 1) && (%player2choice == 1) {
      .timermsg 1 2 msg #setebos %player1 and %player2 both chose rock! It's a draw.
      .timer2 1 3 challengestop
    }
    elseif (%player1choice == 1) && (%player2choice == 2) { 
      .timermsg 1 2 msg #setebos %player1 chose rock and %player2 chose paper! %player2 wins!
      .timer2 1 3 challengestop
    }
  }
}
on *:TEXT:!challenge*:#tirean: {
  if (%challenge == on) { 
    .timermsg 1 1 msg $chan Rock-Paper-Scissors challenge mode is already in use.
  }
  else {
    var -g %player1 = $nick, %player2 = $2, %challenge = on
    .timermsg 1 1 msg $chan $2 - $nick has challenged you to a game of Rock-Paper-Scissors, type either !accept or !decline.
  }
}
on *:TEXT:*:#setebos: {
  if (%challenge == on) {
    if ($1 == !accept) {
      if ($nick == %player2) {
        var -g %player1choice = $rand(1,3), %player2choice = $rand(1,3)
        .timermsg 1 1 msg $chan $nick has accepted the challenge! Rock.. Paper.. Scissors.. Shoot!
        .timer1 1 2 rpschallenge
      }
    }
    if ($1 == !decline) {
      if ($nick == %player2) {
        .timermsg 1 1 msg $chan The challenge request has been declined.
        challengestop
      }
    }
  }
}

Last edited by Setebos; 23/08/14 10:13 PM.
Joined: Aug 2014
Posts: 3
S
Setebos Offline OP
Self-satisified door
OP Offline
Self-satisified door
S
Joined: Aug 2014
Posts: 3
Also I realize I have a different channel name in the challenge command, that was an accident before I copied the code. :P


Link Copied to Clipboard