LG-Gaming Marathon
Would you like to react to this message? Create an account in a few clicks or log in to continue.


LG-Gaming Marathon Server hosted by LGrobert
 
HomeSearchLatest imagesRegisterLog in

 

 Deal or Nodeal game

Go down 
AuthorMessage
LGrobert
Elite Newbie
LGrobert


Male Number of posts : 40
Age : 37
Status : Founder
Points : 9
Registration date : 2008-09-30

Deal or Nodeal game Empty
PostSubject: Deal or Nodeal game   Deal or Nodeal game Icon_minitimeFri Nov 28, 2008 1:26 pm

Thats the game script.Part 1

Code:
On *:LOAD: dond.settings 1

ON *:START: {
  if ( !$hget($_table) ) hmake $_table 10
  if ( !$hget($_players) ) hmake $_players 10
  if ( $isfile($_data) ) hload $_table $_data
  if ( $isfile($_playdata) ) hload $_players $_playdata
  dond.settings
}

On *:EXIT: dond.save
On *:DISCONNECT: dond.save

On *!:NICK: {
  if ( !$readini($_ini,config,enable) ) return
  if ( $hget($_players,$+($network,:,$dondchan,:,$nick)) ) {
    hdel $_players $+($network,:,$dondchan,:,$nick)
    hadd $_players $+($network,:,$dondchan,:,$newnick) 1
  }
  elseif ( $nick == %dond.player ) set %dond.player $newnick
}

