Advertisement
Zsolesszka

[FS]Poker SA-MP 0.3eRC5

Mar 22nd, 2012
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 22.38 KB | None | 0 0
  1. /*
  2.     Poker filterscript by.: Zsolesszka 
  3. -   2012.03.25
  4.     - A few small things corrected, RandomCard, /poker cmd etc..
  5.     - Press Esc ExitPoker
  6.  
  7. -   2012.03.22 0.3eRC5
  8.     - Use script new native function PlayerText:CreatePlayerTextDraw etc..
  9.  
  10. -   2012.03.22
  11.     - Add exit textdraw, change background textdraw, bet textdraw, modified hold textdraw
  12.     - 31 global textdraw OnFilterscriptInit, per player textdraw 7  2048 max textdraw (2048 - 31)/7 =  ~288 max player slot
  13.     - etc..
  14.    
  15. -   2012.03.20 Update Poker [FS] Beta version
  16.         samp 0.3e RC4 use new function
  17.         native TextDrawSetSelectable(Text:text, set); // the default is 0 (non-selectable)
  18.         native SelectTextDraw(playerid, hovercolor); // enables the mouse so the player can select a textdraw
  19.         native CancelSelectTextDraw(playerid);  // cancel textdraw selection with the mouse
  20.         forward OnPlayerClickTextDraw(playerid, Text:clickedid);
  21.  
  22. -   2012.01.15 - 2012.01.27 (first release Poker script)
  23.    
  24.     Thank you SA-MP team.
  25. */
  26.  
  27. #include <a_samp>
  28.  
  29. #define POKERLAPS 52 // 4 * 13 laps (2, 3 ... K, A
  30. enum
  31. {
  32.     TWO = 2,
  33.     THREE,
  34.     FOUR,
  35.     FIVE,
  36.     SIX,
  37.     SEVEN,
  38.     EIGHT,
  39.     NINE,
  40.     TEN,
  41.     JACK,
  42.     QUEEN,
  43.     KING,
  44.     ACE
  45. };
  46.  
  47. enum
  48. {
  49.     HIGH_CARD = 0,
  50.     ONE_PAIR,
  51.     TWO_PAIR,
  52.     THREE_OF_A_KIND,
  53.     STRAIGHT,
  54.     FLUSH,
  55.     FULL_HOUSE,
  56.     FOUR_OF_A_KIND,
  57.     STRAIGHT_FLUSH,
  58.     ROYAL_FLUSH
  59. };
  60.  
  61. new
  62.     LD_POKE[POKERLAPS][] =
  63. {
  64.     { "LD_POKE:cd2c" }, { "LD_POKE:cd3c" }, { "LD_POKE:cd4c" }, { "LD_POKE:cd5c" }, { "LD_POKE:cd6c" }, { "LD_POKE:cd7c" }, { "LD_POKE:cd8c" },
  65.     { "LD_POKE:cd9c" }, { "LD_POKE:cd10c" }, { "LD_POKE:cd11c" }, { "LD_POKE:cd12c" }, { "LD_POKE:cd13c" }, { "LD_POKE:cd1c" },
  66.  
  67.     { "LD_POKE:cd2d" }, { "LD_POKE:cd3d" }, { "LD_POKE:cd4d" }, { "LD_POKE:cd5d" }, { "LD_POKE:cd6d" }, { "LD_POKE:cd7d" }, { "LD_POKE:cd8d" },
  68.     { "LD_POKE:cd9d" }, { "LD_POKE:cd10d" }, { "LD_POKE:cd11d" }, { "LD_POKE:cd12d" }, { "LD_POKE:cd13d" }, { "LD_POKE:cd1d" },
  69.  
  70.     { "LD_POKE:cd2h" }, { "LD_POKE:cd3h" }, { "LD_POKE:cd4h" }, { "LD_POKE:cd5h" }, { "LD_POKE:cd6h" }, { "LD_POKE:cd7h" }, { "LD_POKE:cd8h" },
  71.     { "LD_POKE:cd9h" }, { "LD_POKE:cd10h" }, { "LD_POKE:cd11h" }, { "LD_POKE:cd12h" }, { "LD_POKE:cd13h" }, { "LD_POKE:cd1h" },
  72.  
  73.     { "LD_POKE:cd2s" }, { "LD_POKE:cd3s" }, { "LD_POKE:cd4s" }, { "LD_POKE:cd5s" }, { "LD_POKE:cd6s" }, { "LD_POKE:cd7s" }, { "LD_POKE:cd8s" },
  74.     { "LD_POKE:cd9s" }, { "LD_POKE:cd10s" }, { "LD_POKE:cd11s" }, { "LD_POKE:cd12s" }, { "LD_POKE:cd13s" }, { "LD_POKE:cd1s" }
  75. };
  76.  
  77. new
  78.     Card_Value[POKERLAPS] =
  79. {
  80.     TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE,
  81.     TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE,
  82.     TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE,
  83.     TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE
  84. };
  85.  
  86. new
  87.     Bynary_Mask[POKERLAPS] =
  88. {
  89.     1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000,
  90.     1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000,
  91.     1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000,
  92.     1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000
  93. //      2   3   4   5   6   7   8   9   T   J   Q   K   A
  94. };
  95.  
  96. #define TREFF       0b1 //1 // "clubs"
  97. #define KARO        0b10 //2 // “diamonds”
  98. #define KOR         0b100 //4 // “hearts”
  99. #define PIKK        0b1000 //8 // “spades” or “shields”
  100.  
  101. new
  102.     Color_Mask[POKERLAPS] =
  103. {
  104.     TREFF, TREFF, TREFF, TREFF, TREFF, TREFF, TREFF, TREFF, TREFF, TREFF, TREFF, TREFF, TREFF,  // 1 = 0b10
  105.     KARO, KARO, KARO, KARO, KARO, KARO, KARO, KARO, KARO, KARO, KARO, KARO, KARO,       // 2 = 0b100
  106.     KOR, KOR, KOR, KOR, KOR, KOR, KOR, KOR, KOR, KOR, KOR, KOR, KOR,                        // 4 = 0b1000
  107.     PIKK, PIKK, PIKK, PIKK, PIKK, PIKK, PIKK, PIKK, PIKK, PIKK, PIKK, PIKK, PIKK                    // 8 = 0b10000
  108. };
  109.  
  110. new
  111.     pot[] = { 0, 0, 2, 3, 4, 5, 7, 20, 50, 250 };
  112.  
  113. new
  114.     PlayerText:Start[MAX_PLAYERS];
  115.  
  116. #define BACKGROUND          Start[playerid]
  117. #define CARDSTEXT               Start[playerid] + PlayerText:1 // 2, 3, 4, 5        [5]
  118. #define HOLDSTEXT               Start[playerid] + PlayerText:6 // 7, 8, 9, 10       [5]
  119. #define WIN_TEXT                Start[playerid] + PlayerText:11
  120. #define WINTEXT             Start[playerid] + PlayerText:12
  121. #define BETCREDITTEXT           Start[playerid] + PlayerText:13
  122. #define DEALSTEXT               Start[playerid] + PlayerText:14
  123. #define ADDCOINSTEXT            Start[playerid] + PlayerText:15
  124. #define EXITPOKER               Start[playerid] + PlayerText:16
  125. #define BETTEXT             Start[playerid] + PlayerText:17
  126. #define CHANGEBACKGROUND    Start[playerid] + PlayerText:18
  127.  
  128. #define MIN_BET 5   // $5
  129. #define MAX_BET 100 // $100
  130.  
  131. #define FIRST_CLICKDEALTEXT     (false) // enable hold card
  132. #define SECOND_CLICKDEALTEXT    (true)  // disable hold card
  133. #define HOLDON      (false)
  134. #define HOLDOFF (true) // Not modified
  135.  
  136. forward TextDrawDizajn(playerid, index);
  137. forward TextDrawDizajn2(playerid, win, first_pair, second_pair);
  138.  
  139. enum
  140.     Poker_PlayerInfoEnum
  141. {
  142.     fivecards_hand[10],
  143.     bool:holdstate[5],
  144.     bool:hold,
  145.     Bet,
  146.     Credit,
  147.     LastBackGround,
  148. };
  149.  
  150. new
  151.     PP_Info[MAX_PLAYERS][Poker_PlayerInfoEnum];
  152.  
  153. new
  154.     BackGroundData[][] =
  155. {
  156.     { "LOADSUK:loadscuk" }, { "LOADSUK:loadsc9" }{ "LOADSUK:loadsc8" },
  157.     { "LOADSUK:loadsc7" }{ "LOADSUK:loadsc6" }{ "LOADSUK:loadsc5" },
  158.     { "LOADSUK:loadsc4" }{ "LOADSUK:loadsc3" }{ "LOADSUK:loadsc2" },
  159.     { "LOADSUK:loadsc14" }, { "LOADSUK:loadsc13" }, { "LOADSUK:loadsc12" },
  160.     { "LOADSUK:loadsc11" }, { "LOADSUK:loadsc10" }, { "LOADSUK:loadsc1" },
  161.     { "intro1:intro1" },    { "intro2:intro2" },    { "intro3:intro3" },
  162.     { "intro4:intro4" },    { "ld_shtr:bstars" },   { " " }
  163. };
  164.  
  165. stock
  166.     WinnText(playerid, win)
  167. {
  168.     new
  169.         str[100];
  170.     str = "~w~";
  171.     for(new i = 9; i > 1; i--)
  172.     {
  173.         if(i == win)
  174.             format(str, sizeof str, "%s~r~$%d(win)~n~~w~", str, PP_Info[playerid][Bet] * pot[i]);
  175.         else
  176.             format(str, sizeof str, "%s$%d~n~", str, PP_Info[playerid][Bet] * pot[i]);
  177.     }
  178.     PlayerTextDrawSetString(playerid, WINTEXT, str);
  179. }
  180.  
  181. stock
  182.     BetCredit(playerid)
  183. {
  184.     new
  185.         str[128];
  186.     format(str, sizeof str, "  ~g~Bet: ~w~$%d                                  ~g~Credit: ~w~$%d",
  187.                             PP_Info[playerid][Bet],
  188.                             PP_Info[playerid][Credit]);
  189.  
  190.     PlayerTextDrawSetString(playerid, BETCREDITTEXT, str);
  191. }
  192.  
  193. stock
  194.     Delete_PokerTextDraw(playerid)
  195. {
  196.     PlayerTextDrawDestroy(playerid, BACKGROUND  );
  197.     for(new i = 0; i < 5; i++)
  198.         PlayerTextDrawDestroy(playerid, CARDSTEXT + PlayerText:i);
  199.     for(new i = 0; i < 5; i++)
  200.         PlayerTextDrawDestroy(playerid, HOLDSTEXT + PlayerText:i);
  201.     PlayerTextDrawDestroy(playerid, WIN_TEXT);
  202.     PlayerTextDrawDestroy(playerid, WINTEXT);
  203.     PlayerTextDrawDestroy(playerid, BETCREDITTEXT);
  204.     PlayerTextDrawDestroy(playerid, DEALSTEXT);
  205.     PlayerTextDrawDestroy(playerid, ADDCOINSTEXT);
  206.     PlayerTextDrawDestroy(playerid, EXITPOKER);
  207.     PlayerTextDrawDestroy(playerid, BETTEXT);
  208.     PlayerTextDrawDestroy(playerid, CHANGEBACKGROUND);
  209.  
  210.     Start[playerid] = PlayerText:INVALID_TEXT_DRAW;
  211. }
  212.  
  213. stock
  214.     RandomCard(array[], size = sizeof array)
  215. {
  216.     new
  217.         bool:e[POKERLAPS] = { false, ... };
  218.     for(new p = 0; p < size; p++)
  219.     {
  220.         do
  221.             array[p] = random(POKERLAPS);
  222.         while(e[array[p]])
  223.         e[array[p]] = true;
  224.     }
  225. }
  226.  
  227. stock
  228.     Swap(&a, &b)
  229. {
  230.     new
  231.         s;
  232.     s = a;
  233.     a = b;
  234.     b = s;
  235. }
  236.  
  237. stock
  238.     strtok(const string[], &index)
  239. {
  240.     new length = strlen(string);
  241.     while ((index < length) && (string[index] <= ' '))
  242.     {
  243.         index++;
  244.     }
  245.     new offset = index;
  246.     new result[20];
  247.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  248.     {
  249.         result[index - offset] = string[index];
  250.         index++;
  251.     }
  252.     result[index - offset] = EOS;
  253.     return result;
  254. }
  255.  
  256. stock
  257.     getwin(const cards[], &One_Pair_Type, &Two_Pair_Type)
  258. {
  259.     new
  260.         i = 0,
  261.         getcolor,
  262.         straight;
  263.  
  264.     getcolor = Color_Mask[cards[0]] | Color_Mask[cards[1]] | Color_Mask[cards[2]] | Color_Mask[cards[3]] | Color_Mask[cards[4]];
  265.     getcolor = getcolor & (getcolor - 1);
  266.     straight = (Bynary_Mask[cards[0]] | Bynary_Mask[cards[1]] | Bynary_Mask[cards[2]] | Bynary_Mask[cards[3]] | Bynary_Mask[cards[4]]);
  267.     if(getcolor == 0)
  268.     {
  269.         if(straight == 7936) return ROYAL_FLUSH;
  270.         if(HasStraight(straight)) return STRAIGHT_FLUSH;
  271.         return FLUSH;
  272.     } else {
  273.         new
  274.             two_pair,
  275.             three_of_a_kind,
  276.             match[13];
  277.         for(i = 0; i < 5; i++)
  278.         {
  279.             match[cards[i] % 13]++;
  280.         }
  281.         for(i = 0; i < 13; i++)
  282.         {
  283.             switch(match[i])
  284.             {
  285.                 case 2:
  286.                 {
  287.                     two_pair++;
  288.                     if(two_pair == 1)
  289.                         One_Pair_Type = i;
  290.                     else if(two_pair == 2)
  291.                         Two_Pair_Type = i;
  292.                 }
  293.                 case 3: three_of_a_kind++, One_Pair_Type = i;
  294.                 case 4: return One_Pair_Type = i, FOUR_OF_A_KIND;
  295.             }
  296.         }
  297.         if(two_pair == 1 && three_of_a_kind == 1) return FULL_HOUSE;
  298.         if(two_pair == 2) return TWO_PAIR;
  299.         if(two_pair == 1) return ONE_PAIR;
  300.         if(three_of_a_kind == 1) return THREE_OF_A_KIND;
  301.         if(HasStraight(straight)) return STRAIGHT;
  302.     }
  303.     return HIGH_CARD;
  304. }
  305.  
  306. stock
  307.     HasStraight(straight)
  308. {
  309.     switch(straight)
  310.     {
  311.         case 31, 62, 124, 248, 496, 992, 1984, 3968, 7936, 4111: return true;
  312.     }
  313.     return false;
  314. }
  315.  
  316. public
  317.     OnFilterScriptInit()
  318. {
  319.     print("\nPoker filterscript loaded.\n\t * * * Created by Zsolesszka * * *\n");
  320.     return 1;
  321. }
  322.  
  323. public
  324.     OnFilterScriptExit()
  325. {
  326.     for(new i; i < MAX_PLAYERS; i++)
  327.     {
  328.         if(Start[i] != PlayerText:INVALID_TEXT_DRAW)
  329.         {
  330.             Delete_PokerTextDraw(i);
  331.         }
  332.     }
  333.     return 1;
  334. }
  335.  
  336. public
  337.     OnPlayerConnect(playerid)
  338. {
  339.     PP_Info[playerid][LastBackGround] = 3;
  340.     Start[playerid] = PlayerText:INVALID_TEXT_DRAW;
  341.     return 1;
  342. }
  343.  
  344. public
  345.     OnPlayerDisconnect(playerid, reason)
  346. {
  347.     if(Start[playerid] != PlayerText:INVALID_TEXT_DRAW)
  348.     {
  349.         Delete_PokerTextDraw(playerid);
  350.     }
  351.     return 1;
  352. }
  353.  
  354. public
  355.     OnPlayerCommandText(playerid, cmdtext[])
  356. {
  357.     new
  358.         idx,
  359.         cmd[20];
  360.     cmd = strtok(cmdtext, idx);
  361.     if(strcmp("/poker", cmd, true) == 0)
  362.     {
  363.         if(Start[playerid] != PlayerText:INVALID_TEXT_DRAW) return SendClientMessage(playerid, -1, "Already use poker.");
  364.         cmd = strtok(cmdtext, idx);
  365.         new
  366.             credit = strval(cmd);
  367.         if(credit < 5 || credit > 100000) SendClientMessage(playerid, -1, "{008888}Usage: {ffffff}/poker [5-100000]");
  368.         else if(GetPlayerMoney(playerid) < credit) SendClientMessage(playerid, -1, "Not have enough money.");
  369.         else
  370.         {
  371.         // .......................................... BackGround
  372.             Start[playerid] = CreatePlayerTextDraw(playerid, -0.000, -0.000, "LOADSUK:loadsc7");
  373.             PlayerTextDrawFont(playerid, Start[playerid], 4);
  374.             PlayerTextDrawTextSize(playerid, Start[playerid], 640.000, 450.000);
  375.             PlayerTextDrawColor(playerid, Start[playerid], -1);
  376.             PlayerTextDrawShow(playerid, Start[playerid]);
  377.         // ..........................................
  378.             new
  379.                 PlayerText:txd = Start[playerid],
  380.                 Float:t_x = 167.500000;
  381.             for(new i; i < 5; i++)
  382.             {
  383.         // .......................................... HoldsText
  384.                 txd = CreatePlayerTextDraw(playerid, t_x, 286.500, "LD_TATT:8poker");
  385.                 PlayerTextDrawFont(playerid, txd, 4);
  386.                 PlayerTextDrawTextSize(playerid, txd, 59.500, 88.000);
  387.                 PlayerTextDrawColor(playerid, txd, -1);
  388.                 PlayerTextDrawSetSelectable(playerid, txd, 1);
  389.                 PlayerTextDrawShow(playerid, txd);
  390.                 t_x += 61.500000;
  391.             }
  392.             t_x = 167.500000;
  393.             for(new i; i < 5; i++)
  394.             {
  395.         // .......................................... CardsText
  396.                 txd = CreatePlayerTextDraw(playerid, t_x, 270.500, "LD_POKE:holdon");
  397.                 PlayerTextDrawFont(playerid, txd, 4);
  398.                 PlayerTextDrawTextSize(playerid, txd, 59.500, 14.500);
  399.                 PlayerTextDrawColor(playerid, txd, -1);
  400.                 PlayerTextDrawShow(playerid, txd);
  401.                 t_x += 61.500000;
  402.             }
  403.         // .......................................... Win_Text
  404.             txd = CreatePlayerTextDraw(playerid, 167.500000, 154.000000, "Royal Flush~n~Straight Flush~n~4 of a Kind~n~Full House~n~Flush~n~Straight~n~3 of a Kind~n~Two Pair");
  405.             PlayerTextDrawFont(playerid, txd, 1);
  406.             PlayerTextDrawLetterSize(playerid, txd, 0.320000, 1.400000);
  407.             PlayerTextDrawSetOutline(playerid, txd, 1);
  408.             PlayerTextDrawSetProportional(playerid, txd, 1);
  409.             PlayerTextDrawShow(playerid, txd);
  410.         // .......................................... WinText
  411.             txd = CreatePlayerTextDraw(playerid, 247.500000, 154.000000, "_");
  412.             PlayerTextDrawFont(playerid, txd, 1);
  413.             PlayerTextDrawLetterSize(playerid, txd, 0.320000, 1.400000);
  414.             PlayerTextDrawSetOutline(playerid, txd, 1);
  415.             PlayerTextDrawSetProportional(playerid, txd, 1);
  416.             PlayerTextDrawShow(playerid, txd);
  417.         // .......................................... BetCreditText
  418.             txd = CreatePlayerTextDraw(playerid, 320.000000, 379.000000, "_");
  419.             PlayerTextDrawAlignment(playerid, txd, 2);
  420.             PlayerTextDrawBackgroundColor(playerid, txd, 255);
  421.             PlayerTextDrawFont(playerid, txd, 3);
  422.             PlayerTextDrawLetterSize(playerid, txd, 0.300000, 1.600000);
  423.             PlayerTextDrawColor(playerid, txd, -1);
  424.             PlayerTextDrawSetOutline(playerid, txd, 0);
  425.             PlayerTextDrawSetProportional(playerid, txd, 1);
  426.             PlayerTextDrawSetShadow(playerid, txd, 1);
  427.             PlayerTextDrawUseBox(playerid, txd, 1);
  428.             PlayerTextDrawBoxColor(playerid, txd, 335595560);
  429.             PlayerTextDrawTextSize(playerid, txd, 6.000000, 302.000000);
  430.             PlayerTextDrawShow(playerid, txd);
  431.         // .......................................... DealsText
  432.             txd = CreatePlayerTextDraw(playerid, 229.000, 400.500, "LD_POKE:deal");
  433.             PlayerTextDrawFont(playerid, txd, 4);
  434.             PlayerTextDrawTextSize(playerid, txd, 59.500, 14.500);
  435.             PlayerTextDrawColor(playerid, txd, -1);
  436.             PlayerTextDrawSetSelectable(playerid, txd, 1);
  437.             PlayerTextDrawShow(playerid, txd);
  438.         // .......................................... AddCoinsText
  439.             txd = CreatePlayerTextDraw(playerid, 167.500, 400.500, "LD_POKE:addcoin");
  440.             PlayerTextDrawFont(playerid, txd, 4);
  441.             PlayerTextDrawTextSize(playerid, txd, 59.500, 14.500);
  442.             PlayerTextDrawColor(playerid, txd, -1);
  443.             PlayerTextDrawSetSelectable(playerid, txd, 1);
  444.             PlayerTextDrawShow(playerid, txd);
  445.         // .......................................... ExitPoker
  446.             txd = CreatePlayerTextDraw(playerid, 457.000, 253.000, "LD_BEAT:cross");
  447.             PlayerTextDrawFont(playerid, txd, 4);
  448.             PlayerTextDrawTextSize(playerid, txd, 16.000, 16.000);
  449.             PlayerTextDrawColor(playerid, txd, -1);
  450.             PlayerTextDrawSetSelectable(playerid, txd, 1);
  451.             PlayerTextDrawShow(playerid, txd);
  452.         // .......................................... BetText
  453.             txd = CreatePlayerTextDraw(playerid, 167.500, 377.000, "LD_BEAT:circle");
  454.             PlayerTextDrawFont(playerid, txd, 4);
  455.             PlayerTextDrawTextSize(playerid, txd, 16.000, 16.000);
  456.             PlayerTextDrawColor(playerid, txd, -1);
  457.             PlayerTextDrawSetSelectable(playerid, txd, 1);
  458.             PlayerTextDrawShow(playerid, txd);
  459.         // .......................................... ChangeBackGround
  460.             txd = CreatePlayerTextDraw(playerid, 437.000, 253.000, "LD_NONE:warp");
  461.             PlayerTextDrawFont(playerid, txd, 4);
  462.             PlayerTextDrawTextSize(playerid, txd, 16.000, 16.000);
  463.             PlayerTextDrawColor(playerid, txd, -1);
  464.             PlayerTextDrawSetSelectable(playerid, txd, 1);
  465.             PlayerTextDrawShow(playerid, txd);
  466.  
  467.             if(txd == CHANGEBACKGROUND)
  468.             {
  469.                 PP_Info[playerid][Credit] = credit;
  470.                 GivePlayerMoney(playerid, -credit);
  471.                 TogglePlayerControllable(playerid, false);
  472.                 PP_Info[playerid][Bet] = MIN_BET;
  473.                 PP_Info[playerid][hold] = FIRST_CLICKDEALTEXT;
  474.  
  475.                 BetCredit(playerid);
  476.                 WinnText(playerid, 0);
  477.  
  478.                 for(new i; i < 5; i++)
  479.                 {
  480.                     PP_Info[playerid][fivecards_hand][i] = 0;
  481.                     PP_Info[playerid][fivecards_hand][i + 5] = 0;
  482.                     PP_Info[playerid][holdstate][i] = HOLDOFF;
  483.                 }
  484.                 SelectTextDraw(playerid, 0x9999BBBB);
  485.                 SendClientMessage(playerid, -1, "Play..");
  486.             } else {
  487.                 SendClientMessage(playerid, -1, "Please try again.");
  488.                 Delete_PokerTextDraw(playerid);
  489.             }
  490.         }
  491.         return 1;
  492.     }
  493.     return 0;
  494. }
  495.  
  496. stock
  497.     ExitPoker(playerid)
  498. {
  499.     Delete_PokerTextDraw(playerid);
  500.     TogglePlayerControllable(playerid, true);
  501.     GivePlayerMoney(playerid, PP_Info[playerid][Credit]);
  502.     new
  503.         str[128];
  504.     format(str, sizeof str, "Thank you using the {ffffff}¤ [Fs]Poker script by.: Zsolesszka ¤{22a4b5} Add money : {ffffff}$%d", PP_Info[playerid][Credit]);
  505.     SendClientMessage(playerid, 0x22a4b5AA, str);
  506.     PP_Info[playerid][Credit] = 0;
  507.     CancelSelectTextDraw(playerid);
  508. }
  509.  
  510. public
  511.     OnPlayerClickTextDraw(playerid, Text:clickedid)
  512. {
  513.     if(Start[playerid] != PlayerText:INVALID_TEXT_DRAW && clickedid == Text:INVALID_TEXT_DRAW)
  514.     {
  515.         ExitPoker(playerid);
  516.         return 1;
  517.     }
  518.     return 1;
  519. }
  520.  
  521. public
  522.     OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
  523. {
  524.     if(Start[playerid] != PlayerText:INVALID_TEXT_DRAW)
  525.     {
  526.         if(DEALSTEXT == playertextid)
  527.         {
  528.             if(PP_Info[playerid][hold] == FIRST_CLICKDEALTEXT)
  529.             {
  530.                 if(PP_Info[playerid][Credit] < PP_Info[playerid][Bet]) return SendClientMessage(playerid, -1, "No credit");
  531.                 PP_Info[playerid][Credit] -= PP_Info[playerid][Bet];
  532.                 PP_Info[playerid][hold] = SECOND_CLICKDEALTEXT;
  533.                 PlayerTextDrawHide(playerid, ADDCOINSTEXT);
  534.                 PlayerTextDrawHide(playerid, BETTEXT);
  535.                 PlayerPlaySound(playerid, 43000, 0.00, 0.00, 0.00);
  536.                 RandomCard(PP_Info[playerid][fivecards_hand], 10);
  537.                 WinnText(playerid, 0);
  538.                 BetCredit(playerid);
  539.                 TextDrawDizajn(playerid, 0);
  540.             } else { // else if(PP_Info[playerid][hold] == SECOND_CLICKDEALTEXT)
  541.                 PP_Info[playerid][hold] = FIRST_CLICKDEALTEXT;
  542.                 PlayerTextDrawShow(playerid, ADDCOINSTEXT);
  543.                 PlayerTextDrawShow(playerid, BETTEXT);
  544.                 for(new i; i < 5; i++)
  545.                 {
  546.                     if(PP_Info[playerid][holdstate][i] == HOLDON)
  547.                     {
  548.                         PlayerTextDrawSetString(playerid, HOLDSTEXT + PlayerText:i, " ");
  549.                         PP_Info[playerid][holdstate][i] = HOLDOFF;
  550.                     } else {
  551.                         Swap(PP_Info[playerid][fivecards_hand][i], PP_Info[playerid][fivecards_hand][i + 5]);
  552.                         PlayerTextDrawSetString(playerid, CARDSTEXT + PlayerText:i, LD_POKE[PP_Info[playerid][fivecards_hand][i]]);
  553.                     }
  554.                 }
  555.                 new
  556.                     first_pair,
  557.                     second_pair,
  558.                     win = getwin(PP_Info[playerid][fivecards_hand], first_pair, second_pair);
  559.                 if(win > ONE_PAIR)
  560.                 {
  561.                     PP_Info[playerid][Credit] += (pot[win] * PP_Info[playerid][Bet]);
  562.                     switch(win)
  563.                     {
  564.                         case STRAIGHT, FLUSH, STRAIGHT_FLUSH, FULL_HOUSE, ROYAL_FLUSH:
  565.                         {
  566.                             for(new i = 0; i < 5; i++)
  567.                             {
  568.                                 PlayerTextDrawSetString(playerid, HOLDSTEXT + PlayerText:i, "LD_POKE:holdmid");
  569.                             }
  570.                         }
  571.                         case TWO_PAIR:
  572.                         {
  573.                             for(new i = 0; i < 5; i++)
  574.                             {
  575.                                 if( Card_Value[first_pair] == Card_Value[PP_Info[playerid][fivecards_hand][i]] ||
  576.                                     Card_Value[second_pair] == Card_Value[PP_Info[playerid][fivecards_hand][i]])
  577.                                 {
  578.                                     PlayerTextDrawSetString(playerid, HOLDSTEXT + PlayerText:i, "LD_POKE:holdmid");
  579.                                 }
  580.                             }
  581.                         }
  582.                         case ONE_PAIR, FOUR_OF_A_KIND, THREE_OF_A_KIND:
  583.                         {
  584.                             for(new i = 0; i < 5; i++)
  585.                             {
  586.                                 if(Card_Value[first_pair] == Card_Value[PP_Info[playerid][fivecards_hand][i]])
  587.                                 {
  588.                                     PlayerTextDrawSetString(playerid, HOLDSTEXT + PlayerText:i, "LD_POKE:holdmid");
  589.                                 }
  590.                             }
  591.                         }
  592.                     }
  593.                     PlayerPlaySound(playerid, 5448, 0.00, 0.00, 0.00); //43001); //30800);
  594.                     WinnText(playerid, win);
  595.                     BetCredit(playerid);
  596.                 } else {
  597.                     for(new i = 0; i < 5; i++)
  598.                     {
  599.                         PlayerTextDrawSetString(playerid, HOLDSTEXT + PlayerText:i, "_");
  600.                     }
  601.                 }
  602.             }
  603.         } else {
  604.             if(PP_Info[playerid][hold] == SECOND_CLICKDEALTEXT)
  605.             {
  606.                 for(new i = 0; i < 5; i++)
  607.                 {
  608.                     if(CARDSTEXT + PlayerText:i == playertextid)
  609.                     {
  610.                         PP_Info[playerid][holdstate][i] = HOLDOFF - PP_Info[playerid][holdstate][i];
  611.                         if(PP_Info[playerid][holdstate][i])
  612.                             PlayerTextDrawSetString(playerid, HOLDSTEXT + PlayerText:i, "_");
  613.                         else
  614.                             PlayerTextDrawSetString(playerid, HOLDSTEXT + PlayerText:i, "LD_POKE:holdon");
  615.                         PlayerPlaySound(playerid, 21000, 0.00, 0.00, 0.00); //43000);
  616.                         return 1;  // stop for ciklus one textdraw
  617.                     }
  618.                 }
  619.             }
  620.             else if(ADDCOINSTEXT == playertextid)
  621.             {
  622.                 if(GetPlayerMoney(playerid) < 100)
  623.                 {
  624.                     SendClientMessage(playerid, -1, "{cc1212}You have no money.");
  625.                 } else {
  626.                     GivePlayerMoney(playerid, -100);
  627.                     PP_Info[playerid][Credit] += 100;
  628.                     BetCredit(playerid);
  629.                     PlayerPlaySound(playerid, 4203, 0.00, 0.00, 0.00);
  630.                 }
  631.                 return 1;
  632.             }
  633.             else if(BETTEXT == playertextid)
  634.             {
  635.                 if(PP_Info[playerid][Bet] < 100)
  636.                     PP_Info[playerid][Bet] += 5;
  637.                 else
  638.                     PP_Info[playerid][Bet] = 5;
  639.  
  640.                 BetCredit(playerid);
  641.                 WinnText(playerid, 0)
  642.                 PlayerPlaySound(playerid, 4202, 0.00, 0.00, 0.00);
  643.                 return 1;
  644.             }
  645.         }
  646.  
  647.         if(CHANGEBACKGROUND == playertextid)
  648.         {
  649.             PP_Info[playerid][LastBackGround]++;
  650.             if(PP_Info[playerid][LastBackGround] == sizeof BackGroundData)
  651.                 PP_Info[playerid][LastBackGround] = 0;
  652.             PlayerTextDrawSetString(playerid, BACKGROUND, BackGroundData[PP_Info[playerid][LastBackGround]]);
  653.             return 1;
  654.         }
  655.  
  656.         if(EXITPOKER == playertextid)
  657.         {
  658.             ExitPoker(playerid);
  659.             return 1;
  660.         }
  661.     }
  662.     return 1;
  663. }
  664.  
  665. public
  666.     TextDrawDizajn(playerid, index)
  667. {
  668.     if(index == 5)
  669.     {
  670.         new
  671.             win,
  672.             first_pair,
  673.             second_pair;
  674.         win = getwin(PP_Info[playerid][fivecards_hand], first_pair, second_pair);
  675.         SetTimerEx("TextDrawDizajn2", 200, false, "iiii", playerid, win, first_pair, second_pair);
  676.     } else {
  677.         PlayerPlaySound(playerid, 20800, 0.00, 0.00, 0.00);
  678.         PlayerTextDrawSetString(playerid, CARDSTEXT + PlayerText:index, "LD_POKE:cdback");
  679.         PlayerTextDrawSetString(playerid, HOLDSTEXT + PlayerText:index, " ");
  680.         SetTimerEx("TextDrawDizajn", 100, false, "ii", playerid, ++index);
  681.     }
  682.     return 1;
  683. }
  684.  
  685. public
  686.     TextDrawDizajn2(playerid, win, first_pair, second_pair)
  687. {
  688.     for(new i; i < 5; i++)
  689.     {
  690.         PlayerTextDrawSetString(playerid, CARDSTEXT + PlayerText:i, LD_POKE[PP_Info[playerid][fivecards_hand][i]]);
  691.     }
  692.     switch(win)
  693.     {
  694.         case STRAIGHT, FLUSH, STRAIGHT_FLUSH, FULL_HOUSE, ROYAL_FLUSH:
  695.         {
  696.             for(new i = 0; i < 5; i++)
  697.             {
  698.                 PlayerTextDrawSetString(playerid, HOLDSTEXT + PlayerText:i, "LD_POKE:holdon");
  699.                 PP_Info[playerid][holdstate][i] = HOLDON;
  700.             }
  701.         }
  702.         case TWO_PAIR:
  703.         {
  704.             for(new i = 0; i < 5; i++)
  705.             {
  706.                 if( Card_Value[first_pair] == Card_Value[PP_Info[playerid][fivecards_hand][i]] ||
  707.                     Card_Value[second_pair] == Card_Value[PP_Info[playerid][fivecards_hand][i]])
  708.                 {
  709.                     PlayerTextDrawSetString(playerid, HOLDSTEXT + PlayerText:i, "LD_POKE:holdon");
  710.                     PP_Info[playerid][holdstate][i] = HOLDON;
  711.                 }
  712.             }
  713.         }
  714.         case ONE_PAIR, FOUR_OF_A_KIND, THREE_OF_A_KIND:
  715.         {
  716.             for(new i = 0; i < 5; i++)
  717.             {
  718.                 if(Card_Value[first_pair] == Card_Value[PP_Info[playerid][fivecards_hand][i]])
  719.                 {
  720.                     PlayerTextDrawSetString(playerid, HOLDSTEXT + PlayerText:i, "LD_POKE:holdon");
  721.                     PP_Info[playerid][holdstate][i] = HOLDON;
  722.                 }
  723.             }
  724.         }
  725.     }
  726.     WinnText(playerid, win);
  727.     return 1;
  728. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement