Multiplayer Cricket

By newklear on Apr 16, 2018

Saw This script http://hawkee.com/snippet/17907/ by manish17, made it work with a few extra's.

Just like a game of Cricket.

Possible batting options are Defense , Push and Loft .
Possible bowling options are Bouncer, FullToss and Yorker.

The percentage of getting a wicket differs according to the Batting + Bowling Combo.

Commands : -
!cricket : Starts a cricket game with specified wickets , max 10 . If nothing is mentioned , it is considered 5.
!swap : In an ongoing game , it replaces Player1 by Player2, Only an Op can use !swap .
!stopcricket : Stops the game
!high: Displays the highest score
!pb: Displays your personal best or someone elses, Syntax: !pb or !pb nickname
!help : Lists all important commands.
!combo : Displays the chances of getting out on each combo.
Quick Command Reference, notice the bot, Syntax: /notice botname !help
.
Note : - A bowler must bowl first by noticing the bot . Then only the batsman can bat by , again , noticing the bot.

################################################
##          Two Player Cricket Game           ##
##           Revised Version: 1.0             ##
##            By:  newklear                   ##
################################################

on *:LOAD: { 
  set %chan $input(Enter name of the channel including the #:,e,) 
  echo -a Two Player Cricket Game Loaded, see !help for commands
}

alias -l gamehalt {
  mode %chan -m
  mode %chan -v %player1
  mode %chan -v %player2
  .timeru1 1 5 unset %p1
  .timeru2 1 5 unset %p2
  .timeru3 1 5 unset %toss
  .timeru4 1 5 unset %tosscall
  .timeru5 1 5 unset %tosswinner
  .timeru6 1 5 unset %tossloser
  .timeru7 1 5 unset %bat
  .timeru8 1 5 unset %ball
  .timeru9 1 5 unset %innings
  .timeru10 1 5 unset %counter
  .timeru11 1 5 unset %currentbat
  .timeru12 1 5 unset %currentball
  .timeru13 1 5 unset %score1
  .timeru14 1 5 unset %score2
  .timeru15 1 5 unset %wicket
  .timeru16 1 5 unset %tw
  .timeru17 1 5 unset %youandme
  .timeru18 1 5 unset %luck
  .timeru19 1 5 unset %run
  .timeru20 1 5 unset %pqrs
  .timeru21 1 5 unset %temporary 
  .timeru22 1 5 unset %ru
}

alias -l check_personal_high_one {
  if ($read(pb.txt,s,%bat)) { 
    var %score $gettok($read(pb.txt,s,%bat),2,32)
    if (%score == %score1) { msg %chan 10Well done %bat You have 4equalled 10your previous record! | write pb.txt %bat $ctime %score1 $date }
    if (%score > %score1) { msg %chan 10Well done %bat You have 4broken your 10previous record! | write pb.txt %bat $ctime %score1 $date }
  }
  msg %chan 10Well done %bat $+ , You have set a 4new 10personal record!
  write pb.txt %bat $ctime %score1 $date 
}

alias -l check_personal_high_two {
  if ($read(pb.txt,s,%bat)) { 
    var %score $gettok($read(pb.txt,s,%bat),2,32)
    if (%score == %score2) { msg %chan 10Well done %bat You have 4equalled 10your previous record! | write pb.txt %bat $ctime %score2 $date }
    if (%score > %score2) { msg %chan 10Well done %bat You have 4broken 10your previous record! | write pb.txt %bat $ctime %score2 $date }
  }
  msg %chan 10Well done %bat $+ , You have set a 4new 10personal record!
  write pb.txt %bat $ctime %score2 $date
}

alias -l high_score_one {
  write -c highscore.txt %bat $ctime %score1 $date 
}

alias -l high_score_two {
  write -c highscore.txt %bat $ctime %score2 $date  
}

on *:text:!pb*:%chan: {
  if (!$2) {
    if (!$read(pb.txt,s,$nick)) { msg $chan $nick you do not have a Personal Best set yet! | halt }
    var %time $gettok($read(pb.txt,s,$nick),1,32)
    var %score $gettok($read(pb.txt,s,$nick),2,32)
    var %date $gettok($read(pb.txt,s,$nick),3,32)
    msg $chan High score of: %score set by4 $nick on %date which was $duration($calc($ctime - %time)) ago.
  }
  if ($2) {
    if (!$read(pb.txt,s,$2)) { msg $chan The are no Personal Best scores recorded for $2 yet! | halt }
    var %time $gettok($read(pb.txt,s,$2),1,32)
    var %score $gettok($read(pb.txt,s,$2),2,32)
    var %date $gettok($read(pb.txt,s,$2),3,32)
    msg $chan 14 $+ High score of: %score set by4 $2 on %date which was $duration($calc($ctime - %time)) ago.
  }
}

on *:text:!high*:%chan: {
  if (!$2) { msg $chan Syntax: !high score | halt }
  if ($2 == score ) {
    var %name $gettok($read(highscore.txt),1,32)
    var %time $gettok($read(highscore.txt),2,32)
    var %score $gettok($read(highscore.txt),3,32)
    var %date $gettok($read(highscore.txt),4,32)
    msg $chan 14 $+ High score of: %score set by4 %name on %date which was $duration($calc($ctime - %time)) ago.
  }
}

on *:text:!help*:%chan: {
  if ($nick isop $chan) { notice $nick You can use !swap to switch batters }
  notice $nick !cricket <wickets> : Start a game of cricket with specified wickets - max 10, min 1. Default is 5. 
  notice $nick To stop a game at any point: !stop (warning: you will lose progress of the game in play)
  notice $nick Batting Options : Defend, Push, Loft
  notice $nick Bowling Options : Yorker, FullToss, Bouncer
  notice $nick In game: /msg Umpire !help
  notice $nick For detailed info on the chances of getting out on each combo, do !combo. 
  notice $nick For bowling/batting functions in game type: /notice Umpire !help.
  notice $nick To view 4High Score type: !high score and !pb or !pb nickname for Personal best score.
  notice $nick To view 4Credits type: !credits.
}

on *:NOTICE:!help*:?:{ 
  notice $nick Batting Options : Defend, Push, Loft
  notice $nick Bowling Options : Yorker, FullToss, Bouncer
} 

on *:text:!swap*:%chan: {
  if ($nick isop $chan) { 
    if (!%p1) || (!%p2) { msg $chan The is no game being played! | halt }
    if (!$3) { msg $chan Syntax: !swap player1 player2 | halt }
    if (%bat == $2 ) { 
      msg $chan 14 $+ $2 has been swapped with $3 and is batting now.
      set %bat $3 
    }
    if (%ball == $2 ) {
      msg %chan 14 $+ $2 has been swapped with $3 $+ . $3 is bowling now.
      set %ball $3
    }
  }
  else { 
    notice $nick You cannot use this command, ask a channel op.
  }
}

on *:text:!combo*:%chan: {
  notice $nick These are the percentages of getting out:
  notice $nick Yorker + Defend  = 20%, Yorker + Push = 20%, Yorker + Loft = 50% 
  notice $nick Bouncer + Defend = 50%, Bouncer + Push = 40%, Bouncer + Loft = 20% 
  notice $nick FullToss + Defend = 0%, FullToss + Push = 20%, FullToss + Loft = 40%
}

on *:text:!cricket*:%chan: {
  if (!%p1) && (!%p2) {
    set %p1 $nick
    if ( $2 > 0 && $2 <= 10 ) { set %tw $2 }
    else { set %tw 5 }
    msg %chan 14 $+ $nick has started the Cricket Game with %tw wickets! To join type !join - This game needs (2) / TWO players to start.
    set %player1 $nick
    cs voice %chan %player1
  }
  if ($nick == %p2) { notice $nick You can't challenge yourself! }
} 

on *:text:!join*:%chan: {
  if (!%p1) && (%p2) { notice $nick There is no game started, type !cricket to start one! | halt }
  if (!%p2) && (%p1) {
    set %p2 $nick
    if (%p2 == %p1) { msg $chan You can't challenge yourself! | halt }
    msg %chan 14 $+ $nick has accepted %p1 $+ 's challenge and gets to call the toss - $nick $+ , Choose !heads or !tails.
    set %toss $rand(1,2)
    set %tosscall 0
    set %player2 $nick
    cs voice %chan %player2
    mode %chan +m
  }
}

on *:text:!stop*:%chan: {
  if (!%p1) && (!%p2) { msg %chan There is no game started, type !cricket to start one! | halt }
  msg %chan 9 $+ The Cricket Game has been stopped by $nick $+ .
  gamehalt 
}

on *:text:!heads*:%chan: {
  if ($nick == %p2) {
    if (%toss == 1) { 
      if ( %tosscall == 0) {
        msg %chan 14 $+ %p2 has won the toss. $nick may decide to !bat or !bowl.
        inc %tosscall 
        set %tosswinner %p2
        set %tossloser %p1
        set %youandme 0
      }
    }
    else { 
      if (%tosscall == 0) {
        msg %chan 4 $+ %p2 has lost the toss. %p1 may decide to !bat or !bowl.
        inc %tosscall
        set %tosswinner %p1
        set %tossloser %p2
        set %youandme 0
      }
    }
  }
}

on *:text:!tails*:%chan: {
  if ($nick == %p2) {
    if (%toss == 1) { 
      if (%tosscall == 0) {
        msg %chan 4 $+ %p2 has lost the toss. %p1 may decide to !bat or !bowl.
        inc %tosscall 
        set %tosswinner %p1
        set %tossloser %p2
        set %youandme 0
      }
    }
    else { 
      if ( %tosscall == 0) {
        msg %chan 14 $+ %p2 has won the toss. $nick may decide to !bat or !bowl.
        inc %tosscall
        set %tosswinner %p2
        set %tossloser %p1
        set %youandme 0
      }
    }
  }
}

on *:text:!bat*:%chan: {
  if ($nick == %tosswinner) {
    if (%youandme == 0) {
      set %bat $nick
      set %ball %tossloser
      msg %chan 14 $+ $nick has decided to bat first! Time to hit the ball hard!
      set %innings 1 
      set %counter 0
      set %score1 0
      set %score2 0
      set %wicket 0
      inc %youandme
      msg %chan 14 $+ %ball $+ : To bowl, type /notice $me !throw followed by your specified type of ball. The possible options are: Bouncer, Fulltoss and Yorker.
      msg %chan 14 $+ %bat $+ : To bat, type /notice $me !hit followed by your specified type of shot. The possible options are: Defend, Push and Loft. You must bat only after the bowler has bowled.   
    }
  }
}

on *:text:!bowl*:%chan: {
  if ($nick == %tosswinner) {
    if (%youandme == 0) {
      set %bat %tossloser
      set %ball $nick
      msg %chan 14 $+ $nick decided to bowl first. Seems like a masterplan for an exciting run-chase.
      set %innings 1
      set %counter 0
      set %score1 0
      set %score2 0
      set %wicket 0
      inc %youandme
      msg %chan 14 $+ %ball $+ : To bowl, type /notice $me !throw followed by your specified type of ball. The possible options are: Bouncer, Fulltoss and Yorker.
      msg %chan 14 $+ %bat $+ : To bat, type /notice $me !hit followed by your specified type of shot. The possible options are: Defend, Push and Loft. You must bat only after the bowler has bowled.
    }
  }
}

on *:NOTICE:!throw*:?:{
  if ($nick == %ball) {
    if (%counter == 0) {
      if ( $2 == yorker ) {
        set %currentball yorker
        inc %counter
        notice $nick 14 $+ You bowled a yorker.
        msg %chan 14 $+ $nick bowled a ball.
      }
      if ($2 == bouncer) {
        set %currentball bouncer
        inc %counter
        notice $nick 14 $+ You bowled a bouncer.
        msg %chan 14 $+ $nick bowled a ball.
      }
      if ($2 == fulltoss) {
        set %currentball fulltoss
        inc %counter
        notice $nick 14 $+ You bowled a fulltoss.
        msg %chan 14 $+ $nick bowled a ball.
      }

    }
  }
}

on *:NOTICE:!hit*:?:{
  if ($nick == %bat) {
    if ( %counter == 1 ) {
      if ($2 == defend ) {
        set %currentbat defend
        inc %counter
        notice $nick 11 $+ You played a defensive shot.
        msg %chan 14 $+ $nick played a shot.
      }
      if ($2 == push) {
        set %currentbat push
        inc %counter 
        notice $nick 11 $+ You played a push shot.
        msg %chan 14 $+ $nick played a shot.
      }
      if ($2 == loft) {
        set %currentbat loft
        inc %counter
        notice $nick 11 $+ You played a lofted shot.
        msg %chan 14 $+ $nick played a shot.
      }
      if (%innings == 1) {
        if (%counter == 2) {
          if (%currentball == yorker && %currentbat == defend ) {
            set %luck $rand(1,5)
            if (%luck == 2) { 
              msg %chan 14 $+ %ball bowled an awesome yorker down the line which %bat tried to defend, but failed. %bat is bowled out.
              set %counter 0
              inc %wicket 
              msg %chan 14 $+ Current Score : %score1 / %wicket
              unset %currentball
              unset %currentbat

            }
            else { 
              set %run $rand(0,1) 
              msg %chan 14 $+ %bat defends the yorker bowled by %ball and gets %run runs.  

              %score1 = %score1 + %run
              msg %chan 14 $+ Current Score : %score1 / %wicket
              set %counter 0
              unset %currentball
              unset %currentbat
            }
          }
          if (%currentball == yorker && %currentbat == push ) {
            set %luck $rand(1,5)
            if (%luck == 2) { 
              msg %chan 14 $+ %ball bowled an awesome yorker down the line. %bat played a push shot but got caught out. 
              set %counter 0
              inc %wicket
              msg %chan 14 $+ Current Score : %score1 / %wicket
              unset %currentball
              unset %currentbat
            }
            else { 
              set %run $rand(2,4) 

              msg %chan 14 $+ %bat plays a push shot on the yorker bowled by %ball and gets %run runs.  

              %score1 = %score1 + %run
              msg %chan 14 $+ Current Score : %score1 / %wicket
              set %counter 0
              unset %currentball
              unset %currentbat
            }
          }
          if (%currentball == yorker && %currentbat == loft ) {
            set %luck $rand(1,2)
            if (%luck == 2) { 
              msg %chan 14 $+ %ball bowled an awesome yorker down the line. %bat played an awesome lofted shot but got caught out. %bat is gone.
              set %counter 0
              inc %wicket
              msg %chan 14 $+ Current Score : %score1 / %wicket
              unset %currentball
              unset %currentbat
            }
            else { 
              set %ru $rand(1,2) 
              if ( %run == 1 ) { %run = 4 }
              else { %run = 6 }
              %score1 = %score1 + %run
              msg %chan 14 $+ %bat swings the bat after %ball bowls the yorker and gets %run runs.  

              msg %chan 14 $+ Current Score : %score1 / %wicket
              set %counter 0
              unset %currentball
              unset %currentbat
            }
          }
          if (%currentball == bouncer && %currentbat == defend ) {
            set %luck $rand(1,5)
            if (%luck == 2 ) { 
              msg %chan 14 $+ %ball bowled an awesome bouncer. %bat tried to defend. The ball hit the edge of the bat and a catch was taken. %bat is out.
              set %counter 0
              inc %wicket
              msg %chan 14 $+ Current Score : %score1 / %wicket
              unset %currentball
              unset %currentbat
            }
            else { 
              set %run $rand(0,1) 
              %score1 = %score1 + %run 
              msg %chan 14 $+ %bat defends with the bat after %ball bowls the bouncer and gets %run runs.  

              msg %chan 14 $+ Current Score : %score1 / %wicket
              set %counter 0
              unset %currentball
              unset %currentbat
            }
          }
          if (%currentball == bouncer && %currentbat == push ) {
            set %luck $rand(1,5)
            if (%luck == 2 || %luck == 4 ) { 
              msg %chan 14 $+ %ball bowled an awesome bouncer %bat played a push shot but got caught out. 
              set %counter 0
              inc %wicket
              msg %chan 14 $+ Current Score : %score1 / %wicket

              unset %currentball
              unset %currentbat
            }
            else { 
              set %run $rand(2,4) 
              %score1 = %score1 + %run 
              msg %chan 14 $+ %bat plays a push shot on the bouncer bowled by %ball and gets %run runs.  

              msg %chan 14 $+ Current Score : %score1 / %wicket
              set %counter 0
              unset %currentball
              unset %currentbat
            }
          }
          if (%currentball == bouncer && %currentbat == loft ) {
            set %luck $rand(1,5)
            if (%luck == 2 ) { 
              msg %chan 14 $+ %ball bowled an awesome bouncer down the line. %bat played an awesome lofted shot, but a fielder near the boundary line took the catch.
              set %counter 0
              inc %wicket
              msg %chan 14 $+ Current Score : %score1 / %wicket
              unset %currentball
              unset %currentbat
            }
            else { 
              set %ru $rand(1,2) 
              if ( %run == 1 ) { %run = 4 }
              else { %run = 6 }

              %score1 = %score1 + %run 
              msg %chan 14 $+ %bat swings the bat after %ball bowls the bouncer and gets %run runs.  

              set %run %tem
              msg %chan 14 $+ Current Score : %score1 / %wicket
              set %counter 0
              unset %currentball
              unset %currentbat
            }
          }
          if (%currentball == fulltoss && %currentbat == defend ) {

            set %run $rand(0,1) 
            %score1 = %score1 + %run 
            msg %chan 14 $+ %bat defends the full toss ball bowled by %ball and gets %run runs.  

            msg %chan 14 $+ Current Score : %score1 / %wicket
            set %counter 0
            unset %currentball
            unset %currentbat
          }
          if (%currentball == fulltoss && %currentbat == push ) {
            set %luck $rand(1,5)
            if (%luck == 2) { 
              msg %chan 14 $+ %ball bowled an awesome full toss ball. %bat played a push shot but got caught out in between by a fielder. 
              set %counter 0
              inc %wicket
              msg %chan 14 $+ Current Score : %score1 / %wicket
              unset %currentball
              unset %currentbat
            }
            else { 
              set %run $rand(2,4) 
              %score1 = %score1 + %run 
              msg %chan 14 $+ %bat plays a push shot on the full toss bowled by %ball and gets %run runs.  

              msg %chan 14 $+ Current Score : %score1 / %wicket
              set %counter 0
              unset %currentball
              unset %currentbat
            }
          }
          if (%currentball == fulltoss && %currentbat == loft ) {
            set %luck $rand(1,5)
            if (%luck == 2 || %luck == 4 ) { 
              msg %chan 14 $+ %ball bowled an awesome full toss ball down the line. %bat played an awesome lofted shot, but a fielder near the boundary line took the catch.
              set %counter 0
              inc %wicket
              msg %chan 14 $+ Current Score : %score1 / %wicket
              unset %currentball
              unset %currentbat
            }
            else { 
              set %ru $rand(1,2) 
              if ( %run == 1 ) { %run = 4 }
              else { %run = 6 }

              msg %chan 14 $+ %bat swings the bat after %ball bowls the full toss and gets %run runs.  
              %score1 = %score1 + %run

              msg %chan 14 $+ Current Score : %score1 / %wicket
              set %counter 0
              unset %currentball
              unset %currentbat
            }
          }
          if ( %wicket == %tw ) {
            inc %innings
            %pqrs = %score1 + 1 
            msg %chan 11 $+ Score :- %score1 / %tw
            msg %chan 11 $+ %bat has lost all their wickets. Now %ball needs %pqrs to win the match.
            check_personal_high_one
            if (%score1 == %hs) { set %hs %score1 | msg %chan %bat just 4equalled the Highscore of %score1 $+ ! | high_score_one }
            if (%score1 > %hs) { set %hs %score1 | msg %chan a 4NEW Highscore of %score1 has been set by %bat $+ ! | high_score_one } 
            %temporary = %bat
            %bat = %ball
            %ball = %temporary
            set %wicket 0
            msg %chan 14 $+ Its time for the second innings. Now %ball will be bowling and %bat will be batting.
            msg %chan 14 $+ %ball $+ : To bowl, type /notice $me !throw followed by your specified type of ball. The possible options are: Bouncer, Fulltoss and Yorker.
            msg %chan 14 $+ %bat $+ : To bat, type /notice $me !hit followed by your specified type of shot. The possible options are: Defend, Push and Loft. You must bat only after the bowler has bowled
          }

        }
      }
      if (%innings == 2 ) {
        if (%counter == 2) {

          if ( %currentball == yorker && %currentbat == defend ) {
            set %luck $rand(1,5)
            if (%luck == 2) { 
              msg %chan 14 $+ %ball bowled an awesome yorker down the line which %bat tried to defend, but failed. %bat is bowled.
              set %counter 0
              inc %wicket 
              msg %chan 14 $+ Current Score : %score2 / %wicket
              unset %currentball
              unset %currentbat
              if ( %wicket == %tw ) {
                msg %chan 14 $+ %bat lost their last wicket and the match. %ball wins the game and is the ultimate champion. 
                gamehalt
                inc %innings
                gamehalt
              }
            }
            else { 
              set %run $rand(0,1) 
              msg %chan 14 $+ %bat defends the yorker bowled by %ball and gets %run runs.  

              %score2 = %score2 + %run
              msg %chan 14 $+ Current Score : %score2 / %wicket
              set %counter 0
              unset %currentball
              unset %currentbat
              if ( %score2 > %score1 ) { 
                msg %chan 14 $+ %bat has achieved the target and won the match. Good game! Match Over.
                check_personal_high_two 
                if (%score2 == %hs) { set %hs %score2 | msg %chan %bat just equalled the Highscore of %score2 $+ ! | high_score_two }
                if (%score2 > %hs) { set %hs %score2 | msg %chan A NEW Highscore has been set by %bat $+ ! | high_score_two }  
                gamehalt
              }
            }
          }
          if (%currentball == yorker && %currentbat == push ) {
            set %luck $rand(1,5)
            if (%luck == 2 ) { 
              msg %chan 14 $+ %ball bowled an awesome yorker down the line. %bat played a push shot but got caught out. 
              set %counter 0
              inc %wicket
              msg %chan 14 $+ Current Score : %score2 / %wicket
              unset %currentball
              unset %currentbat
              if ( %wicket == %tw ) {
                msg %chan 14 $+ %bat lost their last wicket and the match. %ball wins the game and is the ultimate champion. 
                inc %innings
                gamehalt
              }
            }
            else { 
              set %run $rand(2,4) 

              msg %chan 14 $+ %bat plays a push shot on the yorker bowled by %ball and gets %run runs.  

              %score2 = %score2 + %run
              msg %chan 14 $+ Current Score : %score2 / %wicket
              set %counter 0
              unset %currentball
              unset %currentbat

              if ( %score2 > %score1 ) { 
                msg %chan 14 $+ %bat has achieved the target and won the match. Good game! Match Over.
                check_personal_high_two 
                if (%score2 == %hs) { set %hs %score2 | msg %chan %bat just equalled the Highscore of %score2 $+ ! | high_score_two }
                if (%score2 > %hs) { set %hs %score2 | msg %chan A NEW Highscore has been set by %bat $+ ! | high_score_two } 
                gamehalt
              }

            }
          }
          if (%currentball == yorker && %currentbat == loft ) {
            set %luck $rand(1,2)
            if (%luck == 2) { 
              msg %chan 14 $+ %ball bowled an awesome yorker down the line. %bat played an awesome lofted shot but got caught out. %bat is gone.
              set %counter 0
              inc %wicket
              msg %chan 14 $+ Current Score : %score2 / %wicket
              unset %currentball
              unset %currentbat
              if ( %wicket == %tw ) {
                msg %chan 14 $+ %bat lost their last wicket and the match. %ball wins the game and is the ultimate champion.
                inc %innings
                gamehalt
              }
            }
            else { 
              set %ru $rand(1,2) 
              if ( %run == 1 ) { %run = 4 }
              else { %run = 6 } 

              %score2 = %score2 + %run 
              msg %chan 14 $+ %bat swings the bat after %ball bowls the yorker and gets %run runs.  

              msg %chan 14 $+ Current Score : %score2 / %wicket
              set %counter 0
              unset %currentball
              unset %currentbat
              if ( %score2 > %score1 ) { 
                msg %chan 14 $+ %bat has achieved the target and won the match. Good game! Match Over. 
                check_personal_high_two
                if (%score2 == %hs) { set %hs %score2 | msg %chan %bat just equalled the Highscore of %score2 $+ ! | high_score_two }
                if (%score2 > %hs) { set %hs %score2 | msg %chan A NEW Highscore has been set by %bat $+ ! | high_score_two } 
                gamehalt
              }
            }
          }
          if (%currentball == bouncer && %currentbat == defend ) {
            set %luck $rand(1,2)
            if (%luck == 2 ) { 
              msg %chan 14 $+ %ball bowled an awesome bouncer. %bat tried to defend. The ball hit the edge of the bat and a catch was taken. %bat is gone.
              set %counter 0
              inc %wicket
              msg %chan 14 $+ Current Score : %score2 / %wicket
              unset %currentball
              unset %currentbat
              if ( %wicket == %tw ) {
                msg %chan 14 $+ %bat lost their last wicket and the match. %ball wins the game and is the ultimate champion.
                inc %innings
                gamehalt
              }
            }
            else { 
              set %run $rand(0,1) 
              %score2 = %score2 + %run 
              msg %chan 14 $+ %bat defends with the bat after %ball bowls the bouncer and gets %run runs.  

              msg %chan 14 $+ Current Score : %score2 / %wicket
              set %counter 0
              unset %currentball
              unset %currentbat
              if ( %score2 > %score1 ) { 
                msg %chan 14 $+ %bat has achieved the target and won the match. Good game! Match Over.
                check_personal_high_two 
                if (%score2 == %hs) { set %hs %score2 | msg %chan %bat just equalled the Highscore of %score2 $+ ! | high_score_two }
                if (%score2 > %hs) { set %hs %score2 | msg %chan A NEW Highscore has been set by %bat $+ ! | high_score_two } 
                gamehalt
              }
            }
          }
          if (%currentball == bouncer && %currentbat == push ) {
            set %luck $rand(1,5)
            if (%luck == 2 || %luck == 4 ) { 
              msg %chan 14 $+ %ball bowled an awesome bouncer %bat played a push shot but got caught out. 
              set %counter 0
              inc %wicket
              msg %chan 14 $+ Current Score : %score2 / %wicket

              unset %currentball
              unset %currentbat
              if ( %wicket == %tw ) {
                msg %chan 14 $+ %bat lost their last wicket and the match. %ball wins the game and is the ultimate champion. 
                inc %innings
                gamehalt
              }
            }
            else { 
              set %run $rand(2,4) 
              %score2 = %score2 + %run 
              msg %chan 14 $+ %bat plays a push shot on the bouncer bowled by %ball and gets %run runs.  

              msg %chan 14 $+ Current Score : %score2 / %wicket
              set %counter 0
              unset %currentball
              unset %currentbat
              if ( %score2 > %score1 ) { 
                msg %chan 14 $+ %bat has achieved the target and won the match. Good game! Match Over. 
                check_personal_high_two
                iif (%score2 == %hs) { set %hs %score2 | msg %chan %bat just equalled the Highscore of %score2 $+ ! | high_score_two }
                if (%score2 > %hs) { set %hs %score2 | msg %chan A NEW Highscore has been set by %bat $+ ! | high_score_two } 
                gamehalt
              }

            }
          }
          if (%currentball == bouncer && %currentbat == loft ) {
            set %luck $rand(1,5)
            if (%luck == 2 ) { 
              msg %chan 14 $+ %ball bowled an awesome bouncer down the line. %bat played an awesome lofted shot, but a fielder near the boundary line took the catch.
              set %counter 0
              inc %wicket
              msg %chan 14 Current Score : %score2 / %wicket
              unset %currentball
              unset %currentbat
              if ( %wicket == %tw ) {
                msg %chan 14 $+ %bat lost their last wicket and the match. %ball wins the game and is the ultimate champion. 
                inc %innings 
                gamehalt
              }
            }
            else { 
              set %ru $rand(1,2) 
              if ( %run == 1 ) { %run = 4 }
              else { %run = 6 }

              %score2 = %score2 + %run 
              msg %chan 14 $+ %bat swings the bat after %ball bowls the bouncer and gets %run runs.  

              set %run %tem
              msg %chan 14 $+ Current Score : %score2 / %wicket
              set %counter 0
              unset %currentball
              unset %currentbat
              if ( %score2 > %score1 ) { 
                msg %chan 14 $+ %bat has achieved the target and won the match. Good game! Match Over. 
                check_personal_high_two
                if (%score2 == %hs) { set %hs %score2 | msg %chan %bat just equalled the Highscore of %score2 $+ ! | high_score_two }
                if (%score2 > %hs) { set %hs %score2 | msg %chan A NEW Highscore has been set by %bat $+ ! | high_score_two }  
                gamehalt
              }

            }
          }
          if (%currentball == fulltoss && %currentbat == defend ) {

            set %run $rand(0,1)
            %score2 = %score2 + %run
            msg %chan 14 $+ %bat defends the full toss ball bowled by %ball and gets %run runs.  

            msg %chan 14 Current Score : %score2 / %wicket
            set %counter 0
            unset %currentball
            unset %currentbat
            if ( %score2 > %score1 ) { 
              msg %chan 14 $+ %bat has achieved the target and won the match. Good game! Match Over. 
              check_personal_high_two
              if (%score2 == %hs) { set %hs %score2 | msg %chan %bat just equalled the Highscore of %score2 $+ ! | high_score_two }
              if (%score2 > %hs) { set %hs %score2 | msg %chan A NEW Highscore has been set by %bat $+ ! | high_score_two }  
              gamehalt
            }
          }
          if (%currentball == fulltoss && %currentbat == push ) {
            set %luck $rand(1,5)
            if (%luck == 2 ) { 
              msg %chan 14 $+ %ball bowled an awesome full toss ball. %bat played a push shot but got caught out in between by a fielder. 
              set %counter 0
              inc %wicket
              msg %chan 14 $+ Current Score : %score2 / %wicket
              unset %currentball
              unset %currentbat
              if ( %wicket == %tw ) {
                msg %chan 14 $+ %bat lost their last wicket and the match. %ball wins the game and is the ultimate champion. 
                inc %innings 
                gamehalt
              }
            }
            else { 
              set %run $rand(2,4) 
              %score2 = %score2 + %run 
              msg %chan 14 $+ %bat plays a push shot on the full toss bowled by %ball and gets %run runs.  

              msg %chan 14 $+ Current Score : %score2 / %wicket
              set %counter 0
              unset %currentball
              unset %currentbat
              if ( %score2 > %score1 ) { 
                msg %chan 14 $+ %bat has achieved the target and won the match. Good game! Match Over.
                check_personal_high_two 
                if (%score2 == %hs) { set %hs %score2 | msg %chan %bat just equalled the Highscore of %score2 $+ ! | high_score_two }
                if (%score2 > %hs) { set %hs %score2 | msg %chan A NEW Highscore has been set by %bat $+ ! | high_score_two }   
                gamehalt
              }

            }
          }
          if (%currentball == fulltoss && %currentbat == loft ) {
            set %luck $rand(1,5)
            if (%luck == 2 || %luck == 4 ) { 
              msg %chan 14 $+ %ball bowled an awesome full toss ball down the line. %bat played an awesome lofted shot, but a fielder near the boundary line took the catch.
              set %counter 0
              inc %wicket
              msg %chan 14 $+ Current Score : %score2 / %wicket
              unset %currentball
              unset %currentbat
              if ( %wicket == %tw ) {
                msg %chan 14 $+ %bat lost their last wicket and the match. %ball wins the game and is the ultimate champion. 
                inc %innings
                gamehalt
              }
            }
            else { 
              set %ru $rand(1,2) 
              if ( %run == 1 ) { %run = 4 }
              else { %run = 6 }
              %score2 = %score2 + %run 
              msg %chan 14 $+ %bat swings the bat after %ball bowls the full toss and gets %run runs.  
              msg %chan 14 $+ Current Score : %score2 / %wicket
              set %counter 0
              unset %currentball
              unset %currentbat
              if ( %score2 > %score1 ) { 
                msg %chan 14 $+ %bat has achieved the target and won the match. Good game! Match Over. 
                check_personal_high_two
                if (%score2 == %hs) { set %hs %score2 | msg %chan %bat just equalled the Highscore of %score2 $+ ! | high_score_two }
                if (%score2 > %hs) { set %hs %score2 | msg %chan A NEW Highscore has been set by %bat $+ ! | high_score_two }   
                gamehalt
              }
            }
          }
        }
      }
    }
  }
}

Comments

Sign in to comment.
bond007   -  Apr 27, 2018

sir plz make this type of cricket game bcoz manish17 game is not working plz make a game like manish plz sir i m waiting
Saw This script http://hawkee.com/snippet/17907/ by manish17, made it work with a few extra's.

newklear  -  May 14, 2018

That is what this script is, a working copy of cricket.

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.