Help with Black Jack - 28/10/05 04:46 PM
hi all,i was wondering if anybody could help me with this script,
i have no idea what im doing as iv never really played with irc scripts before only a little toying with xbox,
nothing like this.I have 2 probs i need to nut out,they are
1. it needs to have some sort of timer on the responce msg to the chan because the way it is now it floods the chan if there
is a few people playing as the responce is to quick...
(e.g player a types !BlackJack and instead of msg'ing the chan straight away,
maybe have a timer for each line it says as its just way to quick atm).
2. when i type certain words/letters it makes my invision double type
(types the same msg twice)this is just when the blackjack
script is loaded and sitting in the background or when its playing
(e.g.
[10:20pm] <@D00M> i need to make it have a timer for the responce
[10:20pm] <@D00M> i need to make it have a timer for the responce
[10:21pm] <@D00M> what the heck?
[10:21pm] <@D00M> i
[10:21pm] <@D00M> i
[10:21pm] <@D00M> its
[10:21pm] <@D00M> it
[10:21pm] <@D00M> it
[10:21pm] <@D00M> im
[10:21pm] <@D00M> im
[10:21pm] <@D00M> iq
[10:21pm] <@D00M> odd
ok as you can see only sometimes does it do it and its only
when i have this script loaded,can someone please have a
look and the script below and tell me if there is any probs
with it or maybe if it can be writing better/cleaner/smaller
(i have no idea just asking)and is it possible to add a timer so
it doesnt flood the chan with the responces,TIA
i have no idea what im doing as iv never really played with irc scripts before only a little toying with xbox,
nothing like this.I have 2 probs i need to nut out,they are
1. it needs to have some sort of timer on the responce msg to the chan because the way it is now it floods the chan if there
is a few people playing as the responce is to quick...
(e.g player a types !BlackJack and instead of msg'ing the chan straight away,
maybe have a timer for each line it says as its just way to quick atm).
2. when i type certain words/letters it makes my invision double type
(types the same msg twice)this is just when the blackjack
script is loaded and sitting in the background or when its playing
(e.g.
[10:20pm] <@D00M> i need to make it have a timer for the responce
[10:20pm] <@D00M> i need to make it have a timer for the responce
[10:21pm] <@D00M> what the heck?
[10:21pm] <@D00M> i
[10:21pm] <@D00M> i
[10:21pm] <@D00M> its
[10:21pm] <@D00M> it
[10:21pm] <@D00M> it
[10:21pm] <@D00M> im
[10:21pm] <@D00M> im
[10:21pm] <@D00M> iq
[10:21pm] <@D00M> odd
ok as you can see only sometimes does it do it and its only
when i have this script loaded,can someone please have a
look and the script below and tell me if there is any probs
with it or maybe if it can be writing better/cleaner/smaller
(i have no idea just asking)and is it possible to add a timer so
it doesnt flood the chan with the responces,TIA
Code:
on *:INPUT:*:{ if ($1 isin !BlackJack!version!leave!deal!bet!ImIn!hitme!stay!double) { msg $chan $1- if ($chan isin %pokerchan) pokercommand $1- haltdef } } on *:TEXT:*:*:{ if ($chan isin %pokerchan) pokercommand $1- } alias blackjack.name { return Blackjack } alias blackjack.version { return 1.1 } alias blackjack.author { return Tat } menu menubar { $blackjack.name $+ : .Set Channel: if ($chan) %pokerchan = %pokerchan $chan .Remove Channel: if ($chan) %pokerchan = $remove(%pokerchan,$chan) } alias -l pokercommand { if ($1 == !BlackJack) psay $msg.blackjack.help if ($1 == !version) psay $msg.blackjack.version if (!$pvar(d,1)) { if ($1 == !leave) stand $nick if ($1 == !deal) deal $nick if ($1 == !bet) bet $nick $2 if ($1 == !ImIn) sit $nick } if ($1 == !hitme) { hit } if ($1 == !stay) { if (!$islive) { psay $msg.error.waitturn | return } stay } if ($1 == !double) { double } } ;blackjack alias alias -l sit { if ($isplayer($1)) { psay $msg.error.alreadyseated | return } if (($players < 6)) { pset player $calc($players + 1) $1 if (!$pvar(money, $1)) { pset Money $1 10000 } if (!$pvar(Bet, $1)) { pset Bet $1 10 } psay $msg.card.satdown } } alias -l stand { if (!$isplayer($1)) { psay $msg.error.notseated | return } var %temp = $playernum($1) pdel player %temp while ($getplayer($calc(%temp + 1)) != $null) { pset Player %temp $getplayer($calc(%temp + 1)) inc %temp } pdel player %temp psay $msg.card.stoodup($1) } alias -l make.bet.wager { pset Wager $getplayer($1) $iif($pvar(Bet, $getplayer($1)) > $pvar(Money, $getplayer($1)), $pvar(Money, $getplayer($1))), $pvar(Bet, $getplayer($1))) } alias -l deal { if (!$isplayer($1)) { psay $msg.error.notseated | return } $foreach(getplayer as guy, make.bet.wager guy) getdeck bj pset player d Dealer %player = 1 $foreach(getplayer as guy,setcard bj guy 1) setcard bj d 1 $foreach(getplayer as guy,setcard bj guy 2) setcard bj d 2 $foreach(getplayer as i, psay $ $+ msg.cards.dealt(i)) psay $msg.card.dealershow if ($checkbj(d)) { psay $msg.card.dbj allstay return } action.on %player } alias -l bet { if (!$isplayer($1)) { psay $msg.error.notseated | return } pset Bet $nick $abs($calc($2)) psay $msg.card.wager } alias -l action.on { .timeraction 1 180 timedout.player %player if (%player > $players) { allstay | return } psay $msg.card.current(%player) if ($checkbj(%player)) { stay } } alias timedout.player { psay $msg.error.timedout set %bootplayer %bootplayer $getplayer(%player) stay } alias -l stay { psay $msg.card.stayed inc %player action.on %player } alias -l hit { if (!$islive) { psay $msg.error.waitturn | return } do.hit %player if ($cardtotal(%player) == busted) { stay } } alias -l do.hit { setcard bj $1 $lastcard($1) psay $msg.card.dealt($1, $calc($lastcard($1) - 1))) } alias -l double { if (!$islive) { psay $msg.error.waitturn | return } if ($calc($lastcard( $playernum($nick) ) - 1) != 2) { psay $msg.error.nolongerdouble | return } if ($int($calc($pvar( Wager, $nick) * 2)) > $pvar(Money, $nick)) { psay $msg.error.ifunds return } pset wager $nick $int($calc($pvar(Wager, $nick) * 2)) hit %player stay } alias -l islive { if ($nick == $getplayer(%player)) { return $true } } alias -l checkbj { if ($calc($bjconvert($pvar($1,1)) + $bjconvert($pvar($1,2))) == 21) return $true } alias -l allstay { .timeraction off psay $msg.card.current(d) dealerplay $foreach(getplayer as guy, checkwin guy) delcards trashdeck bj unset %player var %i = 1 while (%i <= $numtok(%bootplayer,32)) { stand $gettok(%bootplayer,%i,32) inc %i } unset %bootplayer } alias -l dealerplay { while ($cardtotal(d) < 17) { do.hit d } } alias -l bet.loses { pset Money $getplayer($1) $calc($pvar(Money, $getplayer($1)) - $pvar(Wager, $getplayer($1))) } alias -l bet.wins { pset Money $getplayer($1) $calc($pvar( Money, $getplayer($1)) + $pvar(Wager, $getplayer($1))) } alias -l bet.bwins { pset Money $getplayer($1) $calc($pvar( Money, $getplayer($1)) + ($pvar(Wager, $getplayer($1)) * 1.5) ) } alias -l checkwin { if ($checkbj(d)) { psay $msg.end.dbj($1) | bet.loses $1 } else if ($checkbj($1)) { psay $msg.end.bj($1) | bet.bwins $1 } else if ($cardtotal($1) == Busted) { psay $msg.end.busted($1) | bet.loses $1 } else if ($cardtotal(d) == Busted) { psay $msg.end.dbusted($1) | bet.wins $1 } else if ($cardtotal(d) > $cardtotal($1)) { psay $msg.end.dealer($1) | bet.loses $1 } else if ($cardtotal(d) < $cardtotal($1)) { psay $msg.end.player($1) | bet.wins $1 } else if ($cardtotal(d) == $cardtotal($1)) { psay $msg.end.push($1) } psay $msg.card.money($1) } alias -l cardtotal { var %i = 1, %soft = 0, %temp = 0 while ($pvar($1,%i) != $null) { var %temp = $calc(%temp + $bjconvert($pvar($1,%i))) if ($bjconvert($pvar($1,%i)) == 11) { inc %soft } inc %i } while (%temp > 21) { if (%soft <= 0) { return Busted } else { %temp = $calc(%temp - 10) } dec %soft } return %temp } alias -l delcards { $foreach(getplayer as guy, pdel guy) pdel d } alias -l msg.error.alreadyseated { return 12 $+ $nick Is already seated,are you drunk?. } alias -l msg.error.notseated { return 12 $+ $nick Is not seated, type !ImIn to join. } alias -l msg.error.ifunds { return 12 $+ $nick Is a broke-Ass mofo and lacks the funds to double. } alias -l msg.error.timedout { return 04 $+ Player has timed out,we cant wait all day. } alias -l msg.error.waitturn { return 04 $+ Patience my young Padawan one,your turn draws near. } alias -l msg.error.nolongerdouble { return 04 $+ You can no longer double. } alias -l msg.card.wager { return 12 $+ $nick has set a standard wager of $pvar(Bet, $nick) $+ . } alias -l msg.card.dbj { return 04 $+ Dealer has blackjack. Everybody loses HaHaHaHaH!. } alias -l msg.card.satdown { return 12 $+ $nick Sat down to play in seat $players $+ . $nick has $pvar( Money, $nick) chips. } alias -l msg.card.stoodup { return 12 $+ $1 Has left the building. } alias -l msg.card.dealt { return 03 $+ $getplayer($1) was given $convert.card($pvar($1,$2)) $+ . $msg.card.total($1) $+ ! } alias -l msg.cards.dealt { return 03 $+ $getplayer($1) was given $convert.card($pvar($1,1)) and $convert.card($pvar($1,2))$+ . $msg.card.total($1) $+ ! } alias -l msg.card.dealershow { return 04 $+ $getplayer(d) is showing a $convert.card($pvar(d,2)) it is currently $getplayer(%player) $+ 's turn. 12!hitme !leave !stay or !double } alias -l msg.card.current { return 04 $+ $getplayer($1) has a $convert.card($pvar($1,1)) and a $convert.card($pvar($1,2)) $msg.card.total($1) $+ . } alias -l msg.card.stayed { return 12 $+ $getplayer(%player) stayed. } alias -l msg.card.actionon { return 12 $+ It is now $getplayer(%player) $+ 's turn. } alias -l msg.card.total { return 03 $+ Current Total: $cardtotal($1) } alias -l msg.card.money { return 12 $+ $getplayer($1) now has $pvar(Money, $getplayer($1)) $+ . } alias -l msg.end.busted { return 03 $+ $getplayer($1) busted and looses. } alias -l msg.end.dbusted { return 03 $+ $getplayer(d) busted, $getplayer($1) wins. } alias -l msg.end.dealer { return 03 $+ $getplayer(d) $+ 's $cardtotal(d) beats $getplayer($1) hand $cardtotal($1) $+ . } alias -l msg.end.player { return 03 $+ $getplayer(d) $+ 's $cardtotal(d) loses to $getplayer($1) hand $cardtotal($1) $+ . } alias -l msg.end.push { return 03 $+ $getplayer(d) $+ 's $cardtotal(d) is a push with $getplayer($1) hand $cardtotal($1) $+ . } alias -l msg.end.dbj { return 07 $+ $getplayer(d) has BlackJack, $getplayer($1) loses. } alias -l msg.end.bj { return 07 $+ $getplayer($1) has BlackJack and Wins. } alias -l msg.blackjack.help { return 03 $+ Please ues the following cmds to play BlackJack 12 $+ !ImIn 03 $+ to join a game and take a seat, 12 $+ !leave 03 $+ to stand up and leave the game, 12 $+ !bet <Amount> 03 $+ is to place a bet , 12 $+ !deal $+ 03 to deal the cards and begin the game. } alias -l msg.blackjack.version { return 12 $+ $blackjack.name v. $blackjack.version by $blackjack.author } ;deck standards alias -l getcard { if (!$hget($1)) { return } var %temp = $hget($1,$cardsleft($1)) hdel $1 $cardsleft($1) return %temp } alias -l getdeck { trashdeck $1 hmake $1 var %c = 1 while (%c <= 52) { hadd $1 %c %c inc %c } shuffledeck $1 } alias -l trashdeck { if ($hget($1)) hfree $1 } alias -l isdeck { if ($hget($1)) return $true } alias -l shuffledeck { var %i = 1 while ($cardsleft($1) >= %i) { var %temp = $rand(1,$cardsleft($1)) var %temp.card = $hget($1,%temp) hadd $1 %temp $hget($1,%i) hadd $1 %i %temp.card inc %i } } alias -l cardsleft { return $$hget($1,0).item } ;card standards alias -l convert.card { return $convert.rank($1) of $convert.suit($1) } alias -l convert.rank { if (($1 > 52) || ($1 < 1)) { return } return $convert.face($convert.ranknum($1)) } alias -l convert.face { if ($1 isnum 11-14) { return $gettok(Jack.Queen.King.Ace, $calc($1 - 10), $asc(.)) } return $1 } alias -l convert.ranknum { if (($1 > 52) || ($1 < 1)) { return } return $calc($1 - ($int($calc($1 / 13)) * 13) + 2) } alias -l convert.suitnum { if (($1 > 52) || ($1 < 1)) { return } return $int($calc( ($1 - 1) / 13 ) ) } alias -l convert.suit { return $gettok(Clubs.Diamonds.Hearts.Spades, $calc($convert.suitnum($1) + 1), $asc(.)) } alias -l bjconvert { var %temp = $convert.rank($1) if (%temp isnum) { return %temp } if (%temp == Ace) { return 11 } if ((%temp == King) || (%temp == Queen) || (%temp == Jack)) { return 10 } } ;interact standards alias -l pvar { return $readini(cards.ini, $1, $2) } alias -l pset { writeini cards.ini $1 $2 $3- } alias -l pdel { remini cards.ini $1- } alias -l psay { msg $chan $1- } alias -l pnotice { if ($nick != $me) { .notice $nick $1- } else { echo $chan $1- } } alias -l setcard { pset $2 $3 $getcard($1) } alias -l lastcard { var %i = 1 while ($pvar($1,%i) != $null) { inc %i } return %i } ;player standards alias -l players { var %i = 1 while ($getplayer(%i) != $null) { inc %i } return $calc(%i - 1) } alias -l getplayer { return $pvar(player, $1) } alias -l isplayer { if ($playernum($1)) return $true } alias -l playernum { var %i = 1 while ($getplayer(%i) != $null) { if ($1 == $getplayer(%i)) { return %i } inc %i } } ;Brilliant crud alias foreach { if ($regex($1,/^(\S+)\sas\s(\S+)$/)) { var %temp.var 1, %array $regml(1), %key $regml(2) while ($eval( $ $+ %array $+ ( $+ %temp.var $+ ) ,2)) { $eval($replace($2,%key,%temp.var),2) inc %temp.var if (%temp.var >= 10000) { break } } } }