Jump to content
DaBombGamer

BlackJack Script [BAREBONES]

Recommended Posts

Original Author: PapaBear

Reupload: DaBombGamer

Source: My Google Drive :P

Coding Knowledge: Moderate

Works on 4.0. Haven't tested 4.4

This is a barebones script. I am not including the Functions.hpp etc. If someone wants to put effort and do that, i'll happily add it to the main post :)

Similar to @Repentz repost, but this is blackjack, and that... well it's slots.

Sorry it's not a full release. Currently 4AM and don't feel like doing much coding. May add it in at a later time.

CREDITS TO DEADLESSZOMBIE FOR THIS SOURCE. IF YOU DON'T KNOW HOW TO ADD THE REST IN: https://altisdev.com/topic/766/tuto-ajoutez-le-black-jack-d

Next four files are in core\shops

Create a file named fn_BJbet.sqf

/*
	File: fn_BJbet.sqf
	Description: Blackjack
	Created by Blacklistgaming.org
        Coder: PapaBear
*/

private ["_betamt"];
_betamt = [_this,0,1,[0]] call BIS_fnc_param;
disableSerialization;
_display = findDisplay 5980;

if(life_cash < _betamt) exitWith {hint format["You don't have enough money to play (%1$)",_betamt];};   
life_cash = life_cash - _betamt;


_Pcard1 = _display displayCtrl 5992;
_Pcard2 = _display displayCtrl 5993;
_Pcard3 = _display displayCtrl 5994;
_Pcard4 = _display displayCtrl 5997;
_Pcard5 = _display displayCtrl 5998;
_Dcard1 = _display displayCtrl 5990;
_Dcard2 = _display displayCtrl 5991;
_Dcard3 = _display displayCtrl 5995;
_Dcard4 = _display displayCtrl 5996;
_bet1 = _display displayCtrl 5984;
_bet2 = _display displayCtrl 5985;
_bet3 = _display displayCtrl 5986;
_bet4 = _display displayCtrl 5987;
_Stay = _display displayCtrl 5982;
_Hit = _display displayCtrl 5983;
_TOTALTXT = _display displayCtrl 6007;

	_Pcard1 ctrlSetText "";
	_Pcard2 ctrlSetText "";
	_Pcard3 ctrlSetText "";
	_Pcard4 ctrlSetText "";
	_Pcard5 ctrlSetText "";
	_Dcard1 ctrlSetText "";
	_Dcard2 ctrlSetText "";
	_Dcard3 ctrlSetText "";
	_Dcard4 ctrlSetText "";
	_TOTALTXT ctrlSetText "Total: ";


_bet2KTEXT = _display displayCtrl 6003;
_bet4KTEXT = _display displayCtrl 6004;
_bet6KTEXT = _display displayCtrl 6005;
_bet8KTEXT = _display displayCtrl 6006;
_total = 0;
_bet1 ctrlEnable false;
_bet2 ctrlEnable false;
_bet3 ctrlEnable false;
_bet4 ctrlEnable false;
_Hit ctrlEnable false;
_Stay ctrlEnable false;

switch ( _betamt ) do 
{
	case 2000:  { _bet4KTEXT ctrlSetText ""; _bet6KTEXT ctrlSetText ""; _bet8KTEXT ctrlSetText ""; };
	case 4000: { _bet2KTEXT ctrlSetText ""; _bet6KTEXT ctrlSetText ""; _bet8KTEXT ctrlSetText ""; };
	case 6000: { _bet4KTEXT ctrlSetText ""; _bet2KTEXT ctrlSetText ""; _bet8KTEXT ctrlSetText ""; };
	case 8000: { _bet4KTEXT ctrlSetText ""; _bet6KTEXT ctrlSetText ""; _bet2KTEXT ctrlSetText ""; };
	default { _bet4KTEXT ctrlSetText ""; _bet6KTEXT ctrlSetText ""; _bet8KTEXT ctrlSetText ""; }
};

// give dealer 1 card, other is XX 
// give player 2 cards

_number = ceil(random 11);
_number = _number + 2;

if ( _number == 11 OR _number == 12 ) then
{
	_number = 10;

}
else 
{
	if( _number == 13 ) then
	{
		_number = "ACE";
	};

};

_Pcard1 ctrlSetText format["%1",_number];

sleep 0.5;

_number = ceil(random 11);
_number = _number + 2;

if ( _number == 11 OR _number == 12 ) then
{
	_number = 10;

}
else 
{
	if( _number == 13 ) then
	{
		_number = "ACE";
	};

};

_Dcard1 ctrlSetText format["%1",_number];

sleep 0.5;

_number = ceil(random 11);
_number = _number + 2;

if ( _number == 11 OR _number == 12 ) then
{
	_number = 10;

}
else 
{
	if( _number == 13 ) then
	{
		_number = "ACE";
	};

};

_Pcard2 ctrlSetText format["%1",_number];

_P1 = ctrlText _Pcard1;
_P2 = ctrlText _Pcard2;
_D1 = ctrlText _Dcard1;

sleep 0.5;
_winnings = _display displayCtrl 6001;
_total = 0;
if( _P1 == "ACE" ) then
{
	if( _P2 == "10" ) then
	{
		_total = 21;
	}else
	{
		if( _P2 == "ACE" ) then
		{
			_total = 12;
		}
		else
		{
			_total = 11 + (parseNumber _P2);
		};
	};
}
else
{
	if( _P2 == "ACE" ) then
	{
		if( _P1 == "10" ) then 
		{
			_total = 21;
		}
		else
		{
			if( _P1 == "ACE" ) then
			{
				_total = 12;
			}
			else
			{
				_total = 11 + (parseNumber _P1);
			};
		
		};
	}
	else
	{
		_total = (parseNumber _P1) + (parseNumber _P2);
	
	};

};

_TOTALTXT ctrlSetText format["%1",_total];

if( _total == 21 ) then 
{ 
	_win = 4 * _betamt;
	life_cash = life_cash + _win;
	_winnings ctrlSetText format["%1",_win];
	
	_bet1 ctrlEnable true;
	_bet2 ctrlEnable true;
	_bet3 ctrlEnable true;
	_bet4 ctrlEnable true;
}
else
{

	_number = ceil(random 11);
	_number = _number + 2;

	//check if dealer got ace and then a 10.
	//10 then ace?
	
	if( _number == 13 ) then
	{
		_number = "ACE";
		if( _D1 == "10" ) then
		{		
			_Dcard2 ctrlSetText format["%1",_number];
			_winnings = _display displayCtrl 6001;
			_winnings ctrlSetText "You Lose";
			_bet1 ctrlEnable true;
			_bet2 ctrlEnable true;
			_bet3 ctrlEnable true;
			_bet4 ctrlEnable true;
		}
		else
		{
			_Dcard2 ctrlSetText "XX";
		};
	}
	else
	{
		if( _D1 == "ACE" ) then 
		{
			if( _number == 10 ) then 
			{
				_Dcard2 ctrlSetText format["%1",_number];
				_winnings = _display displayCtrl 6001;
				_winnings ctrlSetText "You Lose";
				_bet1 ctrlEnable true;
				_bet2 ctrlEnable true;
				_bet3 ctrlEnable true;
				_bet4 ctrlEnable true;
			}
			else
			{
				_Dcard2 ctrlSetText "XX";
			};
			
		}
		else
		{
			_Dcard2 ctrlSetText "XX";
		};
		
	};

	_Hit ctrlEnable true;
	_Stay ctrlEnable true;

};

Now in the same folder create fn_BJhit.sqf

/*
	File: fn_BJhit.sqf
	Description: Blackjack
	Created by Blacklistgaming.org
        Coder: PapaBear
*/
//hit phase
//check value of cards
//stop if bust
//if 5th hit and still good win

disableSerialization;
_display = findDisplay 5980;


//setup variables
_Pcard1 = _display displayCtrl 5992;   
_Pcard2 = _display displayCtrl 5993;
_Pcard3 = _display displayCtrl 5994;
_Pcard4 = _display displayCtrl 5997;
_Pcard5 = _display displayCtrl 5998;
_TOTALTXT = _display displayCtrl 6007;
_bet2KTEXT = _display displayCtrl 6003;
_bet4KTEXT = _display displayCtrl 6004;
_bet6KTEXT = _display displayCtrl 6005;
_bet8KTEXT = _display displayCtrl 6006;
_betamt = 0;

if( (ctrlText _bet2KText) != "" ) then
{
	_betamt = 2000;
}
else
{
	if( (ctrlText _bet4KText) != "" ) then
	{
		_betamt = 4000;
	}
	else
	{
		if( (ctrlText _bet6KText) != "" ) then
		{
			_betamt = 6000;
		}
		else
		{
			_betamt = 8000;
		};
	};
};

_gameover = false;
_bet1 = _display displayCtrl 5984;
_bet2 = _display displayCtrl 5985;
_bet3 = _display displayCtrl 5986;
_bet4 = _display displayCtrl 5987;
_Stay = _display displayCtrl 5982;
_Hit = _display displayCtrl 5983;
_winnings = _display displayCtrl 6001;
_bet1 ctrlEnable false;
_bet2 ctrlEnable false;
_bet3 ctrlEnable false;
_bet4 ctrlEnable false;
_Hit ctrlEnable false;
_Stay ctrlEnable false;

_P1T = ctrlText _Pcard1;
_P2T = ctrlText _Pcard2;
_P3T = ctrlText _Pcard3;
_P4T = ctrlText _Pcard4;
_P5T = ctrlText _Pcard5;

_ACES = false;
_ACE1 = 0;
_ACE2 = 0;
_ACE3 = 0;
_ACE4 = 0;
_total = 0;
_win = 0;
_cash = 0;

//figure out which card is next to be dealt
_NextCard = 0;
if(_P3T != "" ) then
{
	if(_P4T != "" ) then
	{		
		_NextCard = 5;
	}
	else
	{
		_NextCard = 4;
	};
}
else
{
	_NextCard = 3;
};

//deal next card
_number = ceil(random 11);
_number = _number + 2;
if ( _number == 11 OR _number == 12 ) then
{
	_number = 10;

}
else 
{
	if( _number == 13 ) then
	{
		_number = "ACE";
	};

};

//assign card to its place
switch ( _NextCard ) do
{
	case 3: { _Pcard3 ctrlSetText format["%1",_number]; _P3T = ctrlText _Pcard3; };
	case 4: { _Pcard4 ctrlSetText format["%1",_number]; _P4T = ctrlText _Pcard4; };
	case 5: { _Pcard5 ctrlSetText format["%1",_number]; _P5T = ctrlText _Pcard5; };
	default { _Pcard3 ctrlSetText format["%1",_number]; _P3T = ctrlText _Pcard3; }
};



_totalAces = 0;
//check if there are any aces
//and where they are
if( _P1T == "ACE" ) then
{
	_ACES = true;
	_ACE1 = 1;
	_totalAces = 1;
};

if( _P2T == "ACE" ) then
{
	_ACES = true;
	if( _ACE1 == 0 ) then
	{
		_ACE1 = 2;
		_totalAces = 1;
	}
	else
	{
		_ACE2 = 2;
		_totalAces = 2;
	};
	
};

if( _P3T == "ACE" ) then
{
	_ACES = true;
	if( _ACE1 == 0 ) then
	{
		_ACE1 = 3;
		_totalAces = 1;
	}
	else
	{
		if( _ACE2 == 0 ) then
		{
			_ACE2 = 3;
			_totalAces = 2;
		}
		else
		{
			_ACE3 = 3;
			_totalAces = 3;
		};
		
	};
	
};

if( _P4T == "ACE" ) then
{
	_ACES = true;
	if( _ACE1 == 0 ) then
	{
		_ACE1 = 4;
		_totalAces = 1;
	}
	else
	{
		if( _ACE2 == 0 ) then
		{
			_ACE2 = 4;
			_totalAces = 2;
		}
		else
		{
			if( _ACE3 == 0 ) then
			{
				_ACE3 = 4;
				_totalAces = 3;
			}
			else
			{
				_ACE4 = 4;
				_totalAces = 4;
			};
		};
		
	};
	
};

if( _P5T == "ACE" ) then 
{	
	_ACES = true;
	if( _ACE1 == 0 ) then
	{
		_ACE1 = 5;
		_totalAces = 1;
	}
	else
	{
		if( _ACE2 == 0 ) then
		{
			_ACE2 = 5;
			_totalAces = 2;
		}
		else
		{
			if( _ACE3 == 0 ) then
			{
				_ACE3 = 5;
				_totalAces = 3;
			}
			else
			{		
				_ACE4 = 5;
				_totalAces = 4;
			};
		};
	};
};

	_temp1 = 0;
	_temp2 = 0;
//aces check complete.
//now we need total the players cards
//if there are aces we need to compare
// 11 vs 1 totals
// the total values of whether is 21 or under
if( _ACES ) then 
{
	if( _ACE4 != 5 OR _ACE3 != 5 OR _ACE2 != 5 OR _ACE1 != 5 ) then 
	{
		_total = _total + (parseNumber _P5T);
	};
	
	if( _ACE4 != 4 OR _ACE3 != 4 OR _ACE2 != 4 OR _ACE1 != 4 ) then 
	{
		_total = _total + (parseNumber _P4T);
	};
	
	if( _ACE3 != 3 OR _ACE2 != 3 OR _ACE1 != 3 ) then 
	{
		_total = _total + (parseNumber _P3T);
	};
	
	if( _ACE2 != 2 OR _ACE1 != 2 ) then 
	{
		_total = _total + (parseNumber _P2T);
	};
	
	if( _ACE1 != 1 ) then 
	{
		_total = _total + (parseNumber _P1T);
	};
	

	switch ( _totalAces ) do 
	{
		case 4:
		{
			//11,1,1,1 
			_temp1 = 14;
			//1,1,1,1
			_temp2 = 4;
		};
		case 3:
		{
			//11,1,1
			_temp1 = 13;
			//1,1,1
			_temp2 = 3;
		};
		case 2:
		{
			//11,1
			_temp1 = 12;
			//1,1
			_temp2 = 2;
		};
		case 1:
		{
			//11
			_temp1 = 11;
			//1
			_temp2 = 1;
		};
		default {_temp1 = 0; _temp2 = 0;}
	
	};
	
	_totalTemp = _total + _temp2;
	_total = _total + _temp1;
	
	//if player hit 21 then he wins 4X
	if( _total == 21 ) then
	{
		_TOTALTXT ctrlSetText format["%1",_total];
		_win = 4;
	}
	else
	{
		//player didnt hit 21
		//now check if he went bust using the 11
		//if he didnt then can keep playing
		if( _total > 21 ) then 
		{
			//using 11 he went over 21
			//lets check if he is still over using a 1 instead
			//if over 21 he loses, else keeps playing						
			if( _totalTemp > 21 ) then
			{
				_TOTALTXT ctrlSetText format["%1",_totalTemp];
				_gameover = true;
			}
			else
			{
				//if using 1 in total and still under 21
				//while using 5 cards, player wins 3X
				if( _NextCard == 5 ) then 
				{
					_win = 4;
				}
				else
				{				
					_TOTALTXT ctrlSetText format["%1",_totalTemp];
				};
			};
		}
		else
		{
			_TOTALTXT ctrlSetText format["%1",_total];
		};
	}; 
}
else
{	
	// NO ACES!!!! Total all cards
	_total = (parseNumber _P1T) + (parseNumber _P2T) + (parseNumber _P3T) + (parseNumber _P4T) + (parseNumber _P5T);
	_TOTALTXT ctrlSetText format["%1",_total];
	//if hit 21, win
	if( _total == 21 ) then
	{
		_win = 4;
		_gameover = true;
	}
	else
	{
		if( _total > 21 ) then 
		{
			_gameover = true;
		};
	};
};


//last check to see if they lose, win,still playing
if( _gameover ) then 
{
	if( _win != 0 ) then 
	{
		_cash = _betamt * _win;
		life_cash = life_cash + _cash;
		_winnings ctrlSetText  format["%1",_cash];
		
		//you win, give money
		//set text 
		//free up bet buttons
	}
	else
	{
		_winnings ctrlSetText "You lose. BUST";
		
		//you lose
		//set text
		//free up bet buttons
	};
	
	_bet1 ctrlEnable true;
	_bet2 ctrlEnable true;
	_bet3 ctrlEnable true;
	_bet4 ctrlEnable true;
	_bet2KTEXT  ctrlSetText "BET";
	_bet4KTEXT ctrlSetText "BET";
	_bet6KTEXT ctrlSetText "BET";
	_bet8KTEXT ctrlSetText "BET";
	_Hit ctrlEnable false;
	_Stay ctrlEnable false;

}
else
{

	
	//below 21, can still play
		//free up hit/stay buttons.
		
		_Hit ctrlEnable true;
		_Stay ctrlEnable true;
};

In the same folder (again lol) create fn_BJstay.sqf

/*
	File: fn_BJstay.sqf
	Description: Blackjack
	Created by Blacklistgaming.org
        Coder: PapaBear
*/
//stay
//calculate value of player
//reveal dealer
//if dealer higher, lose
//if dealer lower, dealer hit.
//check dealer value, win/lose hits.

disableSerialization;
_display = findDisplay 5980;


//setup variables
_Pcard1 = _display displayCtrl 5992;   
_Pcard2 = _display displayCtrl 5993;
_Pcard3 = _display displayCtrl 5994;
_Pcard4 = _display displayCtrl 5997;
_Dcard1 = _display displayCtrl 5990;
_Dcard2 = _display displayCtrl 5991;
_Dcard3 = _display displayCtrl 5995;
_Dcard4 = _display displayCtrl 5996;
_TOTALTXT = _display displayCtrl 6007;
_bet2KTEXT = _display displayCtrl 6003;
_bet4KTEXT = _display displayCtrl 6004;
_bet6KTEXT = _display displayCtrl 6005;
_bet8KTEXT = _display displayCtrl 6006;
_betamt = 0;

if( (ctrlText _bet2KText) != "" ) then
{
	_betamt = 2000;
}
else
{
	if( (ctrlText _bet4KText) != "" ) then
	{
		_betamt = 4000;
	}
	else
	{
		if( (ctrlText _bet6KText) != "" ) then
		{
			_betamt = 6000;
		}
		else
		{
			_betamt = 8000;
		};
	};
};

_bet1 = _display displayCtrl 5984;
_bet2 = _display displayCtrl 5985;
_bet3 = _display displayCtrl 5986;
_bet4 = _display displayCtrl 5987;
_Stay = _display displayCtrl 5982;
_Hit = _display displayCtrl 5983;
_winnings = _display displayCtrl 6001;
_bet1 ctrlEnable false;
_bet2 ctrlEnable false;
_bet3 ctrlEnable false;
_bet4 ctrlEnable false;
_Hit ctrlEnable false;
_Stay ctrlEnable false;

_P1T = ctrlText _Pcard1;
_P2T = ctrlText _Pcard2;
_P3T = ctrlText _Pcard3;
_P4T = ctrlText _Pcard4;
_D1T = ctrlText _Dcard1;

_gameover = false;
_totalPlayer = 0;
_totalDealer = 0;
_totalDealer2 = 0;
_totalDealer3 = 0;
_totalDealer4 = 0;
_totalPlayer = ctrlText _TOTALTXT;
_totalPlayer = parseNumber _totalPlayer;
_totalDealer = 0;
_win = 0;


_number = ceil(random 11);
_number = _number + 2;

if ( _number == 11 OR _number == 12 ) then
{
	_number = 10;

}
else 
{
	if( _number == 13 ) then
	{
		_number = 10;
	};

};

_Dcard2 ctrlSetText format["%1",_number];

if( _D1T == "ACE" ) then 
{
	if( _number == 10 ) then 
	{
		_totalDealer = 21;
	}
	else
	{
		_totalDealer = 11 + _number;
	};
}
else
{
	_totalDealer = _number + (parseNumber _D1T);
};

if( _totalDealer > _totalPlayer ) then 
{
	//dealer beat player
	//dealer wins
	//no money for player
	_gameover = true;
}
else
{
	if( _totalDealer == _totalPlayer ) then 
	{
		//tie, betamt won back
		_win = 1;
		_gameover = true;
	}
	else 
	{
		_gameover = false;
	
	};
	
};

if( !_gameover ) then 
{
	_number = ceil(random 11);
	_number = _number + 2;

	if ( _number == 11 OR _number == 12 ) then
	{
		_number = 10;
		_Dcard3 ctrlSetText  format["%1",_number];

	}
	else 
	{
		if( _number == 13 ) then
		{
			_Dcard3 ctrlSetText "ACE";
		}
		else
		{
			_Dcard3 ctrlSetText  format["%1",_number];
		};
		
	};

	
	
	if( _number == 13 ) then 
	{
		_totalTemp = _totalDealer + 11;
		_totalTemp2 = _totalDealer + 1;
		
		if( _totalTemp == 21 OR _totalTemp2 == 21 ) then 
		{
				_gameover = true;			
		}
		else
		{
			if( _totalTemp > 21 AND _totalTemp2 > 21 ) then 
			{
				_gameover = true;
				_win = 2;
			};

		};
		
		if( !_gameover ) then 
		{
			if( _totalTemp > _totalPlayer ) then 
			{
				if( _totalTemp < 21 ) then 
				{
					_gameover = true;
				};
			}
			else
			{
				if( _totalTemp2 > _totalPlayer ) then 
				{
					if( _totalTemp2 < 21 ) then 
					{
						_gameover = true;
					};
				};
			
			};
		
		};
	}
	else
	{
		//should check for aces... but ya
		_totalDealer = _totalDealer + _number;
	
		if( _totalDealer > 21 ) then 
		{
			//player wins
			//dealer bust
			_gameover = true;
			_win = 2;
		}
		else
		{
			if( _totalDealer > _totalPlayer ) then 
			{
				//dealer beats player
				
				_gameover = true;
			}
			else 
			{
				if( _totalDealer == _totalPlayer ) then 
				{
					_gameover = true;
					_win = 1;
				}
				else
				{
					_gameover = false;
				};
			
			};
			
		};
	
	};

};

//draw another card for dealer... card 4. fuck this shit....
if( !_gameover ) then 
{
	_win = 2;
};

//last check to see if they lose, win,still playing

if( _win != 0 ) then 
{
	_cash = _betamt * _win;
	life_cash = life_cash + _cash;
	_winnings ctrlSetText  format["%1",_cash];
	//you win, give money
	//set text 
	//free up bet buttons
}
else
{
	_winnings ctrlSetText "You lose. Dealer Wins.";

	//you lose
	//set text
	//free up bet buttons
};

	_bet1 ctrlEnable true;
	_bet2 ctrlEnable true;
	_bet3 ctrlEnable true;
	_bet4 ctrlEnable true;
	_bet2KTEXT  ctrlSetText "BET";
	_bet4KTEXT ctrlSetText "BET";
	_bet6KTEXT ctrlSetText "BET";
	_bet8KTEXT ctrlSetText "BET";

Again in the same folder lmao, create fn_blackjack.sqf

/*
	File: fn_blackjack.sqf
	Description: Blackjack
	Created by Blacklistgaming.org
        Coder: PapaBear
*/

if(!dialog) then {
	createDialog "BlackjackGUI";
};
disableSerialization;

_display = findDisplay 5980;
_Hit = _display displayCtrl 5983;
_Stay = _display displayCtrl 5982;

_Hit ctrlEnable false;
_Stay ctrlEnable false;

_bet1 = _display displayCtrl 5984;
_bet2 = _display displayCtrl 5985;
_bet3 = _display displayCtrl 5986;
_bet4 = _display displayCtrl 5987;   

_bet1 ctrlEnable true;
_bet2 ctrlEnable true;
_bet3 ctrlEnable true;
_bet4 ctrlEnable true;

Now, go to your dialog folder and create blackjack.hpp

/*Created by Blacklistgaming.org Coder: PapaBear */

#define GUI_GRID_X    (0)
#define GUI_GRID_Y    (0)
#define GUI_GRID_W    (0.025)
#define GUI_GRID_H    (0.04)
#define GUI_GRID_WAbs    (1)
#define GUI_GRID_HAbs    (1)
class BlackjackGUI
{
	idd = 5980;
	name="black_jack";
	movingEnabled = 0;
	enableSimulation = 1;
	onLoad = "";
	
	class controlsBackground
	{
	
		class RscFrame_1800: life_RscText
		{
			idc = 5981;
			colorBackground[] = {0,0,0,0.7};    
			x = 3 * GUI_GRID_W + GUI_GRID_X;
			y = 1.5 * GUI_GRID_H + GUI_GRID_Y;
			w = 31 * GUI_GRID_W;
			h = 20.5 * GUI_GRID_H;
		};
		
		class RscText_1000: life_RscText
		{
			idc = 5988;
			text = "Dealer"; //--- ToDo: Localize;
			x = 5 * GUI_GRID_W + GUI_GRID_X;
			y = 3 * GUI_GRID_H + GUI_GRID_Y;
			w = 5 * GUI_GRID_W;
			h = 2 * GUI_GRID_H;
		};
		class RscText_1001: life_RscText
		{
			idc = 5989;
			text = "Player"; //--- ToDo: Localize;
			x = 20 * GUI_GRID_W + GUI_GRID_X;
			y = 3 * GUI_GRID_H + GUI_GRID_Y;
			w = 6 * GUI_GRID_W;
			h = 2 * GUI_GRID_H;
		};
		
		class RscText_1012: life_RscText
		{
			idc = 5999;
			text = "BLACKJACK"; //--- ToDo: Localize;
			x = 9 * GUI_GRID_W + GUI_GRID_X;
			y = 1 * GUI_GRID_H + GUI_GRID_Y;
			w = 18.5 * GUI_GRID_W;
			h = 2.5 * GUI_GRID_H;
			sizeEx = 3 * GUI_GRID_H;
		};
		class RscText_1013: life_RscText
		{
			idc = 6000;
			text = "Winnings: $"; //--- ToDo: Localize;
			x = 5.5 * GUI_GRID_W + GUI_GRID_X;
			y = 15 * GUI_GRID_H + GUI_GRID_Y;
			w = 5 * GUI_GRID_W;
			h = 2.5 * GUI_GRID_H;
		};
	};
		
	class controls
	{
		class STAY_BTN: life_RscButtonMenu
		{
			idc = 5982;
			text = "Stay"; //--- ToDo: Localize;
			//colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", 0.5};
			colorBackground[] = {0.2,0.3,0.9,0.7};
			onButtonClick = "[] spawn life_fnc_BJstay;";
			x = 20 * GUI_GRID_W + GUI_GRID_X;
			y = 14.5 * GUI_GRID_H + GUI_GRID_Y;
			w = 4 * GUI_GRID_W;
			h = 2.5 * GUI_GRID_H;
		};
		class HIT_BTN: life_RscButtonMenu
		{
			idc = 5983;
			text = "Hit"; //--- ToDo: Localize;
			//colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", 0.5};
			colorBackground[] = {0.2,0.3,0.9,0.7};
			onButtonClick = "[] spawn life_fnc_BJhit;";
			x = 27 * GUI_GRID_W + GUI_GRID_X;
			y = 14.5 * GUI_GRID_H + GUI_GRID_Y;
			w = 4 * GUI_GRID_W;
			h = 2.5 * GUI_GRID_H;
		};
		class TOTAL: life_RscText
		{
			idc = 6007;
			text = "Total: "; //--- ToDo: Localize;
			x = 28 * GUI_GRID_W + GUI_GRID_X;
			y = 10.5 * GUI_GRID_H + GUI_GRID_Y;
			w = 4 * GUI_GRID_W;
			h = 2.5 * GUI_GRID_H;
		};
		class BET_5K: life_RscButtonMenu
		{
			idc = 5984;
			text = "2K"; //--- ToDo: Localize;
			//colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", 0.5};
			colorBackground[] = {0.2,0.3,0.9,0.7};
			onButtonClick = "[2000] spawn life_fnc_BJbet;";
			x = 6 * GUI_GRID_W + GUI_GRID_X;
			y = 19 * GUI_GRID_H + GUI_GRID_Y;
			w = 4 * GUI_GRID_W;
			h = 2.5 * GUI_GRID_H;
		};
		class BET_10K: life_RscButtonMenu
		{
			idc = 5985;
			text = "4K"; //--- ToDo: Localize;
			//colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", 0.5};
			colorBackground[] = {0.2,0.3,0.9,0.7};
			onButtonClick = "[4000] spawn life_fnc_BJbet;";
			x = 13 * GUI_GRID_W + GUI_GRID_X;
			y = 19 * GUI_GRID_H + GUI_GRID_Y;
			w = 4 * GUI_GRID_W;
			h = 2.5 * GUI_GRID_H;
		};
		class BET_25K: life_RscButtonMenu
		{
			idc = 5986;
			text = "6K"; //--- ToDo: Localize;
			//colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", 0.5};
			colorBackground[] = {0.2,0.3,0.9,0.7};
			onButtonClick = "[6000] spawn life_fnc_BJbet;";
			x = 20 * GUI_GRID_W + GUI_GRID_X;
			y = 19 * GUI_GRID_H + GUI_GRID_Y;
			w = 4 * GUI_GRID_W;
			h = 2.5 * GUI_GRID_H;
		};
		class BET_50K: life_RscButtonMenu
		{
			idc = 5987;
			text = "8K"; //--- ToDo: Localize;
			//colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", 0.5};
			colorBackground[] = {0.2,0.3,0.9,0.7};
			onButtonClick = "[8000] spawn life_fnc_BJbet;";
			x = 27 * GUI_GRID_W + GUI_GRID_X;
			y = 19 * GUI_GRID_H + GUI_GRID_Y;
			w = 4 * GUI_GRID_W;
			h = 2.5 * GUI_GRID_H;
		};
		
		class Dealer_Card_1: life_RscText
		{
			idc = 5990;
			x = 5 * GUI_GRID_W + GUI_GRID_X;
			y = 5 * GUI_GRID_H + GUI_GRID_Y;
			w = 4 * GUI_GRID_W;
			h = 2.5 * GUI_GRID_H;
		};
		class Dealer_Card_2: life_RscText
		{
			idc = 5991;
			x = 9.5 * GUI_GRID_W + GUI_GRID_X;
			y = 5 * GUI_GRID_H + GUI_GRID_Y;
			w = 4 * GUI_GRID_W;
			h = 2.5 * GUI_GRID_H;
		};
		class Player_Card_1: life_RscText
		{
			idc = 5992;
			x = 20.5 * GUI_GRID_W + GUI_GRID_X;
			y = 5 * GUI_GRID_H + GUI_GRID_Y;
			w = 4 * GUI_GRID_W;
			h = 2.5 * GUI_GRID_H;
		};
		class Player_Card_2: life_RscText
		{
			idc = 5993;
			x = 24.5 * GUI_GRID_W + GUI_GRID_X;
			y = 5 * GUI_GRID_H + GUI_GRID_Y;
			w = 4 * GUI_GRID_W;
			h = 2.5 * GUI_GRID_H;
		};
		class Player_Card_3: life_RscText
		{
			idc = 5994;
			x = 28.5 * GUI_GRID_W + GUI_GRID_X;
			y = 5 * GUI_GRID_H + GUI_GRID_Y;
			w = 4 * GUI_GRID_W;
			h = 2.5 * GUI_GRID_H;
		};
		class Dealer_Card_4: life_RscText
		{
			idc = 5995;
			x = 5 * GUI_GRID_W + GUI_GRID_X;
			y = 8 * GUI_GRID_H + GUI_GRID_Y;
			w = 4 * GUI_GRID_W;
			h = 2.5 * GUI_GRID_H;
		};
		class Dealer_Card_5: life_RscText
		{
			idc = 5996;
			x = 9.5 * GUI_GRID_W + GUI_GRID_X;
			y = 8 * GUI_GRID_H + GUI_GRID_Y;
			w = 4 * GUI_GRID_W;
			h = 2.5 * GUI_GRID_H;
		};
		class Player_Card_4: life_RscText
		{
			idc = 5997;
			x = 20.5 * GUI_GRID_W + GUI_GRID_X;
			y = 8 * GUI_GRID_H + GUI_GRID_Y;
			w = 4 * GUI_GRID_W;
			h = 2.5 * GUI_GRID_H;
		};
		class Player_Card_5: life_RscText
		{
			idc = 5998;
			x = 24.5 * GUI_GRID_W + GUI_GRID_X;
			y = 8 * GUI_GRID_H + GUI_GRID_Y;
			w = 4 * GUI_GRID_W;
			h = 2.5 * GUI_GRID_H;
		};
		
