This is a simple blackjack game that that i've been working on. this simple version lacks
many of the features of a real blackjack game, but heck. it does work. it is designed to
be easy for the player to win against (to be honest i barely know of a way to make it
harder )
in this version, the cards are randomly decided at the start, the script will automatically
check and change a player's Aces from a value of 11 to a value of 1 to prevent them
from going over 21. it doesn't for the dealer, thus making it slightly easier for the player.
the script is operated by 3 & commands, uses 3 script slots (can have upto 64
scripts on a world), and uses 14 player variables. variables 1 threw 5 are the players
cards, 6 is the players current deck total, 7 is the number of cards the player currently
has. 10 threw 17 are the same as 1 threw 7, except there for the dealer, and except
for variable 15 which is the money given to the player for winning the game. This game
also checks to make sure a player doesn't already have a game in progress before
letting them start a new one. if they do already have a game started, they will continue
playing it. theoretically, this would allow people to crash and resume there game or put
it on hold if needed.
I am in the process of making a more complex version that does do the ace check for
the dealer, it will be 5 to 10 times longer. also am setting it up so it records the number
of global wins and losses, along with players personal wins/losses. it will also possibly
allow players to type in how much they want to bet on the game.
Code: Select all
Event( "&command", "Blackjack" )
{
*msg %player% Welcome to Blackjack!
*msg %player% Please read the Blackjack guide for info on how to play.
*grantitem %player% 1 Blackjack Guide
if ( $PlayerVar[1] = 0)
{
$PlayerVar[1] = rand(10) + 1
$PlayerVar[2] = rand(10) + 1
$PlayerVar[3] = rand(10) + 1
$PlayerVar[4] = rand(10) + 1
$PlayerVar[5] = rand(10) + 1
$PlayerVar[6] = $PlayerVar[1] + $PlayerVar[2]
$PlayerVar[7] = 2
$PlayerVar[10] = rand(10) + 1
$PlayerVar[11] = rand(10) + 1
$PlayerVar[12] = rand(10) + 1
$PlayerVar[13] = rand(10) + 1
$PlayerVar[14] = rand(10) + 1
$playervar[15] = 200
$playervar[16] = $playervar[10] + $playervar[11]
$PlayerVar[17] = 2
*msg %player% Your cards are $PlayerVar[1] and $PlayerVar[2]
*msg %player% One of the dealers cards is a $PlayerVar[10]
if ($PlayerVar[6] = 21)
{
*msg %player% Congratulations! you have 21! You should Stand.
}
else
{
*msg %player% Your total card value is $PlayerVar[6]
*msg %player% Would you like to Hit or Stand?
}
}
else
{
*msg %player% You already have a blackjack game in progress.
*msg %player% Your total card value is $PlayerVar[6]
*msg %player% Would you like to Hit or Stand?
}
}
Event( "&command", "Hit" )
{
if ($PlayerVar[7] = 2)
{
*msg %player% Your cards are $PlayerVar[1], $PlayerVar[2], $PlayerVar[3]
$PlayerVar[6] = $PlayerVar[6] + $PlayerVar[3]
$PlayerVar[7] = 3
if ($PlayerVar[6] > 21)
{
if ($PlayerVar[1] = 11)
{
$PlayerVar[1] = 1
$PlayerVar[6] = $PlayerVar[6] - 10
*msg %player% Your Ace had to be changed to a value of 1 instead of 11 to prevent you from going over 21
*msg %player% Your total card value is $PlayerVar[6]
*msg %player% Would you like to Hit or Stand?
}
else if ($PlayerVar[2] = 11)
{
$PlayerVar[2] = 1
$PlayerVar[6] = $PlayerVar[6] - 10
*msg %player% Your Ace had to be changed to a value of 1 instead of 11 to prevent you from going over 21
*msg %player% Your total card value is $PlayerVar[6]
*msg %player% Would you like to Hit or Stand?
}
else if ($PlayerVar[3] = 11)
{
$PlayerVar[3] = 1
$PlayerVar[6] = $PlayerVar[6] - 10
*msg %player% Your Ace had to be changed to a value of 1 instead of 11 to prevent you from going over 21
*msg %player% Your total card value is $PlayerVar[6]
*msg %player% Would you like to Hit or Stand?
}
else
{
*msg %player% You have gone over 21. You Lose. Better luck next time.
$PlayerVar[1] = 0
}
}
else
{
*msg %player% Your total card value is $PlayerVar[6]
*msg %player% Would you like to Hit or Stand?
}
}
else if ($PlayerVar[7] = 3)
{
*msg %player% Your cards are $PlayerVar[1], $PlayerVar[2], $PlayerVar[3], $PlayerVar[4]
$PlayerVar[6] = $PlayerVar[6] + $PlayerVar[4]
$PlayerVar[7] = 4
if ($PlayerVar[6] > 21)
{
if ($PlayerVar[1] = 11)
{
$PlayerVar[1] = 1
$PlayerVar[6] = $PlayerVar[6] - 10
*msg %player% Your Ace had to be changed to a value of 1 instead of 11 to prevent you from going over 21
*msg %player% Your total card value is $PlayerVar[6]
*msg %player% Would you like to Hit or Stand?
}
else if ($PlayerVar[2] = 11)
{
$PlayerVar[2] = 1
$PlayerVar[6] = $PlayerVar[6] - 10
*msg %player% Your Ace had to be changed to a value of 1 instead of 11 to prevent you from going over 21
*msg %player% Your total card value is $PlayerVar[6]
*msg %player% Would you like to Hit or Stand?
}
else if ($PlayerVar[3] = 11)
{
$PlayerVar[3] = 1
$PlayerVar[6] = $PlayerVar[6] - 10
*msg %player% Your Ace had to be changed to a value of 1 instead of 11 to prevent you from going over 21
*msg %player% Your total card value is $PlayerVar[6]
*msg %player% Would you like to Hit or Stand?
}
else if ($PlayerVar[4] = 11)
{
$PlayerVar[4] = 1
$PlayerVar[6] = $PlayerVar[6] - 10
*msg %player% Your Ace had to be changed to a value of 1 instead of 11 to prevent you from going over 21
*msg %player% Your total card value is $PlayerVar[6]
*msg %player% Would you like to Hit or Stand?
}
else
{
*msg %player% You have gone over 21. You Lose. Better luck next time.
$PlayerVar[1] = 0
}
}
else
{
*msg %player% Your total card value is $PlayerVar[6]
*msg %player% Would you like to Hit or Stand?
}
}
else
{
*msg %player% Your cards are $PlayerVar[1], $PlayerVar[2], $PlayerVar[3], $PlayerVar[4], $PlayerVar[5]
$PlayerVar[6] = $PlayerVar[6] + $PlayerVar[5]
$PlayerVar[7]=5
if ($PlayerVar[6] > 21)
{
if ($PlayerVar[1] = 11)
{
$PlayerVar[1] = 1
$PlayerVar[6] = $PlayerVar[6] - 10
*msg %player% Your Ace had to be changed to a value of 1 instead of 11 to prevent you from going over 21
*msg %player% Congradulations! You have won due to the 5 card rule!
*grantcash %player% $PlayerVar[1]
$PlayerVar[1] = 0
}
else if ($PlayerVar[2] = 11)
{
$PlayerVar[2] = 1
$PlayerVar[6] = $PlayerVar[6] - 10
*msg %player% Your Ace had to be changed to a value of 1 instead of 11 to prevent you from going over 21
*msg %player% Congradulations! You have won due to the 5 card rule!
*grantcash %player% $PlayerVar[1]
$PlayerVar[1] = 0
}
else if ($PlayerVar[3] = 11)
{
$PlayerVar[3] = 1
$PlayerVar[6] = $PlayerVar[6] - 10
*msg %player% Your Ace had to be changed to a value of 1 instead of 11 to prevent you from going over 21
*msg %player% Congradulations! You have won due to the 5 card rule!
*grantcash %player% $PlayerVar[1]
$PlayerVar[1] = 0
}
else if ($PlayerVar[4] = 11)
{
$PlayerVar[4] = 1
$PlayerVar[6] = $PlayerVar[6] - 10
*msg %player% Your Ace had to be changed to a value of 1 instead of 11 to prevent you from going over 21
*msg %player% Congradulations! You have won due to the 5 card rule!
*grantcash %player% $PlayerVar[1]
$PlayerVar[1] = 0
}
else if ($PlayerVar[5] = 11)
{
$PlayerVar[5] = 1
$PlayerVar[6] = $PlayerVar[6] - 10
*msg %player% Your Ace had to be changed to a value of 1 instead of 11 to prevent you from going over 21
*msg %player% Congradulations! You have won due to the 5 card rule!
*grantcash %player% $PlayerVar[1]
$PlayerVar[1] = 0
}
else
{
*msg %player% You have gone over 21. You Lose. Better luck next time.
$PlayerVar[1] = 0
}
}
else
{
*msg %player% Congradulations! You have won due to the 5 card rule!
*grantcash %player% $PlayerVar[1]
$PlayerVar[1] = 0
}
}
}
Event( "&command", "Stand" )
{
*msg %player% You have decided to Stand with a total card value of $PlayerVar[6]
*msg %player% It is now the dealers turn to play.
*msg %player% The dealers cards are $playervar[10] and $playervar[11]
if ($PlayerVar[16] > 16)
{
sleep(20)
*msg %player% The dealer decides to Stand with a total value of $playervar[16]
if ($PlayerVar[16] > $PlayerVar[6])
{
*msg %player% Unfortunatly the dealer has won this round.
*msg %player% better luck next time.
$PlayerVar[1] = 0
}
else if ($PlayerVar[16] = $PlayerVar[6])
{
*msg %player% The game is a tie, there is no winner. Atleast you diden't loose anything.
*msg %player% Feel free to try again.
*grantcash player $playervar[15]
$PlayerVar[1] = 0
}
else
{
*msg %player% Congradulations! you have won this hand!
*msg %player% You have won $playervar[15] Deneri!
*grantcash %player% $playervar[15]
$PlayerVar[1] = 0
}
}
else
{
Sleep(20)
*msg %player% The dealer hits. his cards are now $PlayerVar[10], $PlayerVar[11], and $PlayerVar[12]
$Playervar[16] = $Playervar[16] + $PlayerVar[12]
if ($PlayerVar[16] > 16)
{
if ($PlayerVar[16] > 21)
{
*msg %player% The dealer has gone over 21! you have won this hand! Congratulations
*msg %player% You have won $playervar[15] Deneri!
*grantcash %player% $playervar[15]
$PlayerVar[1] = 0
}
else
{
sleep(20)
*msg %player% The dealer decides to Stand with a total value of $playervar[16]
if ($PlayerVar[16] > $PlayerVar[6])
{
*msg %player% Unfortunatly the dealer has won this round.
*msg %player% better luck next time.
$PlayerVar[1] = 0
}
else if ($PlayerVar[16] = $PlayerVar[6])
{
*msg %player% The game is a tie, there is no winner. Atleast you diden't loose anything.
*msg %player% Feel free to try again.
*grantcash player $playervar[15]
$PlayerVar[1] = 0
}
else
{
*msg %player% Congratulations! you have won this hand!
*msg %player% You have won $playervar[15] Deneri!
*grantcash %player% $playervar[15]
$PlayerVar[1] = 0
}
}
}
else
{
Sleep(20)
*msg %player% The dealer hits. his cards are now $PlayerVar[10], $PlayerVar[11], $PlayerVar[12], and $PlayerVar[13]
$Playervar[16] = $Playervar[16] + $PlayerVar[13]
if ($PlayerVar[16] > 16)
{
if ($PlayerVar[16] > 21)
{
*msg %player% The dealer has gone over 21! you have won this hand! Congratulations
*msg %player% You have won $playervar[15] Deneri!
*grantcash %player% $playervar[15]
$PlayerVar[1] = 0
}
else
{
sleep(20)
*msg %player% The dealer decides to Stand with a total value of $playervar[16]
if ($PlayerVar[16] > $PlayerVar[6])
{
*msg %player% Unfortunatly the dealer has won this round.
*msg %player% better luck next time.
$PlayerVar[1] = 0
}
else if ($PlayerVar[16] = $PlayerVar[6])
{
*msg %player% The game is a tie, there is no winner. Atleast you diden't loose anything.
*msg %player% Feel free to try again.
*grantcash player $playervar[15]
$PlayerVar[1] = 0
}
else
{
*msg %player% Congratulations! you have won this hand!
*msg %player% You have won $playervar[15] Deneri!
*grantcash %player% $playervar[15]
$PlayerVar[1] = 0
}
}
}
else
{
Sleep(20)
*msg %player% The dealer hits. his cards are now $PlayerVar[10], $PlayerVar[11], $PlayerVar[12], $PlayerVar[13], and $PlayerVar[14]
$Playervar[16] = $Playervar[16] + $PlayerVar[14]
if ($PlayerVar[16] > 21)
{
*msg %player% The dealer has gone over 21! you have won this hand! Congratulations
*msg %player% You have won $playervar[15] Deneri!
*grantcash %player% $playervar[15]
$PlayerVar[1] = 0
}
else
{
*msg %player% The dealer wins by default due to the 5 card rule.
*msg %player% Better luck next time.
$PlayerVar[1] = 0
}
}
}
}
}
on ciroz, its text is simply:
Code: Select all
Welcome to the blackjack playguide.
Rules:
the rules of the game are simple. get as close to 21 as you can
without going over. then, if your card value is higher then the
dealers, you win. If you go over 21 and have an ace (11) in your
hand, it will automatically be changed to a 1 to prevent you from
loosing the game. however, this is not yet done for the dealer.
Commands:
type &blackjack to start a new game
type &hit to hit (get another card)
type &stand to stand (end your turn and let the dealer play)
*me puts in a line to make the post wider so the script lines don't wrap.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
(sorry to anybody with a low resolution monitor)