Multiplayer Cricket For IRC

By manish17 on Feb 01, 2017

Hello , so the script lets you play cricket online in the chatroom .
You can select up to 10 wickets and play with 2 players.

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

Paste the snippet on your remotes and get ready for action!

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 .
!stopcricket : Stops the game
!helpcricket : Lists all important commands.
!combo : Displays the chances of getting out on each combo.
.
Note : - A bowler must bowl first by noticing the bot . Then only the batsman can bat by , again , noticing the bot.

############################################################
##          Multiplayer Cricket Game                         ##
##             Version: 1.0                              ##
##             By: manish17                              ##
##             irc.lucidchat.net #LoveLife                 ##
############################################################

on *:LOAD: set %chan $input(Enter name of the channel including the #:,e) 
on *:LOAD: set %owner $input(Enter name of the bot owner:,e) 

on *:text:!cricket*:#: {
  if (%p1 == $null) && (%p2 == $null) && (%idnick [ $+ [ $nick ] ] != $null) {
    set %p1 $nick
    if ( $2 > 0 && $2 <= 10 ) { set %tw $2 }
    else { set %tw 5 }
    msg %chan 10 $+ $nick has started the Cricket game of %tw wickets! To join type !joincricket - Needs TWO players to start
  }
  elseif (%p1 != $null) && (%p2 == $null) { notice $nick %p1 already started a game, type !join to VS Him/Her }

  elseif ($address($nick,2) == %p1) { notice $nick You can't challenge yourself! }
  } }

  on *:text:!joincricket*:#: {
  if (%p1 != $null) && (%p2 == $null) && (%idnick [ $+ [ $nick ] ] != $null) && ($address($nick,2) != %p1) {
    set %p2 $nick

    msg %chan 14 $+ $nick has accepted %p1 $+ 's challenge and gets to call the toss - Reply by !heads or !tails .

    set %toss $rand(1,2)
    set %tosscall 0
  }
  elseif (%p1 == $null) && (%p2 == $null) { notice $nick There is no game started, type !cricket to start one! }
  elseif ( %p2 == %p1) { notice $nick You can't challenge yourself! }
 }
on *:text:!stopcricket*:#: {
if ( $nick == %owner ) {
 msg %chan 9 The Cricket Game has been stopped by %owner .
 gamehalt 
 }
 }
 alias gamehalt {
  unset %p1
  unset %p2
  unset %toss
  unset %tosscall
  unset %tosswinner
  unset %tossloser
  unset %bat
  unset %ball
  unset %innings
  unset %counter
  unset %currentbat
  unset %currentball
  unset %score1
  unset %score2
  unset %wicket

  }

on *:text:!heads*:#: {
if ( $nick == %p2) {
if (%toss == 1) { 
if ( %tosscall == 0) {
msg %chan 3 %p2 has won the toss . $nick may decide to !bat or !ball.
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 !ball
inc %tosscall
set %tosswinner %p1
set %tossloser %p2
set %youandme 0
}
}
}
}

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

on *:text:!bat*:#: {
if ($nick == %tosswinner) {
if (%youandme == 0) {
set %bat $nick
set %ball %tossloser
 msg %chan 10 $nick 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 7 %bat : To bat , type /notice $me !hit followed by your specified type of shot. The possible options are : Defense , Push and Loft . You must bat only after the bowler has bowled. 
msg %chan 6 %ball : To bowl , type /notice $me !throw followed by your specified type of ball . The possible options are : Bouncer , FullToss and Yorker . 
}
}
}

on *:text:!ball*:#: {
if ($nick == %tosswinner) {
if (%youandme == 0) {
set %bat %tossloser
set %ball $nick
msg %chan  7 $nick decided to ball 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 7 %bat : To bat , type /notice $me !hit followed by your specified type of shot. The possible options are : Defense , Push and Loft . You must bat only after the bowler bowls.
msg %chan 6 %ball : To bowl , type /notice $me !throw followed by your specified type of ball . The possible options are : Bouncer , FullToss and Yorker . 
}
}
}

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

}
}
}

