Advertisement
Guest User

Untitled

a guest
Aug 30th, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.77 KB | None | 0 0
  1. //casino slot machine game by Tortilla(Jakub C.)
  2. //needed includes and plugins: zcmd, sscanf
  3. //credits: Unknown - function CreateSprite isn't mine, i found it in some files on my computer, but i think it's created by Ipleomax
  4.  
  5. #define SLOT_CHERRY         0
  6. #define SLOT_BAR1           1
  7. #define SLOT_BAR2           2
  8. #define SLOT_BELL           3
  9. #define SLOT_GRAPES         4
  10. #define SLOT_69             5
  11.  
  12. #define LANG_POL            0
  13. #define LANG_ENG            1
  14.  
  15. new Text:casino_card_id[MAX_PLAYERS][3];
  16. new casino_card_types[6][32] =
  17. {
  18.     "LD_SLOT:cherry", "LD_SLOT:bar1_o", "LD_SLOT:bar2_o", "LD_SLOT:bell", "LD_SLOT:grapes", "LD_SLOT:r_69"
  19. };
  20. new casino_typed_type[3];
  21. new Text:casino_card_bg;
  22. new bool:casino_player_playing[MAX_PLAYERS];
  23. new bool:casino_player_pulled[MAX_PLAYERS];
  24. new casino_timer[2];
  25. new casino_language = LANG_ENG;
  26.  
  27. Text:CreateSprite(Float:X,Float:Y,name_[],Float:Width,Float:Height)
  28. {
  29.     new Text:RetSprite;
  30.     RetSprite = TextDrawCreate(X, Y, name_); // Text is txdfile:texture
  31.     TextDrawFont(RetSprite, 4); // Font ID 4 is the sprite draw font
  32.     TextDrawColor(RetSprite,0xFFFFFFFF);
  33.     TextDrawTextSize(RetSprite,Width,Height); // Text size is the Width:Height
  34.     return RetSprite;
  35. }
  36.  
  37. stock casino_create_textdraw()
  38. {
  39.     casino_card_bg = TextDrawCreate(446.158111, 265.750061, "usebox");
  40.     TextDrawLetterSize(casino_card_bg, 0.000000, 7.868870);
  41.     TextDrawTextSize(casino_card_bg, 187.751098, 0.000000);
  42.     TextDrawAlignment(casino_card_bg, 1);
  43.     TextDrawColor(casino_card_bg, 0);
  44.     TextDrawUseBox(casino_card_bg, true);
  45.     TextDrawBoxColor(casino_card_bg, 102);
  46.     TextDrawSetShadow(casino_card_bg, 0);
  47.     TextDrawSetOutline(casino_card_bg, 0);
  48.     TextDrawFont(casino_card_bg, 0);
  49.    
  50.     foreachEx(playerid, MAX_PLAYERS)
  51.     {
  52.         casino_card_id[playerid][0]         =       CreateSprite(193.967773, 272.416656,"LD_SLOT:cherry",73.557830, 78.750000);
  53.         casino_card_id[playerid][1]         =       CreateSprite(279.707305, 272.416656,"LD_SLOT:cherry",73.557830, 78.750000);
  54.         casino_card_id[playerid][2]         =       CreateSprite(365.915557, 272.416656,"LD_SLOT:cherry",73.557830, 78.750000);
  55.     }
  56. }
  57.  
  58. stock casino_OnPlayerUpdate(playerid)
  59. {
  60.     if(casino_player_playing[playerid])
  61.     {
  62.         new keysa, uda, lra;
  63.         GetPlayerKeys(playerid, keysa, uda, lra);
  64.         if(uda > 0 && !casino_player_pulled[playerid])
  65.         {
  66.             casino_player_pulled[playerid] = true;
  67.             casino_timer[0] = SetTimerEx("casino_timer_random", 50, true, "d", playerid);
  68.             casino_timer[1] = SetTimerEx("casino_timer_end", 5000, false, "d", playerid);
  69.             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.");
  70.         }
  71.     }
  72. }
  73.  
  74. CallBack:casino_timer_random(playerid)
  75. {
  76.     new card_id = random(3);
  77.     new card_type = random(6);
  78.     TextDrawSetString(casino_card_id[playerid][card_id], casino_card_types[card_type]);
  79.     casino_typed_type[card_id] = card_type;
  80.     return 1;
  81. }
  82.  
  83. CallBack:casino_timer_end(playerid)
  84. {
  85.     KillTimer(casino_timer[0]);
  86.     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])
  87.     {
  88.         GiveMoney(playerid, 50 * 2);
  89.         if(casino_language == LANG_ENG) TextDrawSetString(Text:TextDrawMainInfo[playerid], "You have won in this game one hundred bucks, try again, pull the leaver down.");
  90.     }
  91.     else
  92.     {
  93.         GiveMoney(playerid, -50);
  94.         if(casino_language == LANG_ENG) TextDrawSetString(Text:TextDrawMainInfo[playerid], "You have lose in this game fifty bucks, try again, pull the leaver down.");
  95.     }
  96.     foreachEx(card_id, 3)
  97.     {
  98.         casino_typed_type[card_id] = 0;
  99.     }
  100.     casino_player_pulled[playerid] = false;
  101.     return 1;
  102. }
  103.  
  104. stock casino_OnPlayerDisconnect(playerid)
  105. {
  106.     casino_player_playing[playerid] = false;
  107.     casino_player_pulled[playerid] = false;
  108. }
  109.  
  110. CallBack:casino_startGame(playerid)
  111. {
  112.     TogglePlayerControllable(playerid, 0);
  113.     TextDrawShowForPlayer(playerid, casino_card_bg);
  114.     TextDrawShowForPlayer(playerid, casino_card_id[playerid][0]);
  115.     TextDrawShowForPlayer(playerid, casino_card_id[playerid][1]);
  116.     TextDrawShowForPlayer(playerid, casino_card_id[playerid][2]);
  117.     TextDrawShowForPlayer(playerid, TextDrawMainInfo[playerid]);
  118.     if(casino_language == LANG_ENG) TextDrawSetString(Text:TextDrawMainInfo[playerid], "Press ~down~ to pull down the leaver.");
  119.     casino_player_playing[playerid] = true;
  120.     return 1;
  121. }
  122.  
  123. CallBack:casino_endGame(playerid)
  124. {
  125.     TogglePlayerControllable(playerid, 1);
  126.     casino_player_playing[playerid] = false;
  127.     TextDrawHideForPlayer(playerid, casino_card_bg);
  128.     TextDrawHideForPlayer(playerid, TextDrawMainInfo[playerid]);
  129.     foreachEx(card, 3)
  130.     {
  131.         TextDrawHideForPlayer(playerid, casino_card_id[playerid][card]);
  132.     }
  133.     return 1;
  134. }
  135.  
  136. CMD:casino(playerid, params[])
  137. {
  138.     if(!casino_player_playing[playerid]) casino_startGame(playerid);
  139.     else casino_endGame(playerid);
  140.     return 1;
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement