[Include] gCasino - Scripted Casino's
#1

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:
http://www.youtube.com/watch?v=Fe8FEUoXDmE

To add a new casino game object:
pawn 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:
pawn Code:
RemoveCasinoMachine(_machineID); //Safely destroy a casino object
Other functions:
pawn 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:
pawn 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:
pawn Code:
stock CasinoGetPlayerMoney(playerid) {
    return GetPlayerMoney(playerid);
}
This allows you to control how the players money is checked.

Example:

pawn 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
Reply


Messages In This Thread
gCasino - Scripted Casino's - by Grimrandomer - 09.02.2014, 05:49
Re: gCasino - Scripted Casino's - by Aerotactics - 09.02.2014, 06:40
Re: gCasino - Scripted Casino's - by Lordzy - 09.02.2014, 06:51
Re: gCasino - Scripted Casino's - by Grimrandomer - 09.02.2014, 06:58
Re: gCasino - Scripted Casino's - by Aerotactics - 09.02.2014, 07:02
Re: gCasino - Scripted Casino's - by Grimrandomer - 09.02.2014, 07:04
Re: gCasino - Scripted Casino's - by audriuxxx - 09.02.2014, 07:24
Re: gCasino - Scripted Casino's - by Grimrandomer - 09.02.2014, 07:35
Re: gCasino - Scripted Casino's - by AIped - 09.02.2014, 07:54
Re: gCasino - Scripted Casino's - by zSuYaNw - 09.02.2014, 08:13
Re: gCasino - Scripted Casino's - by Patrick - 09.02.2014, 08:50
Re: gCasino - Scripted Casino's - by Grimrandomer - 09.02.2014, 09:15
Re: gCasino - Scripted Casino's - by Aerotactics - 09.02.2014, 09:34
Re: gCasino - Scripted Casino's - by Grimrandomer - 09.02.2014, 09:58
Re: gCasino - Scripted Casino's - by audriuxxx - 09.02.2014, 11:25
Re: gCasino - Scripted Casino's - by audriuxxx - 09.02.2014, 12:30
Re: gCasino - Scripted Casino's - by PT - 09.02.2014, 12:35
Re: gCasino - Scripted Casino's - by Grimrandomer - 09.02.2014, 14:29
Re: gCasino - Scripted Casino's - by audriuxxx - 09.02.2014, 14:48
Re: gCasino - Scripted Casino's - by Grimrandomer - 09.02.2014, 14:58
Re: gCasino - Scripted Casino's - by Pottus - 09.02.2014, 15:30
Re: gCasino - Scripted Casino's - by audriuxxx - 09.02.2014, 15:58
Re: gCasino - Scripted Casino's - by Aerotactics - 09.02.2014, 21:14
Re: gCasino - Scripted Casino's - by Grimrandomer - 09.02.2014, 21:29
Re: gCasino - Scripted Casino's - by Aerotactics - 09.02.2014, 22:05
Re: gCasino - Scripted Casino's - by Kenshin869 - 10.02.2014, 02:40
Re: gCasino - Scripted Casino's - by Grimrandomer - 10.02.2014, 09:26
Re: gCasino - Scripted Casino's - by audriuxxx - 10.02.2014, 17:16
Re: gCasino - Scripted Casino's - by Aerotactics - 13.02.2014, 07:49
Re: gCasino - Scripted Casino's - by PSYCHOBABYKILLA - 10.04.2015, 04:26
Re : gCasino - Scripted Casino's - by tysanio - 10.08.2015, 04:48
Re: gCasino - Scripted Casino's - by rt-2 - 07.09.2016, 02:59
Re: gCasino - Scripted Casino's - by Spmn - 07.09.2016, 13:12
Re: gCasino - Scripted Casino's - by rt-2 - 07.09.2016, 23:03

Forum Jump:


Users browsing this thread: 8 Guest(s)