on *:NOTICE:!hit*:?:{

if ($nick == %bat) {
if ( %counter == 1 ) {
if ($2 == defense ) {
set %currentbat defense
inc %counter
notice $nick 11 You played a defensive shot.
msg %chan 8 $nick played a shot.
}
if ($2 == push) {
set %currentbat push
inc %counter 
notice $nick 11 You played a push shot.
msg %chan 8 $nick played a shot.
}
if ($2 == loft) {
set %currentbat loft
inc %counter
notice $nick 11 You played a lofted shot.
msg %chan 8 $nick played a shot.

}

if (%innings == 1) {
if (%counter == 2) {
if (%currentball == yorker && %currentbat == defense ) {
set %luck $rand(1,5)
if (%luck == 2) { 
msg %chan 10 %ball bowled an awesome yorker down the line which %bat tried to defend , but failed. He is bowled.
set %counter 0
inc %wicket 
msg %chan 3 Current Score : %score1 / %wicket
unset %currentball
unset %currentbat

}

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

%score1 = %score1 + %run
msg %chan 9 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 10 %ball bowled an awesome yorker down the line. %bat played a push shot but got caught out. 
set %counter 0
inc %wicket
msg %chan 3 Current Score : %score1 / %wicket
unset %currentball
unset %currentbat
 }
else { 
set %run $rand(2,4) 

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

%score1 = %score1 + %tem
msg %chan 9 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 10 %ball bowled an awesome yorker down the line. %bat played an awesome lofted shot but got caught out. He is gone.
set %counter 0
inc %wicket
msg %chan 3 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 7 %bat swings the bat after %ball bowls the yorker and gets %run runs.  

msg %chan 9 Current Score : %score1 / %wicket
set %counter 0
unset %currentball
unset %currentbat
}
}

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

msg %chan 9 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 10 %ball bowled an awesome bouncer  %bat played a push shot but got caught out. 
set %counter 0
inc %wicket
msg %chan 3 Current Score : %score1 / %wicket

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

msg %chan 9 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 10 %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 3 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 7 %bat swings the bat after %ball bowls the bouncer and gets %run runs.  

set %run %tem
msg %chan 9 Current Score : %score1 / %wicket
set %counter 0
unset %currentball
unset %currentbat
}
}

if (%currentball == fulltoss && %currentbat == defense ) {

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

msg %chan 9 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 10 %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 3 Current Score : %score1 / %wicket
 unset %currentball
unset %currentbat
 }
else { 
set %run $rand(2,4) 
%score1 = %score1 + %run 
msg %chan 7 %bat plays a push shot on the full toss bowled by %ball and gets %run runs.  

msg %chan 9 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 10 %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 3 Current Score : %score1 / %wicket
 unset %currentball
unset %currentbat
 }
else { 
set %ru $rand(1,2) 
if ( %run == 1 ) { %run = 4 }
else { %run = 6 }

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

msg %chan 9 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 his wickets. Now %ball needs %pqrs to win the match.
 %temporary = %bat
 %bat = %ball
 %ball = %temporary
 set %wicket 0
 msg %chan 14 Its time for the second innings. Now %ball will be balling and %bat will be batting.
 msg %chan 7 %bat : To bat , type /notice $me !hit followed by your specified type of shot. The possible options are : Defense , Push and Loft . You must bat only after the bowler bowls.
msg %chan 6 %ball : To bowl , type /notice $me !throw followed by your specified type of ball . The possible options are : Bouncer , FullToss and Yorker . 
 }

}
}

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

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

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

if ( %score2 > %score1 ) { 
msg %chan 10 %bat has achieved the target and won the match . Good game! Game stops . 
gamehalt
}
}
}

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

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

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

if ( %score2 > %score1 ) { 
msg %chan 10 %bat has achieved the target and won the match . Good game! Game stops . 
gamehalt
}

}
}

