mIRC Home    About    Download    Register    News    Help

Print Thread
#134090 28/10/05 04:46 PM
Joined: Oct 2005
Posts: 71
D
D00M Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Oct 2005
Posts: 71
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 confused

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 &lt; 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)) &gt; $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 &gt; $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)) &gt; $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 &lt;= $numtok(%bootplayer,32)) { 
    stand $gettok(%bootplayer,%i,32) 
    inc %i 
  } 
  unset %bootplayer 
} 
alias -l dealerplay { while ($cardtotal(d) &lt; 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) &gt; $cardtotal($1)) { psay $msg.end.dealer($1) | bet.loses $1 } 
  else if ($cardtotal(d) &lt; $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 &gt; 21) { 
    if (%soft &lt;= 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 &lt;Amount&gt; 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 &lt;= 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) &gt;= %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 &gt; 52) || ($1 &lt; 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 &gt; 52) || ($1 &lt; 1)) { return } 
  return $calc($1 - ($int($calc($1 / 13)) * 13) + 2) 
} 
alias -l convert.suitnum { 
  if (($1 &gt; 52) || ($1 &lt; 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 &gt;= 10000) { break } 
    } 
  } 
} 

#134091 28/10/05 05:33 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
That's blackjack?! Sheesh... Blackjack is a simple enough game that it could easily be done in half that. Heh.

One thing...

if ($1 isin !BlackJack!version!leave!deal!bet!ImIn!hitme!stay!double) {

That's a really bad idea... if you type any single letter that is in there, it will trigger. For example, if you said: "Jack is a funny name.", it would trigger because "Jack" isin that set of commands.

As for why it repeats, that's the reason. "i" and "it" and "im" are all in that line of commands.

Try replacing it with:
if ($istok(!BlackJack !version !leave !deal !bet !ImIn !hitme !stay !double,$1,32) {

That should do fix your problem.

For the delay, I will leave it for someone else... I don't want to start figuring out such a long script right now.


Invision Support
#Invision on irc.irchighway.net
#134092 28/10/05 07:42 PM
Joined: Oct 2005
Posts: 71
D
D00M Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Oct 2005
Posts: 71
hey Riamus2,thanx for the reply,yeah i thought it might not have to be so big but as i said i no nothing about this so i thought here would be a good place to ask,i tried the line of code you said,it has stopped it from double typing but instead of the second line being typed i now i get an error,

<@D00M> i
* /if: invalid format (line 2, BlackJack.mrc)
<@D00M> it
* /if: invalid format (line 2, BlackJack.mrc)
<@D00M> it
* /if: invalid format (line 2, BlackJack.mrc)
<@D00M> it

any help would be great with the timer prob as its a bugger for flooding,if any one has any advice on making this smaller/cleaner and can help with the timer prob i would be 4ever greatfull,TIA wink

#134093 28/10/05 07:44 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Sorry... typo -- I missed a ).

if ($istok(!BlackJack !version !leave !deal !bet !ImIn !hitme !stay !double,$1,32)) {

That will fix it for you. Is this something you wrote up, then?

I made up a nice single-deck card hash table that stores cards with color that can then be output to the channel. In other words, a 5 of Hearts will appear in the channel as 5H and will have a white background and red lettering, making it as close to a real card as can fit in a line of text on IRC. The use of the hash table makes it very easy to "shuffle" the deck and prevent cards from being used multiple time, as well as it makes it very easy to deal with suits.

If you wrote this and want to improve it, you might look into that possibility. If you didn't write this, then I wouldn't bother trying to convert it.

Last edited by Riamus2; 28/10/05 07:49 PM.

Invision Support
#Invision on irc.irchighway.net
#134094 28/10/05 08:07 PM
Joined: Oct 2005
Posts: 71
D
D00M Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Oct 2005
Posts: 71
ah nice 1 that fixed the double tying,thanx a mill for the quick
reply.As for writing this myself,no i wish i new how to write
or even understand this stuff,very basic is all i no atm.This
was just something i came across when surfing for some
games for irc that others could join in on,i havent have a clue
really what im doing as to write stuff myself but i seem to be
able to sometimes stumble my way through editing up other
peoples work(just the txt that gets msg'd to people etc,very basic stuff is all i no),i luv the idea you did with the colour of the cards but wouldnt no where to start to add it to this.Is there a better black jack script you can suggest? or should i just stick with trying to add a timer to the responces?. Thanx
again for the tip and look forward to any and all replys, cool

D00M

#134095 28/10/05 08:23 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
I've never used one, but there may be good ones at http://www.mircscripts.org. I have no idea.

Right now, I'm working on 2 games, myself (and a third that has been on hold for over a year)...

  • Scattergories (2 players maximum with GUI/Dialog interface and in-game chat)
  • Cribbage (2 players maximum with a text-only interface... this is where the card table I mentioned is being used)
  • Monopoly (4 players per game, 3 games maximum at any given time. Old Games Themed -- spaces are old computer/console games. Fully GUI.) <= This is the one that is on hold for so long. It is mostly done other than making the buy/sell/rent/houses/hotels/cards work. Tedious things that I don't feel like working with. The board and everything is done and all the multiplayer coding is done. Maybe, someday, I'll start up on it again and get it finished.


I've also put some work into a Dungeon Crawl style RPG that is fully customizable by users -- they can easily add in new races (player and AI) and new weapons and spells and armor and such. It actually works well for what I've done so far. I just got tired of working on all the code of how attacking works and defending and all that stuff. Trying to figure out exactly how armor prevents damage is a pain. So, that's pretty much not planned to ever finish, though I may add more over time and eventually complete it. The nice thing is that I already have over 300,000 items that can be found in the game. And that is without users adding their own content. laugh

Eventually, I'll release a game. So far, I've only released addons to Invision, my $DateXpander script, a dictionary script and a weather script. It's just a matter of getting myself to complete the coding.... I tend to set things aside and go play a game or work on my translation of DragonBall Z: Super Gokuden for SNES instead. smile


Invision Support
#Invision on irc.irchighway.net
#134096 28/10/05 08:46 PM
Joined: Oct 2005
Posts: 71
D
D00M Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Oct 2005
Posts: 71
shocked wow i didnt no half that stuff was possible to even do with irc,i luv the ideas you have and hope you dont give up mate,they sounds great and i think many would think so also.
That Monopoly games sounds killer but it must be a huge job to pull it all together.I wouldnt want to be in your shoes lol.
Thanx again for the help Riamus2 i will have a look at the site you said and keep looking.
im not looking for anything as advanced as yours just some basic games i could run with invision so others can pass the time some what,there has to be some good games out there done well,failure is not an option laugh

#134097 28/10/05 08:54 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Well, Scattergories and Cribbage aren't all that advanced. smile

A friend of mine on the Invision channel listed in my signature has UNO for the channel there. If you ask smiley in there about it, he could probably tell you what script it is and where to get it. It's a fun game in the channel.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard