All pastes #122963 Raw Edit

Unnamed

public text v1 · immutable
·published 2006-08-09 00:47 UTC
rendered paste body
/*
hash format (bj):
			start		1/null
			stage		1(bets)/2(cards)/3(finale)/null
			nick		1/null
			bet_nick		num
			players		n0 n1 n2
hash table is not meant to be permanent
*/
on *:text:!sit:#nudalz:{
  if ($hget(bj,$nick)) { msg # You already joined. }
  elseif ($hget(bj,start)) { msg # You cannot join a hand in-progress. }
  else {
    hadd -m bj $nick 1
    hadd -m bj players $hget(bj,players) $nick
    if (!$readini(n_blackjack.ini,db,$nick)) {
      var %money = 500
      writeini n_blackjack.ini db $nick %money
      msg # New player! $+(,$nick,) was granted $+($chr(36),%money)
    }
    msg # $+(,$nick,) joined the game. (players: $numtok($hget(bj,players),32) $+ )
  }
}
on *:text:!stand:#nudalz:{
  if (!$hget(bj,$nick)) { msg # You have not joined. }
  elseif ($hget(bj,start)) { msg # You cannot leave a hand in-progress. Loser. }
  else {
    hadd -m bj players $deltok($hget(bj,players),$findtok($hget(bj,players),$nick,32),32)
    hdel bj $nick
    msg # $+(,$nick,) left the game. (players: $numtok($hget(bj,players),32) $+ )
  }
}
on *:text:!deal:#nudalz:{
  if (!$hget(bj,$nick)) { msg # You have not joined. }
  elseif ($hget(bj,start)) { msg # Hand is in-progress. }
  else {
    hadd -m bj start 1
    hadd -m bj stage 1
    .timerbets 2 30 msg # Waiting on unbolded names to place their bets: $hget(bj,players)
    if ($numtok($hget(bj,players),32) == 1) {
      msg # Starting blackjack with just $+(,$nick,) and dealer.
    }
    if ($numtok($hget(bj,players),32) >= 2) {
      msg # Starting blackjack with $+(,$numtok($hget(bj,players),32),) players.
    }
    ;have it remove slowpokes after 75seconds
  }
}
on *:text:!bet*:#nudalz:{
  if (!$hget(bj,$nick)) { msg # You are not in this hand. }
  elseif (!$hget(bj,start)) { msg # No cards have been dealt yet. }
  elseif ($regex($hget(bj,stage),^2|3$)) { msg # Bets have already been placed. }
  elseif (!$2) { msg # Use: !bet <amount> }
  elseif ($2 > $readini(n_blackjack.ini,db,$nick)) { msg # $+(,$nick,) you can only place a bet up to $+($v2,.) }
  else {
    hadd -m bj $+(bet_,$nick) $2
    hadd -m bj players $replace($hget(bj,players),$nick,$+(,$nick,))
    notice $nick You bet $+(,$chr(36),$2,,.) Remaining: $+($chr(36),$calc($readini(n_blackjack.ini,db,$nick) - $2))
  }
}
on *:text:!money*:#nudalz:{
  if (!$2) {
    if (!$readini(n_blackjack.ini,db,$nick)) { msg # $+(,$nick,) is bankrupt. }
    else {
      msg # $+(,$nick,) you have $+($chr(36),$readini(n_blackjack.ini,db,$nick),.)
    }
  }
  else {
    if (!$readini(n_blackjack.ini,db,$2)) { msg # $+(,$2,) is bankrupt. }
    else {
      msg # $+(,$2,) has $+($chr(36),$readini(n_blackjack.ini,db,$2),.)
    }
  }
}