Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //casino slot machine game by Tortilla(Jakub C.)
- //needed includes and plugins: zcmd, sscanf
- //credits: Unknown - function CreateSprite isn't mine, i found it in some files on my computer, but i think it's created by Ipleomax
- #define SLOT_CHERRY 0
- #define SLOT_BAR1 1
- #define SLOT_BAR2 2
- #define SLOT_BELL 3
- #define SLOT_GRAPES 4
- #define SLOT_69 5
- #define LANG_POL 0
- #define LANG_ENG 1
- new Text:casino_card_id[MAX_PLAYERS][3];
- new casino_card_types[6][32] =
- {
- "LD_SLOT:cherry", "LD_SLOT:bar1_o", "LD_SLOT:bar2_o", "LD_SLOT:bell", "LD_SLOT:grapes", "LD_SLOT:r_69"
- };
- new casino_typed_type[3];
- new Text:casino_card_bg;
- new bool:casino_player_playing[MAX_PLAYERS];
- new bool:casino_player_pulled[MAX_PLAYERS];
- new casino_timer[2];
- new casino_language = LANG_ENG;
- Text:CreateSprite(Float:X,Float:Y,name_[],Float:Width,Float:Height)
- {
- new Text:RetSprite;
- RetSprite = TextDrawCreate(X, Y, name_); // Text is txdfile:texture
- TextDrawFont(RetSprite, 4); // Font ID 4 is the sprite draw font
- TextDrawColor(RetSprite,0xFFFFFFFF);
- TextDrawTextSize(RetSprite,Width,Height); // Text size is the Width:Height
- return RetSprite;
- }
- stock casino_create_textdraw()
- {
- casino_card_bg = TextDrawCreate(446.158111, 265.750061, "usebox");
- TextDrawLetterSize(casino_card_bg, 0.000000, 7.868870);
- TextDrawTextSize(casino_card_bg, 187.751098, 0.000000);
- TextDrawAlignment(casino_card_bg, 1);
- TextDrawColor(casino_card_bg, 0);
- TextDrawUseBox(casino_card_bg, true);
- TextDrawBoxColor(casino_card_bg, 102);
- TextDrawSetShadow(casino_card_bg, 0);
- TextDrawSetOutline(casino_card_bg, 0);
- TextDrawFont(casino_card_bg, 0);
- foreachEx(playerid, MAX_PLAYERS)
- {
- casino_card_id[playerid][0] = CreateSprite(193.967773, 272.416656,"LD_SLOT:cherry",73.557830, 78.750000);
- casino_card_id[playerid][1] = CreateSprite(279.707305, 272.416656,"LD_SLOT:cherry",73.557830, 78.750000);
- casino_card_id[playerid][2] = CreateSprite(365.915557, 272.416656,"LD_SLOT:cherry",73.557830, 78.750000);
- }
- }
- stock casino_OnPlayerUpdate(playerid)
- {
- if(casino_player_playing[playerid])
- {
- new keysa, uda, lra;
- GetPlayerKeys(playerid, keysa, uda, lra);
- if(uda > 0 && !casino_player_pulled[playerid])
- {
- casino_player_pulled[playerid] = true;
- casino_timer[0] = SetTimerEx("casino_timer_random", 50, true, "d", playerid);
- casino_timer[1] = SetTimerEx("casino_timer_end", 5000, false, "d", playerid);
- if(casino_language == LANG_ENG) TextDrawSetString(Text:TextDrawMainInfo[playerid], "You pulled down the leaver, wait couple of seconds until random ends to check who is the winner.");
- }
- }
- }
- CallBack:casino_timer_random(playerid)
- {
- new card_id = random(3);
- new card_type = random(6);
- TextDrawSetString(casino_card_id[playerid][card_id], casino_card_types[card_type]);
- casino_typed_type[card_id] = card_type;
- return 1;
- }
- CallBack:casino_timer_end(playerid)
- {
- KillTimer(casino_timer[0]);
- if(casino_typed_type[0] == casino_typed_type[1] && casino_typed_type[1] == casino_typed_type[2] && casino_typed_type[0] == casino_typed_type[2])
- {
- GiveMoney(playerid, 50 * 2);
- if(casino_language == LANG_ENG) TextDrawSetString(Text:TextDrawMainInfo[playerid], "You have won in this game one hundred bucks, try again, pull the leaver down.");
- }
- else
- {
- GiveMoney(playerid, -50);
- if(casino_language == LANG_ENG) TextDrawSetString(Text:TextDrawMainInfo[playerid], "You have lose in this game fifty bucks, try again, pull the leaver down.");
- }
- foreachEx(card_id, 3)
- {
- casino_typed_type[card_id] = 0;
- }
- casino_player_pulled[playerid] = false;
- return 1;
- }
- stock casino_OnPlayerDisconnect(playerid)
- {
- casino_player_playing[playerid] = false;
- casino_player_pulled[playerid] = false;
- }
- CallBack:casino_startGame(playerid)
- {
- TogglePlayerControllable(playerid, 0);
- TextDrawShowForPlayer(playerid, casino_card_bg);
- TextDrawShowForPlayer(playerid, casino_card_id[playerid][0]);
- TextDrawShowForPlayer(playerid, casino_card_id[playerid][1]);
- TextDrawShowForPlayer(playerid, casino_card_id[playerid][2]);
- TextDrawShowForPlayer(playerid, TextDrawMainInfo[playerid]);
- if(casino_language == LANG_ENG) TextDrawSetString(Text:TextDrawMainInfo[playerid], "Press ~down~ to pull down the leaver.");
- casino_player_playing[playerid] = true;
- return 1;
- }
- CallBack:casino_endGame(playerid)
- {
- TogglePlayerControllable(playerid, 1);
- casino_player_playing[playerid] = false;
- TextDrawHideForPlayer(playerid, casino_card_bg);
- TextDrawHideForPlayer(playerid, TextDrawMainInfo[playerid]);
- foreachEx(card, 3)
- {
- TextDrawHideForPlayer(playerid, casino_card_id[playerid][card]);
- }
- return 1;
- }
- CMD:casino(playerid, params[])
- {
- if(!casino_player_playing[playerid]) casino_startGame(playerid);
- else casino_endGame(playerid);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement