SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 09/02/2014, 06:49 AM   #1
Grimrandomer
Big Clucker
 
Grimrandomer's Avatar
 
Join Date: Dec 2011
Posts: 125
Reputation: 54
Post gCasino - Scripted Casino's

While working on an RP script last year, I made a simple script to re-create the single player poker casino game.

This is my first attempt at making an include, if I have made any mistakes please help me learn by suggesting ways to do it better instead of pointing out flaws.

Should now be fixed!

The current version 1.0.0.2 only re-creates the poker game, but has the flexibility to add other casino games in the future.

Video:
[ame]http://www.youtube.com/watch?v=Fe8FEUoXDmE[/ame]


To add a new casino game object:
Code:
CreateCasinoMachine(_type, Float:_lX, Float:_lY, Float:_lZ, Float:_rX, Float:_rY, Float:_rZ, useDynamicObj=0);

// _type is the Casino Type (Currently only CASINO_MACHINE_POKER)
// _lX, _lY, _lZ is the Position X/Y/Z
// _rX, _rY, _rZ is the Rotation X/Y/Z
// useDynamicObj=0 is to use the DynamicObject in incognito's streamer (Requires the <streamer> be included prior to <GrimCasino> )

//Returns: _machineID

To remove a casino object:
Code:
RemoveCasinoMachine(_machineID); //Safely destroy a casino object

Other functions:
Code:
IsValidCasinoMachineType(_type); //Is this casino type valid?
GetMachineType(_machineID, &_type); //Gets the casino machine type (Returns 0 if its an invalid machine id)
ClosestCasinoMachine(playerid); //Machine ID they are near (INVALID_CASINO_MACHINE_ID if by none)
IsPlayerAtAnyCasinoMachine(playerid); //Is player currently using any machine
IsPlayerAtCasinoMachine(playerid, _machineID); //is player currently using a machine
RemoveAllFromMachine(_machineID); //Remove all players using a machine
RemoveFromMachine(playerid, _machineID); //Remove a player from a machine
RemoveAllFromAllMachines(); //Kick all players from all machines

Callbacks:
Code:
forward OnCasinoMoney(playerid, machineid, amount, result); //Casino Money Event
//result = CASINO_MONEY_CHARGE ~ This is called when they place a bet
//result = CASINO_MONEY_WIN ~ This is called if they win some money
//result = CASINO_MONEY_NOTENOUGH ~ This is called if they don't have enough to place the desired bet

forward OnCasinoStart(playerid, machineid); //Called when a Casino interface is opened
forward OnCasinoEnd(playerid, machineid); //Called when a Casino interface is closed
forward OnCasinoMessage(playerid, machineid, message[]); //Called when the casino has some text for the player, such as "Hold any or all of your cards"

Note:
So this can work with any existing anti-cheats, the following must be added in your code:
Code:
stock CasinoGetPlayerMoney(playerid) {
	return GetPlayerMoney(playerid);
}
This allows you to control how the players money is checked.

Example:

Code:
    #include <a_samp>
    #include <core>
    #include <float>
    #include <GrimCasino>
     
    main() {
            print("----------------------------------");
            print("  Bare Script");
            print("----------------------------------");
    }
     
    public OnGameModeInit() {
            CreateCasinoMachine(CASINO_MACHINE_POKER, 2034.9810, 1340.2120, 10.6517, 0.0000, 0.0000, -90.0000);
            return 1;
    }
     
    public OnCasinoStart(playerid, machineid) {
            new _type;
            if (GetMachineType(machineid, _type)) {
                if (_type == CASINO_MACHINE_POKER) {
                            SendClientMessage(playerid, 0xFFFFFFFF, "[CASINO] Welcome to the Poker machine");
                            SendClientMessage(playerid, 0xFFFFFFFF, " > How to play:");
                            SendClientMessage(playerid, 0xFFFFFFFF, " >  Select how many coins to wager, the more you wager, the higher your winnings");
                            SendClientMessage(playerid, 0xFFFFFFFF, " >  If you wager 1 coin ($100) and your hand is a Straight, you will win $400");
                            SendClientMessage(playerid, 0xFFFFFFFF, " >  For information on poker hands see: http://en.wikipedia.org/wiki/List_of_poker_hands");
                    }
            }
    }
     
    public OnCasinoEnd(playerid, machineid) {
        SendClientMessage(playerid, 0xFFFFFFFF, "[CASINO] Goodbye, Thanks for playing!");
    }
     
    public OnCasinoMessage(playerid, machineid, message[]) {
            new _msg[128];
            format(_msg, 128, "[CASINO] %s", message);
            SendClientMessage(playerid, 0xFFFFFFFF, _msg);
    }
     
    public OnCasinoMoney(playerid, machineid, amount, result) {
            new message[128];
            if (result == CASINO_MONEY_CHARGE) {
                    GivePlayerMoney(playerid, (amount * -1));
                    format(message, 128, "[CASINO] You have been charged $%i", amount);
            } else if (result == CASINO_MONEY_WIN) {
                    GivePlayerMoney(playerid, amount);
                    format(message, 128, "[CASINO] You have won $%i", amount);
            } else {/*if (result == CASINO_MONEY_NOTENOUGH) {*/
                    format(message, 128, "[CASINO] You dont have $%i to place a bet!", amount);
            }
            SendClientMessage(playerid, 0xFFFFFFFF, message);
    }
     
    stock CasinoGetPlayerMoney(playerid) {
            return GetPlayerMoney(playerid);
    }


Downloads:

GrimCasino.inc SolidFiles V1.0.0.2 PasteBin
Example: http://pastebin.com/MAhK0zhh

Any questions feel free to ask
__________________

Last edited by Grimrandomer; 09/02/2014 at 10:14 AM. Reason: Hopefully fixed
Grimrandomer is online now   Reply With Quote
Old 09/02/2014, 07:40 AM   #2
Aerotactics
High-roller
 
Aerotactics's Avatar
 
Join Date: Jun 2013
Location: return 0;
Posts: 1,084
Reputation: 112
Default Re: gCasino - Scripted Casino's

This is beautiful! Im building an RP server and would love this include! My suggestion to you is add more games of course! Suggestions:
Track Betting (Like in singleplayer)
Blackjack
Texas Hold 'em

That's just off the top of my head. MAy I ask you send me a PM with each new update? That would be amazing!

EDIT
More suggestions (maybe too complicated):
7-card no peek
Slots (how could I forget that? I always lose my money on those things...)
Roulette(?) I never was a fan of it though.
Aerotactics is offline   Reply With Quote
Old 09/02/2014, 07:51 AM   #3
Lordzy
High-roller
 
Join Date: Mar 2012
Location: NetherRealm
Posts: 2,777
Reputation: 1131
Default Re: gCasino - Scripted Casino's

Looks great! I suggest you to improve the textdraw colors and also make those column separator's color to a custom one. Overall, it's really good.
__________________
Currently inactive - I don't play at any SA-MP servers nor work on anything in PAWN for now. The projects that I've done so far in PAWN, which requires updates will be taking some time.
Lordzy is offline   Reply With Quote
Old 09/02/2014, 07:58 AM   #4
Grimrandomer
Big Clucker
 
Grimrandomer's Avatar
 
Join Date: Dec 2011
Posts: 125
Reputation: 54
Default Re: gCasino - Scripted Casino's

Thanks


If I get some time ill work on the other casino games.

About the download, its the source as a pastebin, ill upload the file, and update the thread, thanks
__________________
Grimrandomer is online now   Reply With Quote
Old 09/02/2014, 08:02 AM   #5
Aerotactics
High-roller
 
Aerotactics's Avatar
 
Join Date: Jun 2013
Location: return 0;
Posts: 1,084
Reputation: 112
Default Re: gCasino - Scripted Casino's

Quote:
Originally Posted by Grimrandomer View Post
Thanks


If I get some time ill work on the other casino games.

About the download, its the source as a pastebin, ill upload the file, and update the thread, thanks
Yeah, I figured out how to "compile" it, Im dumb lol

EDIT
After setting it up I'm getting these errors:
Code:
C:\Users\AEROTA~1\Desktop\LS-RP\pawno\include\GrimCasino.inc(1172) : warning 201: redefinition of constant/macro (symbol "OnGameModeInit")
C:\Users\AEROTA~1\Desktop\LS-RP\pawno\include\GrimCasino.inc(1173) : warning 201: redefinition of constant/macro (symbol "OnPlayerConnect")
C:\Users\Aerotactics' PC\Desktop\LS-RP\gamemodes\LS-RP.pwn(108) : error 017: undefined symbol "useDynamicObj"
C:\Users\Aerotactics' PC\Desktop\LS-RP\gamemodes\LS-RP.pwn(108) : warning 215: expression has no effect
C:\Users\Aerotactics' PC\Desktop\LS-RP\gamemodes\LS-RP.pwn(108) : error 001: expected token: ";", but found ")"
C:\Users\Aerotactics' PC\Desktop\LS-RP\gamemodes\LS-RP.pwn(108) : error 029: invalid expression, assumed zero
C:\Users\Aerotactics' PC\Desktop\LS-RP\gamemodes\LS-RP.pwn(108) : fatal error 107: too many error messages on one line
And line 108 in my script is:
Code:
CreateCasinoMachine(CASINO_MACHINE_POKER,1565.4,-2330.8,13.2, 0, 0, 0, useDynamicObj=1);
And it's under OnGamemodeInit.

EDIT 2
I fixed line 108 by removing "useDynamicObj=1" but I must point out the other errors to you.

EDIT 3
Anytime I try to join my server I'm DCed and this hasnt happened without the plugin. I'm gonna have to remove it for now until all the bugs are fixed. Keep me posted though!
Aerotactics is offline   Reply With Quote
Old 09/02/2014, 08:04 AM   #6
Grimrandomer
Big Clucker
 
Grimrandomer's Avatar
 
Join Date: Dec 2011
Posts: 125
Reputation: 54
Default Re: gCasino - Scripted Casino's

Its ok I should have uploaded it as a file anyway

The hardest bit about this was the checking of a players "hand" for poker:

Code:
cPoker_checkGame(playerid) {
	
	new suit_a = cPoker_checkGameContains(playerid, CARD_ACE, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
	////printf("suit_a: %i", suit_a);
	new suit_2 = cPoker_checkGameContains(playerid, 2, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
	////printf("suit_2: %i", suit_2);
	new suit_3 = cPoker_checkGameContains(playerid, 3, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
	////printf("suit_3: %i", suit_3);
	new suit_4 = cPoker_checkGameContains(playerid, 4, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
	////printf("suit_4: %i", suit_4);
	new suit_5 = cPoker_checkGameContains(playerid, 5, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
	////printf("suit_5: %i", suit_5);

	if (c_suitsEqual(suit_a,suit_2,suit_3,suit_4,suit_5)) {
		////print("CHECK_ROYALFLUSH");
		return CHECK_ROYALFLUSH;
	}
	
	new suit_10 = cPoker_checkGameContains(playerid, 10, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
	////printf("suit_10: %i", suit_10);
	new suit_j = cPoker_checkGameContains(playerid, CARD_JACK, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
	////printf("suit_j: %i", suit_j);
	new suit_q = cPoker_checkGameContains(playerid, CARD_QUEEN, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
	////printf("suit_q: %i", suit_q);
	new suit_k = cPoker_checkGameContains(playerid, CARD_KING, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
	////printf("suit_k: %i", suit_k);
	
	if (c_suitsEqual(suit_10,suit_j,suit_q,suit_k,suit_a)) {
		////print("CHECK_ROYALFLUSH");
		return CHECK_ROYALFLUSH;
	}
	
	new suit_6 = cPoker_checkGameContains(playerid, 6, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
	////printf("suit_6: %i", suit_6);
	new suit_7 = cPoker_checkGameContains(playerid, 7, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
	////printf("suit_7: %i", suit_7);
	new suit_8 = cPoker_checkGameContains(playerid, 8, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
	////printf("suit_8: %i", suit_8);
	new suit_9 = cPoker_checkGameContains(playerid, 9, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
	////printf("suit_9: %i", suit_9);
	
	////print("CHECK_STRAIGHTFLUSH - START");
	if (c_suitsEqual(suit_2,suit_3,suit_4,suit_5,suit_6)) {
		return CHECK_STRAIGHTFLUSH;
	} else if (c_suitsEqual(suit_3,suit_4,suit_5,suit_6,suit_7)) {
		return CHECK_STRAIGHTFLUSH;
	} else if (c_suitsEqual(suit_4,suit_5,suit_6,suit_7,suit_8)) {
		return CHECK_STRAIGHTFLUSH;
	} else if (c_suitsEqual(suit_5,suit_6,suit_7,suit_8,suit_9)) {
		return CHECK_STRAIGHTFLUSH;
	} else if (c_suitsEqual(suit_6,suit_7,suit_8,suit_9,suit_10)) {
		return CHECK_STRAIGHTFLUSH;
	} else if (c_suitsEqual(suit_7,suit_8,suit_9,suit_10,suit_j)) {
		return CHECK_STRAIGHTFLUSH;
	} else if (c_suitsEqual(suit_8,suit_9,suit_10,suit_j,suit_q)) {
		return CHECK_STRAIGHTFLUSH;
	} else if (c_suitsEqual(suit_9,suit_10,suit_j,suit_q,suit_k)) {
		return CHECK_STRAIGHTFLUSH;
	}
	////print("CHECK_STRAIGHTFLUSH - END");
	
	new countC[13];
	////print("CHECK_FOUROFAKIND - START");
	for (new _c=0; _c<5; _c++) {
		new _n = cPokerGame[playerid][_c][1];
		////printf("_n: %i", _n);
		countC[_n-1]++;
		if (countC[_n-1]==4) {
			////print("CHECK_FOUROFAKIND");
			return CHECK_FOUROFAKIND;
		}
	}
	////print("CHECK_FOUROFAKIND - END");
	
	////print("CHECK_FULLHOUSE - START");
	for (new _card=1; _card<=13; _card++) {
		if (countC[_card-1]==3) {
			for (new _subCard=1; _subCard<=13; _subCard++) {
				if (_subCard != _card) {
					if (countC[_subCard-1]==2) {
						//print("CHECK_FULLHOUSE");
						return CHECK_FULLHOUSE;
					}
				}
			}
		}
	}
	////print("CHECK_FULLHOUSE - END");
	
	if (c_Equal(cPokerGame[playerid][0][0],cPokerGame[playerid][1][0],cPokerGame[playerid][2][0],cPokerGame[playerid][3][0],cPokerGame[playerid][4][0])) {
		////print("CHECK_FLUSH");
		return CHECK_FLUSH;
	}

	////print("CHECK_STRAIGHT - START");
	if (c_anySuits(suit_a,suit_2,suit_3,suit_4,suit_5)) {
		return CHECK_STRAIGHT;
	} else if (c_anySuits(suit_2,suit_3,suit_4,suit_5,suit_6)) {
		return CHECK_STRAIGHT;
	} else if (c_anySuits(suit_3,suit_4,suit_5,suit_6,suit_7)) {
		return CHECK_STRAIGHT;
	} else if (c_anySuits(suit_4,suit_5,suit_6,suit_7,suit_8)) {
		return CHECK_STRAIGHT;
	} else if (c_anySuits(suit_5,suit_6,suit_7,suit_8,suit_9)) {
		return CHECK_STRAIGHT;
	} else if (c_anySuits(suit_6,suit_7,suit_8,suit_9,suit_10)) {
		return CHECK_STRAIGHT;
	} else if (c_anySuits(suit_7,suit_8,suit_9,suit_10,suit_j)) {
		return CHECK_STRAIGHT;
	} else if (c_anySuits(suit_8,suit_9,suit_10,suit_j,suit_q)) {
		return CHECK_STRAIGHT;
	} else if (c_anySuits(suit_9,suit_10,suit_j,suit_q,suit_k)) {
		return CHECK_STRAIGHT;
	} else if (c_anySuits(suit_10,suit_j,suit_q,suit_k,suit_a)) {
		return CHECK_STRAIGHT;
	} 
	////print("CHECK_STRAIGHT - END");
	
	////print("CHECK_THREEOFAKIND - START");
	for (new _card=1; _card<=13; _card++) {
		if (countC[_card-1]==3) {
			for (new _subCard=1; _subCard<=13; _subCard++) {
				if (_subCard != _card) {
					if (countC[_subCard-1]==1) {
						for (new _subSubCard=1; _subSubCard<=13; _subSubCard++) {
							if (_subCard != _card && _subSubCard != _card && _subCard != _subSubCard) {
								if (countC[_subSubCard-1]==1) {
									return CHECK_THREEOFAKIND;
								}
							}
						}
					}
				}
			}
		}
	}
	////print("CHECK_THREEOFAKIND - END");
	
	////print("CHECK_TWOPAIRS - START");
	for (new _card=1; _card<=13; _card++) {
		////printf("_card: %i", _card);
		if (countC[_card-1]==2) {
			////printf("countC[_card-1]: %i", countC[_card-1]);
			for (new _subCard=1; _subCard<=13; _subCard++) {
				////printf("_subCard: %i", _subCard);
				if (_subCard != _card) {
					if (countC[_subCard-1]==2) {
						////printf("countC[_subCard-1]: %i", countC[_subCard-1]);
						return CHECK_TWOPAIRS;
					}
				}
			}
		}
	}
	////print("CHECK_TWOPAIRS - END");
	
	////print("CHECK_JACKORBETTER - START");
	for (new _c=0; _c<5; _c++) {
		new _c_v = cPokerGame[playerid][_c][1];
		if (_c_v >= CARD_JACK || _c_v == CARD_ACE) {
			return CHECK_JACKORBETTER;
		}
	}
	////print("CHECK_JACKORBETTER - END");
	
	return CHECK_NONE;
}
__________________
Grimrandomer is online now   Reply With Quote
Old 09/02/2014, 08:24 AM   #7
audriuxxx
Banned
 
Join Date: Jan 2013
Posts: 738
Reputation: 0
Default Re: gCasino - Scripted Casino's

Code:
warning 201: redefinition of constant/macro (symbol "OnGameModeInit")
warning 201: redefinition of constant/macro (symbol "OnPlayerConnect")
warning 201: redefinition of constant/macro (symbol "OnPlayerClickTextDraw")
warning 201: redefinition of constant/macro (symbol "OnPlayerClickPlayerTextDraw")
audriuxxx is offline   Reply With Quote
Old 09/02/2014, 08:35 AM   #8
Grimrandomer
Big Clucker
 
Grimrandomer's Avatar
 
Join Date: Dec 2011
Posts: 125
Reputation: 54
Default Re: gCasino - Scripted Casino's

Quote:
Originally Posted by audriuxxx View Post
Code:
warning 201: redefinition of constant/macro (symbol "OnGameModeInit")
warning 201: redefinition of constant/macro (symbol "OnPlayerConnect")
warning 201: redefinition of constant/macro (symbol "OnPlayerClickTextDraw")
warning 201: redefinition of constant/macro (symbol "OnPlayerClickPlayerTextDraw")
Hmm, Worked on my test game mode, Whats the code inside your OnGameModeInit?
__________________
Grimrandomer is online now   Reply With Quote
Old 09/02/2014, 08:54 AM   #9
AIped
Gangsta
 
AIped's Avatar
 
Join Date: Feb 2011
Location: Netherlands
Posts: 782
Reputation: 46
Default Re: gCasino - Scripted Casino's

simple functions good!
AIped is offline   Reply With Quote
Old 09/02/2014, 09:13 AM   #10
zSuYaNw
Godfather
 
zSuYaNw's Avatar
 
Join Date: Apr 2010
Location: Santa Catarina
Posts: 6,843
Reputation: 660
Default Re: gCasino - Scripted Casino's

Very nice well

PS: what's the name of the song?
zSuYaNw is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] Scripted Fire Sniperwolves Includes 66 02/05/2017 09:09 AM
Want Something Scripted? andrew4699 Help Archive 1 12/07/2011 02:57 AM
[REQ] [FS] Scripted/un-scripted - AddStaticVehicleEx Jack_Leslie Help Archive 3 08/05/2011 09:16 AM
Scripted Top View Joe Staff Help Archive 20 13/01/2011 02:19 AM
Scripted Smoke playbox12 Help Archive 7 09/05/2010 06:22 PM


All times are GMT. The time now is 05:00 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.