		class Winnings: life_RscText
		{
			idc = 6001;
			x = 11 * GUI_GRID_W + GUI_GRID_X;
			y = 15 * GUI_GRID_H + GUI_GRID_Y;
			w = 5 * GUI_GRID_W;
			h = 2.5 * GUI_GRID_H;
		};
		class EXIT_BTN: life_RscButtonMenu
		{
			idc = 6002;
			text = "EXIT"; //--- ToDo: Localize;
			colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", 0.5};
			onButtonClick = "closeDialog 0;";
			x = 30 * GUI_GRID_W + GUI_GRID_X;
			y = 1.5 * GUI_GRID_H + GUI_GRID_Y;
			w = 4 * GUI_GRID_W;
			h = 1 * GUI_GRID_H;
		};
		class RscText_1015: life_RscText
		{
			idc = 6003;
			text = "BET"; //--- ToDo: Localize;
			x = 7 * GUI_GRID_W + GUI_GRID_X;
			y = 18 * GUI_GRID_H + GUI_GRID_Y;
			w = 2 * GUI_GRID_W;
			h = 1 * GUI_GRID_H;
		};
		class RscText_1016: life_RscText
		{
			idc = 6004;
			text = "BET"; //--- ToDo: Localize;
			x = 14 * GUI_GRID_W + GUI_GRID_X;
			y = 18 * GUI_GRID_H + GUI_GRID_Y;
			w = 2 * GUI_GRID_W;
			h = 1 * GUI_GRID_H;
		};
		class RscText_1017: life_RscText
		{
			idc = 6005;
			text = "BET"; //--- ToDo: Localize;
			x = 21 * GUI_GRID_W + GUI_GRID_X;
			y = 18 * GUI_GRID_H + GUI_GRID_Y;
			w = 2 * GUI_GRID_W;
			h = 1 * GUI_GRID_H;
		};
		class RscText_1018: life_RscText
		{
			idc = 6006;
			text = "BET"; //--- ToDo: Localize;
			x = 28 * GUI_GRID_W + GUI_GRID_X;
			y = 18 * GUI_GRID_H + GUI_GRID_Y;
			w = 2 * GUI_GRID_W;
			h = 1 * GUI_GRID_H;
		};
	};
};

That's the base script. Enjoy!

Edited by DaBombGamer
Added Resourceful Link
  • Like 3

Share this post


Link to post
Share on other sites

I got this to work on the first try after installing 

https://www.altisliferpg.com/topic/307-tutorial-slot-machines/#comment-1405

I am using v5.0.

To add the missing parts that I found on the referenced site;

In main\Functions.hpp add "this" to the bottom of

 class Shops {
        file = "core\shops";

class blackjack {};
		class BJbet {};
		class BJhit {};
		class BJstay {};
 

In main\dialog\MasterHandler.hpp add "this" at the bottom

#include "blackjack.hpp"

This goes into the infostand

this allowDamage false; this enableSimulation false; this addAction[" Blackjack",life_fnc_blackjack];

This works for me, it might not work for you.

Thanks for the Script. 

 

 

  • Like 1

Share this post


Link to post
Share on other sites

It's a very nice script however it's too easy to win since it has some bugs. One example is that the dealer only takes as many cards as the player decides to take. So if you press stay and the dealer gets an ACE and 3 and 10 the player wins even though the dealer should take another card.blackjackbug.png.04729241bf80c9399b69899a700d7c13.png

Share this post


Link to post
Share on other sites
15 hours ago, Felix said:

It's a very nice script however it's too easy to win since it has some bugs. One example is that the dealer only takes as many cards as the player decides to take. So if you press stay and the dealer gets an ACE and 3 and 10 the player wins even though the dealer should take another card.blackjackbug.png.04729241bf80c9399b69899a700d7c13.png

That unfortunately is the flaw of the script, rather easy to win

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×