09.02.2014, 05:49
(
Last edited by Grimrandomer; 30/12/2018 at 08:18 PM.
Reason: Hopefully fixed
)
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:
To remove a casino object:
Other functions:
Callbacks:
Note:
So this can work with any existing anti-cheats, the following must be added in your code:
This allows you to control how the players money is checked.
Example:
Downloads:
GrimCasino.inc SolidFiles V1.0.0.2 PasteBin
Example: http://pastebin.com/MAhK0zhh
Any questions feel free to ask
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
pawn Code:
RemoveCasinoMachine(_machineID); //Safely destroy a casino object
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
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"
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);
}
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