if (%currentball == yorker && %currentbat == loft ) {
set %luck $rand(1,2)
if (%luck == 2) { 
msg %chan 10 %ball bowled an awesome yorker down the line. %bat played an awesome lofted shot but got caught out. He is gone.
set %counter 0
inc %wicket
msg %chan 3 Current Score : %score2 / %wicket
 unset %currentball
unset %currentbat
if ( %wicket == %tw ) {
msg %chan 10 %bat lost his last wicket and eventually 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 7 %bat swings the bat after %ball bowls the yorker and gets %run runs.  

msg %chan 9 Current Score : %score2 / %wicket
set %counter 0
unset %currentball
unset %currentbat
if ( %score2 > %score1 ) { 
msg %chan 10 %bat has achieved the target and won the match . Good game! Game stops . 
gamehalt
}
}
}

if (%currentball == bouncer && %currentbat == defense ) {
set %luck $rand(1,2)
if (%luck == 2 ) { 
msg %chan 10 %ball bowled an awesome bouncer . %bat tried to defend. The ball hit the edge of the bat and a catch was taken. He is gone.
set %counter 0
inc %wicket
msg %chan 3 Current Score : %score2 / %wicket
 unset %currentball
unset %currentbat
if ( %wicket == %tw ) {
msg %chan 10 %bat lost his last wicket and eventually 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 7 %bat defenses with the bat after %ball bowls the bouncer and gets %run runs.  

msg %chan 9 Current Score : %score2 / %wicket
set %counter 0
unset %currentball
unset %currentbat
if ( %score2 > %score1 ) { 
msg %chan 10 %bat has achieved the target and won the match . Good game! Game stops . 
gamehalt
}
}
}

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

unset %currentball
unset %currentbat
if ( %wicket == %tw ) {
msg %chan 10 %bat lost his last wicket and eventually 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 7 %bat plays a push shot on the bouncer bowled by %ball and gets %run runs.  

msg %chan 9 Current Score : %score2 / %wicket
set %counter 0
unset %currentball
unset %currentbat
if ( %score2 > %score1 ) { 
msg %chan 10 %bat has achieved the target and won the match . Good game! Game stops . 
gamehalt
}

}
}

if (%currentball == bouncer && %currentbat == loft ) {
set %luck $rand(1,5)
if (%luck == 2 ) { 
msg %chan 10 %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 3 Current Score : %score2 / %wicket
 unset %currentball
unset %currentbat
if ( %wicket == %tw ) {
msg %chan 10 %bat lost his last wicket and eventually 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 7 %bat swings the bat after %ball bowls the bouncer and gets %run runs.  

set %run %tem
msg %chan 9 Current Score : %score2 / %wicket
set %counter 0
unset %currentball
unset %currentbat
if ( %score2 > %score1 ) { 
msg %chan 10 %bat has achieved the target and won the match . Good game! Game stops . 
gamehalt
}

}
}

if (%currentball == fulltoss && %currentbat == defense ) {

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

msg %chan 9 Current Score : %score2 / %wicket
set %counter 0
unset %currentball
unset %currentbat
if ( %score2 > %score1 ) { 
msg %chan 10 %bat has achieved the target and won the match . Good game! Game stops . 
gamehalt
}
}

if (%currentball == fulltoss && %currentbat == push ) {
set %luck $rand(1,5)
if (%luck == 2 ) { 
msg %chan 10 %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 3 Current Score : %score2 / %wicket
 unset %currentball
unset %currentbat
if ( %wicket == %tw ) {
msg %chan 10 %bat lost his last wicket and eventually 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 7 %bat plays a push shot on the full toss bowled by %ball and gets %run runs.  

msg %chan 9 Current Score : %score2 / %wicket
set %counter 0
unset %currentball
unset %currentbat
if ( %score2 > %score1 ) { 
msg %chan 10 %bat has achieved the target and won the match . Good game! Game stops . 
gamehalt
}

}
}

if (%currentball == fulltoss && %currentbat == loft ) {
set %luck $rand(1,5)
if (%luck == 2 || %luck == 4 ) { 
msg %chan 10 %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 3 Current Score : %score2 / %wicket
 unset %currentball
unset %currentbat
if ( %wicket == %tw ) {
msg %chan 10 %bat lost his last wicket and eventually 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 7 %bat swings the bat after %ball bowls the full toss and gets %run runs.  

msg %chan 9 Current Score : %score2 / %wicket
set %counter 0
unset %currentball
unset %currentbat
if ( %score2 > %score1 ) { 
msg %chan 10 %bat has achieved the target and won the match . Good game! Game stops . 
gamehalt
}
}
}
}
}
}
}
}
}

on *:text:!swap*:#: {
if ($nick == %owner ) { 
if (%bat == $2 ) { 
msg $chan 10 $2 has been swapped with $3 and is batting now.
set %bat $3 
}
if (%ball == $2 ) {
msg %chan 10 $2 has been swapped with $3 . $3 is bowling now.
  set %ball $3
  }
  }
  else { 
  notice $nick You cannot use this command.
  }
  }

  on *:text:!helpcricket*:#: {
  notice $nick !cricket <wickets> : Start a game of cricket with specified wickets - maximum 10 . Default is 5 . 
  notice $nick Batting Options : Defense , Push , Loft
  notice $nick Bowling Options : Yorker , FullToss , Bouncer
  notice $nick For detailed info on the chances of getting out on each combo , do !combo . 
  }

  on *:text:!combo*:#: {
  notice $nick The percentages are the chances of getting out.
  notice $nick Yorker + Defense  = 20 % , Yorker + Push = 20% , Yorker + Loft = 50% 
  notice $nick Bouncer + Defense = 50% , Bouncer + Push = 40 % , Bouncer + Loft = 20% 
  notice $nick FullToss + Defense = 0% , FullToss + Push = 20% , FullToss + Loft = 40%
  }

Comments

Sign in to comment.
bond007   -  Aug 12, 2017

Bro this script not working i try to many times but always fail not works this cricket script

 Respond  
fahadmehar   -  Apr 24, 2017

Is this TCL or Remote?

 Respond  
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.