On *!:QUIT: {
  if ( !$readini($_ini,config,enable) ) return
  if ( $hget($_players,$+($network,:,$dondchan,:,$nick)) ) hdel $_players $+($network,:,$dondchan,:,$nick)
  elseif ( $nick == %dond.player ) {
    unset %dond.player
    msg $dondchan 10 $+ $nick just quitted. A new player will be picked shortly...
    .timerdond.rpick 1 2 dond.rpick $network $dondchan new
  }
}
On *!:KICK:$($dondchan): {
  if ( !$readini($_ini,config,enable) ) return
  if ( $hget($_players,$+($network,:,#,:,$knick)) ) hdel $_players $+($network,:,#,:,$knick)
  elseif ( $knick == %dond.player ) {
    unset %dond.player
    msg $dondchan 10 $+ $nick was kicked. A new player will be picked shortly...
    .timerdond.rpick 1 2 dond.rpick $network $chan new
  }
}
On *!:PART:$($dondchan): {
  if ( !$readini($_ini,config,enable) ) return
  if ( $hget($_players,$+($network,:,#,:,$nick)) ) hdel $_players $+($network,:,#,:,$nick)
  elseif ( $nick == %dond.player ) {
    unset %dond.player
    msg $dondchan 10 $+ $nick just left the channel. A new player will be picked shortly...
    .timerdond.rpick 1 2 dond.rpick $network $chan new
  }
}

On !*:JOIN:$($dondchan): {
  $+(.timerdondjoinmsg,$cid,$chan,$nick) 1 2 .notice $nick Welcome to $chan $+ , $nick $+ ! $dond.logo v $+ $dond.version is $iif($readini($_ini,config,enable),10ON. Type 03!dond to start the game.,04OFF.)
}


On *:TEXT:!*:$($dondchan): {
  if ( !$readini($_ini,config,enable) ) return
  if ( $istok(!dond !start,$1,32) ) {
    if ( !%dond.status ) {
      if ( !%dond.start ) {
        dond.start $network $chan
      }
      else msg $chan The game is about to start in %dond.start secs. Type 3!join now.
    }
    else {
      if ( %dond.player == $nick ) msg $chan 07You are already playing the game!
      elseif ( %dond.player ) msg $chan 12Please wait after07 %dond.player 12finishes the game.
    }
  }
  elseif ( $1 == !stop ) && ( $nick isop $chan ) dond.end $nick
  elseif ( $1 == !pass ) && ( %dond.player == $nick ) {
    unset %dond.player
    msg $chan 10 $+ $nick has passed playing the game. 12A new player will be picked shortly...
    if ( $me isop $chan ) mode $chan -v $nick
    .timerdond.* off
    .timerdond.rpick 1 2 dond.rpick $network $chan new
  }
  elseif ( $1 == !stats ) {
    var %n = $iif($2,$2,$nick)
    msg $chan $dond.logo stats for12 %n $+ :03 $comma($iif($hget($_table,$+($network,:,$chan,:,%n)),$v1,0)) Total Points
  }
  elseif ( $1 == !join ) {
    if ( %dond.start ) || ( %dond.status == playing ) {
      if ( !$hget($_players,$+($network,:,$chan,:,$nick)) ) {
        hadd -m $_players $+($network,:,$chan,:,$nick) 1
        msg $chan Thank you for joining,10 $nick $+ . Player will be randomly picked $iif(%dond.start,in07 %dond.start secs.,after10 %dond.player finishes the game.)
      }
      else msg $chan You already joined the game. Please wait for the game to start.
    }
  }
  elseif ( $1 == !confirm ) {
    if ( %dond.status == confirm ) && ( %dond.player.temp == $nick ) {
      set %dond.status playing
      .timerdond.noconfirm off
      set %dond.player $nick
      unset %dond.player.temp
      msg $chan GOOD! Then let's play $dond.logo $+ !
      if ( $me isop $chan ) && ( $readini($_ini,config,avplayer) ) mode $chan +v $nick
      ;hadd -m $_prevplayers $+($network,:,$chan,:,$nick)
      dond.createboxes
      .timerdond.chooseanybox 1 2  msg $chan There are 26 boxes. Choose any box (from 1 to 26) so we can start playing. Type 3!choose <number>. You have04 $dond.time(randomchoosebox) secs or I will randomly select a box for you.
      .timerdond.random.choose 1 $calc($dond.time(randomchoosebox) + 2) dond.randomchoosebox
      set %dond.level 0
    }
  }
  elseif ( $istok(!deal !nodeal,$1,32) ) && ( %dond.player == $nick ) && ( %dond.answerdond ) {
    if ( $timer(dond.autoaccept) ) .timerdond.autoaccept off
    if ( $1 == !deal ) {
      unset %dond.player
      tokenize 32 $hget($_table,$+($network,:,$chan,:,$nick))
      hadd -m $_table $+($network,:,$chan,:,$nick) $calc($1 + %dond.bankerdeal) $2 $3
      msg $chan You have accepted the Banker's offer. You get10 $comma(%dond.bankerdeal) points. Your total points is now03 $comma($hget($_table,$+($network,:,$chan,:,$nick))) $+ . Thank you for playing.
      if ( $me isop $chan ) mode $chan -v $nick   
      .timerdond.rpick 1 2 dond.rpick $network $chan new
    }
    else {
      msg $chan You declined the Banker's offer. Let's continue playing!
      inc %dond.level
      var %d = $dond.casesperlevel
      msg $chan Now, $iif( %dond.level == 8,choose from the last box $+(09,$chr(44),01) $+ $gettok(%dond.boxwdamts,1,58) $+  and your chosen box $+(09,$chr(44),01) $+ $gettok(%dond.chosenbox,1,58) $+ , you have to eliminate04 %d boxes.) Type 03!choose $str($+(<number>,$chr(32)),%d) to eliminate the boxes. You have07 $dond.time(timelimit) secs to respond.
      .timerdond.timelimit 1 $dond.time(timelimit) dond.timelimit $network $chan %dond.player
    }
    unset %dond.answerdond %dond.pickednum
  }
  elseif ( $1 == !choose ) {
    if ( %dond.player == $nick ) {
      dond.choose $nick $network $chan $2-
    }
  }
  elseif ( $1 == !commands ) msg $chan $dond.logo commands: !dond !join !confirm !deal !nodeal !stats !pass !stop !top10
  elseif ( $1 == !top10 ) dond.top $network $chan
}


;############ ALIASES #############

alias -l dondchan return $readini($_ini,config,channel)
alias dond.version return 0.18 BETA
alias -l _table return dond.scores
alias -l _players return dond.players
alias -l _prevplayers return dond.prevplayers
alias -l _playdata return $qt($scriptdirdondplayers.dat)
alias -l _data return $qt($scriptdirdondscores.dat)
alias -l _ini return $qt($scriptdirdond.ini)
alias -l dond.logo return 01,08DEALor08,01NODEAL

alias -l dond.rpick {
  if ( $3 == new ) msg $dondchan 12Let's continue the game. Picking a random player now....
  if ( $dond.players($1,$2) ) {
    var %n = $dond.players($1,$2).rand
    set %dond.player.temp $gettok(%n,3,58)
    hdel $_players %n
    .timerdond.newplayer 1 5 msg $dondchan The new player is ->07 %dond.player.temp <- Please type 03!confirm within04 $dond.time(confirmtime) secs, to confirm that you want to play.
    set %dond.status confirm
    .timerdond.noconfirm 1 $dond.time(confirmtime) dond.noconfirm %dond.player.temp %n
  }
  else {
    msg $dondchan 07Seems like the players are inactive.
    dond.end System Console Auto
  }
}

alias -l dond.noconfirm {
  msg $dondchan 10 $+ $1 did not confirm. Too bad, you lose your chance to play. We will pick another player...
  unset %dond.player.temp
  tokenize 58 $2
  dond.rpick $1 $2
}

alias dond.createboxes {
  unset %dond.boxwdamts
  var %amt = .1 1 5 10 25 50 75 100 200 300 400 500 750 1000 5000 10000 25000 50000 75000 100000 200000 300000 400000 500000 750000 1000000
  var %b = 26, %g
  while %b {
    %g = $gettok(%amt,$r(1,$numtok(%amt,32)),32)
    set %dond.boxwdamts $+(%b,:,%g) %dond.boxwdamts
    %amt = $remtok(%amt,%g,1,32)
    dec %b
  }
}

alias -l dond.getboxes {
  if ( %dond.boxwdamts ) {
    var %n = $numtok($v1,32), %o
    while %n {
      tokenize 58 $gettok(%dond.boxwdamts,%n,32)
      %o = 09,01 $+ $iif($1 isnum 1-9,$+(01,009,$1),$1) $+  %o
      dec %n
    }
    return %o
  }
}

alias -l dond.getamts {
  if ( %dond.boxwdamts ) {
    var %n = $numtok($v1,32), %o, %p , %o2
    while %n {
      tokenize 58 $gettok(%dond.boxwdamts,%n,32)
      %o = $2 %o
      dec %n
    }
    %o = $addtok(%o,$gettok(%dond.chosenbox,2,58),32)
    %o = $sorttok(%o,32,n)
    %p = $numtok(%o,32)
    while %p {
      %o2 = 08,01 $+ $comma($gettok(%o,%p,32)) $+  %o2
      dec %p
    }
    return %o2
  }
}

alias -l dond.bankerdeal {
  if ( %dond.boxwdamts ) {
    var %n = $numtok($v1,32), %o, %p = %n, %t = $1 * 2
    while %n {
      tokenize 58 $gettok(%dond.boxwdamts,%n,32)
      inc %o $2
      dec %n
    }
    ;inc %o $calc($gettok(%dond.chosenbox,2,58) * .25)
    inc %o $gettok(%dond.chosenbox,2,58)
    set %dond.bankerdeal $round($calc(%o / %p * %t / 10),2)
    return %dond.bankerdeal
    ; return $calc(%o / 10)
  }
}

alias -l dond.getboxnum return $wildtok(%dond.boxwdamts,$iif($1 isnum 1-9,$remove($1,0),$1) $+ :*,1,32)
Back to top Go down
http://lg-gaming.com
LGrobert
Elite Newbie
LGrobert


Male Number of posts : 40
Age : 37
Status : Founder
Points : 9
Registration date : 2008-09-30

Deal or Nodeal game Empty
PostSubject: Re: Deal or Nodeal game   Deal or Nodeal game Icon_minitimeFri Nov 28, 2008 1:27 pm

And this is part 2

Code:
alias -l dond.removebox {
  var %c = $dond.getboxnum($1)
  if ( !%dond.chosenbox ) set %dond.chosenbox %c
  set %dond.boxwdamts $remtok(%dond.boxwdamts,%c,1,32)
}

alias -l dond.casesperlevel {
  var %dond.cpl = 6 5 4 3 3 2 1
  set %dond.casesperlevel $gettok(%dond.cpl,%dond.level,32)
  return %dond.casesperlevel
}

alias -l dond.randomchoosebox {
  var %d = %dond.boxwdamts, %c = $iif(%dond.casesperlevel,$v1,1), %r, %o
  while %c {
    %r = $gettok(%d,$r(1,$numtok(%d,32)),32)
    %d = $remtok(%d,%r,1,32)
    %o = $addtok(%o,$gettok(%r,1,58),32)
    dec %c
  }
  echo -a ** %o
  dond.choose dond.random a a %o
}

alias -l dond.start {
  var %os = $dond.time(onstart)
  set %dond.status 1
  msg $dondchan It's time for another game of $dond.logo $+ ! For those who wants to play, type 03!join to join the game. $&
    The player will be randomly picked from those who joined. 4You have %os seconds to join.
  set -z %dond.start %os
  .timerdond.rpick 1 %os dond.rpick $1-
}

alias -l dond.end {
  if ( %dond.status ) {
    .timerdond.* off
    msg $dondchan $dond.logo 04has been $iif($3,$+($3,-)) $+ stopped by07 $iif($1,$1-2,System Console) $+ . Type03 !dond to start another game.
    unset %dond.*
    if ( $hget($_players) ) hfree $_players
  }
}

alias -l dond.choose {
  if ( %dond.level == 0 ) {
    if ( $4 isnum 1-26 ) {
      .timerdond.* off
      inc %dond.level
      var %cpl = $dond.casesperlevel
      msg $dondchan $iif(dond.random == $1,A Random box has been selected for you $+ :,You have chosen Box) 10 $+ $chr(35) $+ $4 
      dond.removebox $4
      msg $dondchan Here are the Boxes left: $dond.getboxes
      .timerdond.eliminate 1 2 msg $dondchan Now, you have to eliminate %cpl boxes. Type 3!choose $str($+(<number>,$chr(32)),%cpl) to eliminate the boxes. You have07 $dond.time(timelimit) secs to respond.
      .timerdond.timelimit 1 $calc($dond.time(timelimit) + 2) dond.timelimit $2 $3 %dond.player
    }
    else msg $dondchan %dond.player $+ : 12There are only 0426 12boxes.
  }
  elseif ( %dond.level isnum 1-7 ) {
    if ( $4 ) {
      if ( $timer(dond.timelimit) ) .timerdond.timelimit off
      var %d = $dond.casesperlevel, %net = $2, %ch = $3, %nn, %nb, %ae
      if ( !%dond.pickednum ) set %dond.pickednum 0
      if ( %dond.pickednum < %dond.casesperlevel ) {
        var %w = 1, %n, %f = $4-, %eb
        while ( %dond.pickednum < %dond.casesperlevel ) && $gettok(%f,%w,32) {
          %n = $v1
          if ( $dond.getboxnum(%n) ) {
            tokenize 58 $v1
            %eb = $addtok(%eb,12 $+ $chr(35) $+ $1 10 $+ $comma($2) $+ ,44)
            dond.removebox %n
            inc %dond.pickednum
          }
          elseif ( %n !isnum ) %nn = $addtok(%nn,12 $+ %n $+ ,44)
          elseif ( %n == $gettok(%dond.chosenbox,1,58) ) msg $dondchan Box12 $chr(35) $+ %n is already your chosen box.
          elseif ( %n !isnum 1-26 ) %nb = $addtok(%nb,12 $+ %n $+ ,44)
          else %ae = $addtok(%ae,12 $+ %n $+ ,44)
          inc %w
        }
        if ( %nn ) msg $dondchan %nn $iif($numtok(%nn,44) > 1,are,is) not a number.
        if ( %nb ) msg $dondchan There $iif($numtok(%nb,44) > 1,are,is) no Box $chr(35) $+ $iif($numtok(%nb,44) > 1,s) %nb
        if ( %ae ) msg $dondchan You have already eliminated Box $chr(35) $+ $iif($numtok(%ae,44) > 1,s) %ae
        if ( %eb ) msg $dondchan You have eliminated07 %dond.pickednum of12 %dond.casesperlevel Boxe(s): %eb
        if ( %dond.pickednum < %dond.casesperlevel ) {
          .timerdond.pickednum 1 3 msg $dondchan 04 $+ $calc(%dond.casesperlevel - %dond.pickednum) more to eliminate.
          .timerdond.timelimit 1 $calc($dond.time(timelimit) + 3) dond.timelimit %net %ch %dond.player
        }
        else {
          .timerdond.getboxes1 1 1 msg $dondchan Here's the rest of the boxes: $!dond.getboxes
          .timerdond.getamts1 1 2 msg $dondchan Here's the remaining amounts: $!dond.getamts
          .timerbanker1 1 5 msg $dondchan 04! B A N K E R !       
          .timerbanker2 1 6 msg $dondchan The Banker's offer is:10 $comma($dond.bankerdeal(2))
          .timerdond.msg.dond 1 7 $({, ) msg $dondchan To accept the offer, type 12!deal. If you don't accept, type 04!nodeal. You have07 $dond.time(autoaccept) secs to respond. $(|, ) set % $+ dond.answerdond 1 $(}, )
          .timerdond.autoaccept 1 $calc($dond.time(autoaccept) + 7) dond.autoacceptoffer %net %ch %dond.player
        }
      }
      else msg $dondchan You have already eliminated %dond.casesperlevel boxes at this time.
    }
    else msg $dondchan Choose %dond.casesperlevel boxes to elimnate from the remaining ones. Type 3!choose $str($+(<number>,$chr(32)),%dond.casesperlevel) $+ .
  }
  elseif ( %dond.level == 8 ) {
    if ( $istok($gettok(%dond.boxwdamts,1,58) $gettok(%dond.chosenbox,1,58),$4,32) ) {
      if ( $timer(dond.timelimit) ) .timerdond.timelimit off
      var %n = $2
      tokenize 58 $iif($4 $+ :* iswm %dond.boxwdamts,$v2,%dond.chosenbox)
      hinc -m $_table $+(%n,:,$dondchan,:,%dond.player) $2
      msg $dondchan Your chose Box12 $chr(35) $+ $1 with10 $comma($2) and will be added to your total points, which is now03 $comma($hget($_table,$+(%n,:,$dondchan,:,%dond.player))) $+ . Thank you for Playing.
      if ( $me isop $dondchan ) mode $dondchan -v %dond.player     
      unset %dond.player
      .timerdond.rpick 1 2 dond.rpick %n $dondchan new
    }
    else msg $dondchan 10 $+ $4 $+  is neither of your chosen box 09,01 $+ $gettok(%dond.chosenbox,1,58) $+  nor the box left 09,01 $+ $gettok(%dond.boxwdamts,1,58) $+ . You have04 $timer(dond.timelimit).secs secs left to respond.
  }
}

alias -l comma {
  ;By Fiberoptics
  var %a, %b = $regsub($ticks,$1,/\G([+-]?\d+?)(?=(?:\d{3})++(?=\.\d++$|$))/g,\1 $+ $chr(44),%a)
  return %a
}

alias -l dond.save {
  hsave -o $_table $_data
  hsave -o $_players $_playdata
}

alias -l dond.players {
  var %n = $hfind($_players,$+($1,:,$2,:*),0,w)
  if ( $prop == rand ) return $hfind($_players,$+($1,:,$2,:*),$r(1,%n),w)
  return %n
}

alias -l dond.timelimit {
  unset %dond.player
  msg $dondchan  $+ $3 12seems to be inactive. We will now select a new player...
  if ( $me isop $dondchan ) mode $v2 -v $3
  .timerdond.rpick 1 2 dond.rpick $1 $2
}

alias -l dond.autoacceptoffer {
  hinc -m $_table $+($1,:,$2,:,$3) %dond.bankerdeal
  msg $dondchan 12The Banker's offer has been auto-accepted.10 $comma(%dond.bankerdeal) 12will be added to your points. Your new total points:03 $comma($hget($_table,$+($1,:,$2,:,$3))) 
  dond.timelimit $1-
}

alias -l dond.time return $readini($_ini,config,$1)

alias -l dond.settings {
  if ( !$readini($_ini,config,avplayer) ) wini config avplayer 1
  if ( !$readini($_ini,config,onstart) ) wini config onstart 30
  if ( !$readini($_ini,config,timelimit) ) wini config timelimit 45
  if ( !$readini($_ini,config,randomchoosebox) ) wini config randomchoosebox 45
  if ( !$readini($_ini,config,autoaccept) ) wini config autoaccept 45
  if ( $1 ) echo $colour(info) -a ** $dond.logo v $+ $dond.version - Default Settings has been set.
}

alias -l dond.setchan {
  writeini -n $_ini config channel $1
  unset %dond.*
}

alias -l wini writeini -n $_ini $1-

alias -l dond.top {
  var %h = $hfind(dond.scores,$+($1,:,$2,:*),0,w), %w = @dond.top, %i
  window -hn %w
  clear %w
  while %h {
    %i = $hfind(dond.scores,$+($1,:,$2,:*),%h,w)
    aline %w $gettok(%i,3,58) $hget(dond.scores,%i)
    dec %h
  }
  filter -cteuww 2 32 %w %w
  var %l = $line(%w,0), %a = 1, %o
  while %a <= 10 {
    %o = $addtok(%o,$+(08,$chr(44),01) $+ $chr(35) $+ %a $+ $+(01,$chr(44),15) $iif($line(%w,%a),$gettok($v1,1,32) $comma($gettok($v1,2,32)),*),32)
    inc %a
  }
  msg $2 $dond.logo TOP10: %o
}

;############ MENU #############

menu * {
  DOND v $+ $dond.version
  .$style(1) $iif($readini($_ini,config,enable),Enabled,Disabled)
  ..$iif($readini($_ini,config,enable),Disable,Enable) game: {
    wini config enable $iif($readini($_ini,config,enable),0,1)
    if ( !$readini($_ini,config,enable) ) && ( %dond.status ) dond.end System Console
  }
  .-
  .$iif( $readini($_ini,config,enable), Status)
  ..$iif( !%dond.status, Start, Stop) DoND:  {
    if ( $me ison $dondchan ) $iif( !%dond.status , dond.start $network $dondchan, dond.end System Console)
    else echo 04 -a $dond.logo Error: I am not on $dondchan $+ .
  }
  .-
  .Settings
  ..Channel ( $+ $dondchan $+ )
  ...$iif(( $chan ) && ( $chan != $dondchan ),Set Current $chr(40) $+ $chan $+ $chr(41)) : dond.setchan $chan
  ...Set Other? : dond.setchan #$$?="Enter the Channel name to play DEAL or NODEAL"
  ..-
  ..$iif($readini($_ini,config,avplayer),$style(1)) Auto voice Player
  ...$iif( !$readini($_ini,config,avplayer), Enable, Disable) :  wini config avplayer $iif($readini($_ini,config,avplayer),0,1)
  ..-
  ..Time
  ...On Start ( $+ $readini($_ini,config,onstart) $+ ) : wini config onstart $$?="Enter time when starting the game (seconds)"
  ...Time to Confirm ( $+ $readini($_ini,config,confirmtime) $+ ) : wini config confirmtime $$?="Enter time for user to confirm before starting the game (seconds)"
  ...Time Limit ( $+ $readini($_ini,config,timelimit) $+ ) : wini config timelimit $$?="Enter time limit for user to respond (seconds)"
  ...Random 1st box ( $+ $readini($_ini,config,randomchoosebox) $+ ) : wini config randomchoosebox $$?="Enter time limit when choosing the 1st box randomly (seconds)"
  ...Auto Accept Offer ( $+ $readini($_ini,config,autoaccept) $+ ) : wini config autoaccept $$?="Enter time limit for user to respond before offer is auto-accepted (seconds)"
  ..-
  ..Scores
  ...Save {
    var %w =  $input(Do you really want to set the default settings?,uy,Deal or No Deal)
    if ( $! ) {
      hsave -o $_table $_data
      echo $colour(info) -a $dond.logo v $+ $dond.version - Scores has been saved!
    }
  }
  ...Reset {
    var %w =  $input(Do you really want to reset All the scores?,uy,Deal or No Deal - Confirm Reset)
    if ( $! ) {
      hfree $_table
      hmake $_table 10
    }
  }
  ..-
  ..Reset : {
    var %w =  $input(Do you really want to set the default settings?,uy,Deal or No Deal - Confirm Reset)
    if ( $! ) {
      dond.settings 1
    }
  }
}
Back to top Go down
http://lg-gaming.com
 
Deal or Nodeal game
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
LG-Gaming Marathon :: Server :: Scripts-
Jump to: