Guest User

www.pro-pawn.ru

a guest
Mar 5th, 2014
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 43.34 KB | None | 0 0
  1. //Спешал фор www.pro-pawn.ru
  2. #if defined _gCasino_included
  3.     #endinput
  4. #endif
  5. #define _gCasino_included
  6.  
  7. #define _gCasino_PRESSED(%0)                    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  8.  
  9.  
  10. /*
  11.     Grimrandomer's Casino Script
  12.     Version: 1.0.0.2
  13.    
  14.     www.Grimrandomer.com
  15.     www.LV-CNR.com
  16.  
  17. */
  18.  
  19. #define _gCasino_KEY                    KEY_SECONDARY_ATTACK //Key they press to use casino machine <Enter> / <F> by default.
  20.  
  21. #define MAX_CASINO_MACHINES             100 //MAX Number of casino machine's, adjust this based on estimated amount used for better memory use.
  22. #define INVALID_CASINO_MACHINE_ID       -1
  23.  
  24. #define CASINO_MACHINE_POKER            0
  25. //#define CASINO_MACHINE_SLOTS          1
  26. //#define CASINO_MACHINE_WHEELOFORTUNE  2
  27.  
  28. #define CASINO_MACHINE_POKER_MODEL      2785
  29.  
  30. #define CASINO_MONEY_CHARGE             0
  31. #define CASINO_MONEY_WIN                1
  32. #define CASINO_MONEY_NOTENOUGH          2
  33.  
  34. #define GC_FREEZESTATE_UNFROZEN         0
  35. #define GC_FREEZESTATE_FROZEN           1
  36.  
  37.  
  38. enum casino_machine {
  39.     cm_active,
  40.     cm_type,
  41.     Float:cm_loc[3],
  42.     Float:cm_rot[3],
  43.     cm_isDynamic,
  44.     cm_objs[4]
  45. }
  46.  
  47. new _machines[MAX_CASINO_MACHINES][casino_machine];
  48.  
  49. stock _gCasino_SetPlayerFreezeState(playerid,freezeState) {
  50.     if (freezeState==GC_FREEZESTATE_FROZEN) {
  51.         TogglePlayerControllable(playerid, 0);
  52.     } else {
  53.         TogglePlayerControllable(playerid, 1);
  54.     }
  55. }
  56.  
  57. stock IsValidCasinoMachineType(_type) {
  58.     if (_type==CASINO_MACHINE_POKER)
  59.         return 1;
  60.        
  61.     return 0;
  62. }
  63.  
  64. stock freeCasinoMachineID() {
  65.     for (new _mid=0; _mid<MAX_CASINO_MACHINES; _mid++) {
  66.         if (_machines[_mid][cm_active] == 0) {
  67.             return _mid;
  68.         }
  69.     }
  70.     return INVALID_CASINO_MACHINE_ID;
  71. }
  72.  
  73. stock IsValidCasinoMachineID(_machineID) {
  74.     if (_machineID>=0 && _machineID<MAX_CASINO_MACHINES) {
  75.         if (_machines[_machineID][cm_active]==1) {
  76.             return true;
  77.         }
  78.     }
  79.     return false;
  80. }
  81.  
  82. stock GetMachineType(_machineID, &_type) {
  83.     if (!IsValidCasinoMachineID(_machineID))
  84.         return false;
  85.    
  86.     _type = _machines[_machineID][cm_type];
  87.     return true;
  88. }
  89.  
  90. stock CreateCasinoMachine(_type, Float:_lX, Float:_lY, Float:_lZ, Float:_rX, Float:_rY, Float:_rZ, useDynamicObj=0) {
  91.     if (!IsValidCasinoMachineType(_type))
  92.         return 0;
  93.  
  94.     new _machineID = freeCasinoMachineID();
  95.     if (_machineID == INVALID_CASINO_MACHINE_ID)
  96.         return 0;
  97.  
  98.     _machines[_machineID][cm_active] = 1;
  99.     _machines[_machineID][cm_type] = _type;
  100.     _machines[_machineID][cm_loc][0] = _lX;
  101.     _machines[_machineID][cm_loc][1] = _lY;
  102.     _machines[_machineID][cm_loc][2] = _lZ;
  103.     _machines[_machineID][cm_rot][0] = _rX;
  104.     _machines[_machineID][cm_rot][1] = _rY;
  105.     _machines[_machineID][cm_rot][2] = _rZ;
  106.     _machines[_machineID][cm_isDynamic] = useDynamicObj;
  107.    
  108.     /* CREATE OBJECTS */
  109.     switch (_type) {
  110.         case CASINO_MACHINE_POKER: {
  111.             if (useDynamicObj==0) {
  112.                 _machines[_machineID][cm_objs][0] = CreateObject(CASINO_MACHINE_POKER_MODEL, _lX, _lY, _lZ, _rX, _rY, _rZ);
  113.             } else {
  114.                 #if defined CreateDynamicObject
  115.                 _machines[_machineID][cm_objs][0] = CreateDynamicObject(CASINO_MACHINE_POKER_MODEL, _lX, _lY, _lZ, _rX, _rY, _rZ);
  116.                 #else
  117.                 _machines[_machineID][cm_objs][0] = CreateObject(CASINO_MACHINE_POKER_MODEL, _lX, _lY, _lZ, _rX, _rY, _rZ);
  118.                 #endif
  119.             }
  120.         }
  121.     }
  122.  
  123.     return _machineID;
  124. }
  125.  
  126. stock RemoveCasinoMachine(_machineID) {
  127.     if (_machineID == INVALID_CASINO_MACHINE_ID)
  128.         return 0;
  129.  
  130.     if ((_machineID < 0) || (_machineID>=MAX_CASINO_MACHINES))
  131.         return 0;
  132.        
  133.     if (_machines[_machineID][cm_active] == 0)
  134.         return 0;
  135.    
  136.     _machines[_machineID][cm_active] = 0;
  137.    
  138.     RemoveAllFromMachine(_machineID);
  139.  
  140.     /* REMOVE OBJECTS */
  141.     switch (_type) {
  142.         case CASINO_MACHINE_POKER: {
  143.             if (useDynamicObj==0) {
  144.                 DestroyObject(_machines[_machineID][cm_objs][0]);
  145.             } else {
  146.                 #if defined DestroyDynamicObject
  147.                 DestroyDynamicObject(_machines[_machineID][cm_objs][0]);
  148.                 #else
  149.                 DestroyObject(_machines[_machineID][cm_objs][0]);
  150.                 #endif
  151.             }
  152.         }
  153.     }
  154. }
  155.  
  156. stock IsPlayerAtAnyCasinoMachine(playerid) {
  157.     if (SetPVarInt(playerid, "ss_casino_use") == 1)
  158.         return 1;
  159.        
  160.     return 0;
  161. }
  162.  
  163. stock IsPlayerAtCasinoMachine(playerid, _machineID) {
  164.     if (GetPVarInt(playerid, "ss_casino_use") == 1) {
  165.         if (GetPVarInt(playerid, "ss_casino_using") == _machineID) {
  166.             return 1;
  167.         }
  168.     }
  169.     return 0;
  170. }
  171.  
  172. stock RemoveAllFromAllMachines() {
  173.     for (playerid=0; playerid<MAX_PLAYERS; playerid++) {
  174.         if (IsPlayerAtAnyCasinoMachine(playerid)) {
  175.             closePlayerCasinoInterface(playerid);
  176.         }
  177.     }
  178. }
  179.  
  180. stock RemoveAllFromMachine(_machineID) {
  181.     for (playerid=0; playerid<MAX_PLAYERS; playerid++) {
  182.         if (IsPlayerAtCasinoMachine(playerid, _machineID)) {
  183.             closePlayerCasinoInterface(playerid);
  184.         }
  185.     }
  186. }
  187.  
  188. stock RemoveFromMachine(playerid, _machineID) {
  189.     if (IsPlayerAtCasinoMachine(playerid, _machineID)) {
  190.         closePlayerCasinoInterface(playerid);
  191.     }
  192.     return 0;
  193. }
  194.  
  195. stock ClosestCasinoMachine(playerid) {
  196.     for (new _mid=0; _mid<MAX_CASINO_MACHINES; _mid++) {
  197.         if (_machines[_mid][cm_active] == 1) {
  198.             if(IsPlayerInRangeOfPoint(playerid,2.5,_machines[_mid][cm_loc][0],_machines[_mid][cm_loc][1],_machines[_mid][cm_loc][2])) {
  199.                 return _mid;
  200.             }
  201.         }
  202.     }
  203.     return INVALID_CASINO_MACHINE_ID;
  204. }
  205.  
  206. stock closePlayerCasinoInterface(playerid) {
  207.     if (GetPVarInt(playerid, "ss_casino_use") == 0)
  208.         return 0;
  209.        
  210.     new _machineID = GetPVarInt(playerid, "ss_casino_using");
  211.     SetPVarInt(playerid, "ss_casino_use", 0);
  212.     SetPVarInt(playerid, "ss_casino_using", -1);
  213.  
  214.     // CLOSE
  215.     switch (_machines[_machineID][cm_type]) {
  216.         case CASINO_MACHINE_POKER: {
  217.             cPoker_closeInterface(playerid);
  218.         }
  219.     }
  220.    
  221.     CallLocalFunction("OnCasinoEnd", "ii", playerid, _machineID);
  222.    
  223.     return 1;
  224. }
  225.  
  226. stock openPlayerCasinoInterface(playerid, _machineID) {
  227.     if (GetPVarInt(playerid, "ss_casino_use") == 1)
  228.         return 0;
  229.    
  230.     SetPVarInt(playerid, "ss_casino_use", 1);
  231.     SetPVarInt(playerid, "ss_casino_using", _machineID);
  232.  
  233.     // OPEN
  234.     switch (_machines[_machineID][cm_type]) {
  235.         case CASINO_MACHINE_POKER: {
  236.             cPoker_openInterface(playerid);
  237.         }
  238.     }
  239.    
  240.     CallLocalFunction("OnCasinoStart", "ii", playerid, _machineID);
  241.    
  242.     return 1;
  243. }
  244.  
  245. /* POKER CODE */
  246.  
  247. #define CARD_TYPE_NONE                  0
  248. #define CARD_TYPE_CLUB                  1
  249. #define CARD_TYPE_DIAMOND               2
  250. #define CARD_TYPE_HEART                 3
  251. #define CARD_TYPE_SPADE                 4
  252.  
  253. #define CARD_JACK                       11
  254. #define CARD_QUEEN                      12
  255. #define CARD_KING                       13
  256. #define CARD_ACE                        1
  257.  
  258. #define HOLD_BUTTON_DISABLED            0
  259. #define HOLD_BUTTON_NORMAL              1
  260. #define HOLD_BUTTON_SELECTED            2
  261.  
  262. #define CASINO_POKER_BTN_DEAL           0
  263. #define CASINO_POKER_BTN_ADDCOIN        1
  264. #define CASINO_POKER_BTN_HOLD           2
  265.  
  266. #define CPOKER_CHECKMODE_CARD           0
  267. #define CPOKER_CHECKMODE_CARDSUIT       1
  268.  
  269. #define c_suitsEqual(%1,%2,%3,%4,%5)    (%1==1 && c_Equal(%1,%2,%3,%4,%5))
  270. #define c_anySuits(%1,%2,%3,%4,%5)      (%1>CARD_TYPE_NONE && %2>CARD_TYPE_NONE && %3>CARD_TYPE_NONE && %4>CARD_TYPE_NONE &&%5>CARD_TYPE_NONE)
  271. #define c_Equal(%1,%2,%3,%4,%5)         (%1==%2 && %2==%3 && %3==%4 && %4==%5)
  272.  
  273. #define CHECK_NONE                      0
  274. #define CHECK_ROYALFLUSH                1
  275. #define CHECK_STRAIGHTFLUSH             2
  276. #define CHECK_FOUROFAKIND               3
  277. #define CHECK_FULLHOUSE                 4
  278. #define CHECK_FLUSH                     5
  279. #define CHECK_STRAIGHT                  6
  280. #define CHECK_THREEOFAKIND              7
  281. #define CHECK_TWOPAIRS                  8
  282. #define CHECK_JACKORBETTER              9
  283.  
  284. new Text:poker_background[2];
  285. new Text:poker_coinSelectionBG[6];
  286. new Text:poker_coinSelectionText[6];
  287. new Text:poker_coinHeadingText[6];
  288. new Text:poker_deal;
  289. new Text:poker_addCoin;
  290. new Text:poker_coinValue;
  291.  
  292. new PlayerText:poker_card[MAX_PLAYERS][5];
  293. new PlayerText:poker_hold[MAX_PLAYERS][5];
  294. new PlayerText:poker_wager[MAX_PLAYERS];
  295.  
  296. new Float:cardPosX[5] = {76.0, 176.0, 274.0, 373.0, 471.0};
  297. new Float:holdPosX[5] = {122.0, 222.0, 321.0, 419.0, 517.0};
  298.  
  299. new cPoker_winningCoinsValue[9][5] = {
  300.     {250,500,750,1000,4000}, //ROYALFLUSH
  301.     {50,100,150,200,250}, //STRAIGHTFLUSH
  302.     {25,50,75,100,125}, //FOUROFAKIND
  303.     {9,18,27,36,45}, //FULLHOUSE
  304.     {6,12,18,24,30}, //FLUSH
  305.     {4,8,12,16,20}, //STRAIGHT
  306.     {3,6,9,12,15}, //THREEOFAKIND
  307.     {2,4,6,8,10}, //TWOPAIRS
  308.     {1,2,3,4,5} //JACKORBETTER
  309. };
  310.  
  311. new cPoker_winningType[10][20] = {
  312.     "None",
  313.     "Royal Flush",
  314.     "Straight Flush",
  315.     "Four of a kind",
  316.     "Full house",
  317.     "Flush",
  318.     "Straight",
  319.     "Three of a Kind",
  320.     "Two Pairs",
  321.     "Jack or Better"
  322. };
  323.  
  324. new cPokerGame[MAX_PLAYERS][5][3];
  325.  
  326. cPoker_genTDs() {
  327.     poker_background[0] = TextDrawCreate(0.000000, 0.000000, "_");
  328.     TextDrawBackgroundColor (poker_background[0], 255);
  329.     TextDrawFont            (poker_background[0], 1);
  330.     TextDrawLetterSize      (poker_background[0], 0.500000, 50.000000);
  331.     TextDrawColor           (poker_background[0], -1);
  332.     TextDrawSetOutline      (poker_background[0], 0);
  333.     TextDrawSetProportional (poker_background[0], 1);
  334.     TextDrawSetShadow       (poker_background[0], 1);
  335.     TextDrawUseBox          (poker_background[0], 1);
  336.     TextDrawBoxColor        (poker_background[0], 9764863);
  337.     TextDrawTextSize        (poker_background[0], 640.000000, 0.000000);
  338.     TextDrawSetSelectable   (poker_background[0], 0);
  339.  
  340.     poker_background[1] = TextDrawCreate(76.000000, 57.000000, "_");
  341.     TextDrawBackgroundColor (poker_background[1], 255);
  342.     TextDrawFont            (poker_background[1], 1);
  343.     TextDrawLetterSize      (poker_background[1], 0.500000, 18.000000);
  344.     TextDrawColor           (poker_background[1], -1);
  345.     TextDrawSetOutline      (poker_background[1], 0);
  346.     TextDrawSetProportional (poker_background[1], 1);
  347.     TextDrawSetShadow       (poker_background[1], 1);
  348.     TextDrawUseBox          (poker_background[1], 1);
  349.     TextDrawBoxColor        (poker_background[1], -65281);
  350.     TextDrawTextSize        (poker_background[1], 459.000000, 0.000000);
  351.     TextDrawSetSelectable   (poker_background[1], 0);
  352.  
  353.     poker_coinSelectionBG[0] = TextDrawCreate(77.000000, 58.000000, "_");
  354.     TextDrawBackgroundColor (poker_coinSelectionBG[0], 255);
  355.     TextDrawFont            (poker_coinSelectionBG[0], 1);
  356.     TextDrawLetterSize      (poker_coinSelectionBG[0], 0.500000, 17.800003);
  357.     TextDrawColor           (poker_coinSelectionBG[0], -1);
  358.     TextDrawSetOutline      (poker_coinSelectionBG[0], 0);
  359.     TextDrawSetProportional (poker_coinSelectionBG[0], 1);
  360.     TextDrawSetShadow       (poker_coinSelectionBG[0], 1);
  361.     TextDrawUseBox          (poker_coinSelectionBG[0], 1);
  362.     TextDrawBoxColor        (poker_coinSelectionBG[0], 255);
  363.     TextDrawTextSize        (poker_coinSelectionBG[0], 197.000000, 0.000000);
  364.     TextDrawSetSelectable   (poker_coinSelectionBG[0], 0);
  365.  
  366.     poker_coinSelectionBG[1] = TextDrawCreate(201.000000, 58.000000, "_");
  367.     TextDrawBackgroundColor (poker_coinSelectionBG[1], 255);
  368.     TextDrawFont            (poker_coinSelectionBG[1], 1);
  369.     TextDrawLetterSize      (poker_coinSelectionBG[1], 0.500000, 17.800003);
  370.     TextDrawColor           (poker_coinSelectionBG[1], -1);
  371.     TextDrawSetOutline      (poker_coinSelectionBG[1], 0);
  372.     TextDrawSetProportional (poker_coinSelectionBG[1], 1);
  373.     TextDrawSetShadow       (poker_coinSelectionBG[1], 1);
  374.     TextDrawUseBox          (poker_coinSelectionBG[1], 1);
  375.     TextDrawBoxColor        (poker_coinSelectionBG[1], 255);
  376.     TextDrawTextSize        (poker_coinSelectionBG[1], 245.000000, 0.000000);
  377.     TextDrawSetSelectable   (poker_coinSelectionBG[1], 0);
  378.  
  379.     poker_coinSelectionBG[2] = TextDrawCreate(249.000000, 58.000000, "_");
  380.     TextDrawBackgroundColor (poker_coinSelectionBG[2], 255);
  381.     TextDrawFont            (poker_coinSelectionBG[2], 1);
  382.     TextDrawLetterSize      (poker_coinSelectionBG[2], 0.500000, 17.800003);
  383.     TextDrawColor           (poker_coinSelectionBG[2], -1);
  384.     TextDrawSetOutline      (poker_coinSelectionBG[2], 0);
  385.     TextDrawSetProportional (poker_coinSelectionBG[2], 1);
  386.     TextDrawSetShadow       (poker_coinSelectionBG[2], 1);
  387.     TextDrawUseBox          (poker_coinSelectionBG[2], 1);
  388.     TextDrawBoxColor        (poker_coinSelectionBG[2], 255);
  389.     TextDrawTextSize        (poker_coinSelectionBG[2], 291.000000, 0.000000);
  390.     TextDrawSetSelectable   (poker_coinSelectionBG[2], 0);
  391.  
  392.     poker_coinSelectionBG[3] = TextDrawCreate(295.000000, 58.000000, "_");
  393.     TextDrawBackgroundColor (poker_coinSelectionBG[3], 255);
  394.     TextDrawFont            (poker_coinSelectionBG[3], 1);
  395.     TextDrawLetterSize      (poker_coinSelectionBG[3], 0.500000, 17.800003);
  396.     TextDrawColor           (poker_coinSelectionBG[3], -1);
  397.     TextDrawSetOutline      (poker_coinSelectionBG[3], 0);
  398.     TextDrawSetProportional (poker_coinSelectionBG[3], 1);
  399.     TextDrawSetShadow       (poker_coinSelectionBG[3], 1);
  400.     TextDrawUseBox          (poker_coinSelectionBG[3], 1);
  401.     TextDrawBoxColor        (poker_coinSelectionBG[3], 255);
  402.     TextDrawTextSize        (poker_coinSelectionBG[3], 337.000000, 0.000000);
  403.     TextDrawSetSelectable   (poker_coinSelectionBG[3], 0);
  404.  
  405.     poker_coinSelectionBG[4] = TextDrawCreate(341.000000, 58.000000, "_");
  406.     TextDrawBackgroundColor (poker_coinSelectionBG[4], 255);
  407.     TextDrawFont            (poker_coinSelectionBG[4], 1);
  408.     TextDrawLetterSize      (poker_coinSelectionBG[4], 0.500000, 17.800003);
  409.     TextDrawColor           (poker_coinSelectionBG[4], -1);
  410.     TextDrawSetOutline      (poker_coinSelectionBG[4], 0);
  411.     TextDrawSetProportional (poker_coinSelectionBG[4], 1);
  412.     TextDrawSetShadow       (poker_coinSelectionBG[4], 1);
  413.     TextDrawUseBox          (poker_coinSelectionBG[4], 1);
  414.     TextDrawBoxColor        (poker_coinSelectionBG[4], 255);
  415.     TextDrawTextSize        (poker_coinSelectionBG[4], 393.000000, 0.000000);
  416.     TextDrawSetSelectable   (poker_coinSelectionBG[4], 0);
  417.  
  418.     poker_coinSelectionBG[5] = TextDrawCreate(397.000000, 58.000000, "_");
  419.     TextDrawBackgroundColor (poker_coinSelectionBG[5], 255);
  420.     TextDrawFont            (poker_coinSelectionBG[5], 1);
  421.     TextDrawLetterSize      (poker_coinSelectionBG[5], 0.500000, 17.800003);
  422.     TextDrawColor           (poker_coinSelectionBG[5], -1);
  423.     TextDrawSetOutline      (poker_coinSelectionBG[5], 0);
  424.     TextDrawSetProportional (poker_coinSelectionBG[5], 1);
  425.     TextDrawSetShadow       (poker_coinSelectionBG[5], 1);
  426.     TextDrawUseBox          (poker_coinSelectionBG[5], 1);
  427.     TextDrawBoxColor        (poker_coinSelectionBG[5], 255);
  428.     TextDrawTextSize        (poker_coinSelectionBG[5], 458.000000, 0.000000);
  429.     TextDrawSetSelectable   (poker_coinSelectionBG[5], 0);
  430.  
  431.     poker_coinSelectionText[0] = TextDrawCreate(78.000000, 56.000000, "ROYAL FLUSH~n~STRAIGHT FLUSH~n~FOUR OF A KIND~n~FULL HOUSE~n~FLUSH~n~STRAIGHT~n~THREE OF A KIND~n~TWO PAIRS~n~JACKS OR BETTER");
  432.     TextDrawBackgroundColor (poker_coinSelectionText[0], 255);
  433.     TextDrawFont            (poker_coinSelectionText[0], 1);
  434.     TextDrawLetterSize      (poker_coinSelectionText[0], 0.399998, 2.000000);
  435.     TextDrawColor           (poker_coinSelectionText[0], -65281);
  436.     TextDrawSetOutline      (poker_coinSelectionText[0], 1);
  437.     TextDrawSetProportional (poker_coinSelectionText[0], 1);
  438.     TextDrawSetSelectable   (poker_coinSelectionText[0], 0);
  439.  
  440.     poker_coinSelectionText[1] = TextDrawCreate(237.000000, 56.000000, "$25k~n~$5k~n~$2.5K~n~$900~n~$600~n~$400~n~$300~n~$200~n~$100~n~");//"250~n~50~n~25~n~9~n~6~n~4~n~3~n~2~n~1~n~");
  441.     TextDrawAlignment       (poker_coinSelectionText[1], 3);
  442.     TextDrawBackgroundColor (poker_coinSelectionText[1], 255);
  443.     TextDrawFont            (poker_coinSelectionText[1], 1);
  444.     TextDrawLetterSize      (poker_coinSelectionText[1], 0.399998, 2.000000);
  445.     TextDrawColor           (poker_coinSelectionText[1], -65281);
  446.     TextDrawSetOutline      (poker_coinSelectionText[1], 1);
  447.     TextDrawSetProportional (poker_coinSelectionText[1], 1);
  448.     TextDrawSetSelectable   (poker_coinSelectionText[1], 0);
  449.  
  450.     poker_coinSelectionText[2] = TextDrawCreate(283.000000, 56.000000, "$50k~n~$10k~n~$5k~n~$1.8k~n~$1.2k~n~$800~n~$600~n~$400~n~$200~n~");//"500~n~100~n~50~n~18~n~12~n~8~n~6~n~4~n~2~n~");
  451.     TextDrawAlignment       (poker_coinSelectionText[2], 3);
  452.     TextDrawBackgroundColor (poker_coinSelectionText[2], 255);
  453.     TextDrawFont            (poker_coinSelectionText[2], 1);
  454.     TextDrawLetterSize      (poker_coinSelectionText[2], 0.399998, 2.000000);
  455.     TextDrawColor           (poker_coinSelectionText[2], -65281);
  456.     TextDrawSetOutline      (poker_coinSelectionText[2], 1);
  457.     TextDrawSetProportional (poker_coinSelectionText[2], 1);
  458.     TextDrawSetSelectable   (poker_coinSelectionText[2], 0);
  459.  
  460.     poker_coinSelectionText[3] = TextDrawCreate(329.000000, 56.000000, "$75k~n~$15k~n~$7.5k~n~$2.7k~n~$1.8k~n~$1.2k~n~$900~n~$600~n~$300~n~"); //"750~n~150~n~75~n~27~n~18~n~12~n~9~n~6~n~3~n~");
  461.     TextDrawAlignment       (poker_coinSelectionText[3], 3);
  462.     TextDrawBackgroundColor (poker_coinSelectionText[3], 255);
  463.     TextDrawFont            (poker_coinSelectionText[3], 1);
  464.     TextDrawLetterSize      (poker_coinSelectionText[3], 0.399998, 2.000000);
  465.     TextDrawColor           (poker_coinSelectionText[3], -65281);
  466.     TextDrawSetOutline      (poker_coinSelectionText[3], 1);
  467.     TextDrawSetProportional (poker_coinSelectionText[3], 1);
  468.     TextDrawSetSelectable   (poker_coinSelectionText[3], 0);
  469.  
  470.     poker_coinSelectionText[4] = TextDrawCreate(385.000000, 56.000000, "$100k~n~$20k~n~$10k~n~$3.6k~n~$2.4k~n~$1.6k~n~$1.2k~n~$800~n~$400~n~"); //"1000~n~200~n~100~n~36~n~24~n~16~n~12~n~8~n~4~n~");
  471.     TextDrawAlignment       (poker_coinSelectionText[4], 3);
  472.     TextDrawBackgroundColor (poker_coinSelectionText[4], 255);
  473.     TextDrawFont            (poker_coinSelectionText[4], 1);
  474.     TextDrawLetterSize      (poker_coinSelectionText[4], 0.399998, 2.000000);
  475.     TextDrawColor           (poker_coinSelectionText[4], -65281);
  476.     TextDrawSetOutline      (poker_coinSelectionText[4], 1);
  477.     TextDrawSetProportional (poker_coinSelectionText[4], 1);
  478.     TextDrawSetSelectable   (poker_coinSelectionText[4], 0);
  479.  
  480.     poker_coinSelectionText[5] = TextDrawCreate(450.000000, 56.000000, "$400k~n~$25k~n~$12.5k~n~$4.5k~n~$3k~n~$2k~n~$1.5k~n~$1k~n~$500~n~"); //4000~n~250~n~125~n~45~n~30~n~20~n~15~n~10~n~5~n~");
  481.     TextDrawAlignment       (poker_coinSelectionText[5], 3);
  482.     TextDrawBackgroundColor (poker_coinSelectionText[5], 255);
  483.     TextDrawFont            (poker_coinSelectionText[5], 1);
  484.     TextDrawLetterSize      (poker_coinSelectionText[5], 0.399998, 2.000000);
  485.     TextDrawColor           (poker_coinSelectionText[5], -65281);
  486.     TextDrawSetOutline      (poker_coinSelectionText[5], 1);
  487.     TextDrawSetProportional (poker_coinSelectionText[5], 1);
  488.     TextDrawSetSelectable   (poker_coinSelectionText[5], 0);
  489.  
  490.     poker_coinHeadingText[0] = TextDrawCreate(78.000000, 36.000000, "WAGERED");
  491.     TextDrawBackgroundColor (poker_coinHeadingText[0], 255);
  492.     TextDrawFont            (poker_coinHeadingText[0], 1);
  493.     TextDrawLetterSize      (poker_coinHeadingText[0], 0.399998, 2.000000);
  494.     TextDrawColor           (poker_coinHeadingText[0], -1);
  495.     TextDrawSetOutline      (poker_coinHeadingText[0], 1);
  496.     TextDrawSetProportional (poker_coinHeadingText[0], 1);
  497.     TextDrawSetSelectable   (poker_coinHeadingText[0], 0);
  498.  
  499.     poker_coinHeadingText[1] = TextDrawCreate(237.000000, 36.000000, "$100~n~");
  500.     TextDrawAlignment       (poker_coinHeadingText[1], 3);
  501.     TextDrawBackgroundColor (poker_coinHeadingText[1], 255);
  502.     TextDrawFont            (poker_coinHeadingText[1], 1);
  503.     TextDrawLetterSize      (poker_coinHeadingText[1], 0.399998, 2.000000);
  504.     TextDrawColor           (poker_coinHeadingText[1], -1);
  505.     TextDrawSetOutline      (poker_coinHeadingText[1], 1);
  506.     TextDrawSetProportional (poker_coinHeadingText[1], 1);
  507.     TextDrawSetSelectable   (poker_coinHeadingText[1], 0);
  508.  
  509.     poker_coinHeadingText[2] = TextDrawCreate(283.000000, 36.000000, "$200~n~");
  510.     TextDrawAlignment       (poker_coinHeadingText[2], 3);
  511.     TextDrawBackgroundColor (poker_coinHeadingText[2], 255);
  512.     TextDrawFont            (poker_coinHeadingText[2], 1);
  513.     TextDrawLetterSize      (poker_coinHeadingText[2], 0.399998, 2.000000);
  514.     TextDrawColor           (poker_coinHeadingText[2], -1);
  515.     TextDrawSetOutline      (poker_coinHeadingText[2], 1);
  516.     TextDrawSetProportional (poker_coinHeadingText[2], 1);
  517.     TextDrawSetSelectable   (poker_coinHeadingText[2], 0);
  518.  
  519.     poker_coinHeadingText[3] = TextDrawCreate(329.000000, 36.000000, "$300~n~");
  520.     TextDrawAlignment       (poker_coinHeadingText[3], 3);
  521.     TextDrawBackgroundColor (poker_coinHeadingText[3], 255);
  522.     TextDrawFont            (poker_coinHeadingText[3], 1);
  523.     TextDrawLetterSize      (poker_coinHeadingText[3], 0.399998, 2.000000);
  524.     TextDrawColor           (poker_coinHeadingText[3], -1);
  525.     TextDrawSetOutline      (poker_coinHeadingText[3], 1);
  526.     TextDrawSetProportional (poker_coinHeadingText[3], 1);
  527.     TextDrawSetSelectable   (poker_coinHeadingText[3], 0);
  528.  
  529.     poker_coinHeadingText[4] = TextDrawCreate(385.000000, 36.000000, "$400~n~");
  530.     TextDrawAlignment       (poker_coinHeadingText[4], 3);
  531.     TextDrawBackgroundColor (poker_coinHeadingText[4], 255);
  532.     TextDrawFont            (poker_coinHeadingText[4], 1);
  533.     TextDrawLetterSize      (poker_coinHeadingText[4], 0.399998, 2.000000);
  534.     TextDrawColor           (poker_coinHeadingText[4], -1);
  535.     TextDrawSetOutline      (poker_coinHeadingText[4], 1);
  536.     TextDrawSetProportional (poker_coinHeadingText[4], 1);
  537.     TextDrawSetSelectable   (poker_coinHeadingText[4], 0);
  538.  
  539.     poker_coinHeadingText[5] = TextDrawCreate(450.000000, 36.000000, "$500~n~");
  540.     TextDrawAlignment       (poker_coinHeadingText[5], 3);
  541.     TextDrawBackgroundColor (poker_coinHeadingText[5], 255);
  542.     TextDrawFont            (poker_coinHeadingText[5], 1);
  543.     TextDrawLetterSize      (poker_coinHeadingText[5], 0.399998, 2.000000);
  544.     TextDrawColor           (poker_coinHeadingText[5], -1);
  545.     TextDrawSetOutline      (poker_coinHeadingText[5], 1);
  546.     TextDrawSetProportional (poker_coinHeadingText[5], 1);
  547.     TextDrawSetSelectable   (poker_coinHeadingText[5], 0);
  548.  
  549.     poker_addCoin = TextDrawCreate(122.000000, 416.000000, "ADD COIN");
  550.     TextDrawAlignment       (poker_addCoin, 2);
  551.     TextDrawBackgroundColor (poker_addCoin, 255);
  552.     TextDrawFont            (poker_addCoin, 2);
  553.     TextDrawLetterSize      (poker_addCoin, 0.299997, 2.000000);
  554.     TextDrawColor           (poker_addCoin, -1);
  555.     TextDrawSetOutline      (poker_addCoin, 1);
  556.     TextDrawSetProportional (poker_addCoin, 1);
  557.     TextDrawUseBox          (poker_addCoin, 1);
  558.     TextDrawBoxColor        (poker_addCoin, -286331649);
  559.     TextDrawTextSize        (poker_addCoin, 15.000000, 90.000000);
  560.     TextDrawSetSelectable   (poker_addCoin, 1);
  561.  
  562.     poker_deal = TextDrawCreate(222.000000, 416.000000, "DEAL");
  563.     TextDrawAlignment       (poker_deal, 2);
  564.     TextDrawBackgroundColor (poker_deal, 255);
  565.     TextDrawFont            (poker_deal, 2);
  566.     TextDrawLetterSize      (poker_deal, 0.299997, 2.000000);
  567.     TextDrawColor           (poker_deal, -1);
  568.     TextDrawSetOutline      (poker_deal, 1);
  569.     TextDrawSetProportional (poker_deal, 1);
  570.     TextDrawUseBox          (poker_deal, 1);
  571.     TextDrawBoxColor        (poker_deal, -286331649);
  572.     TextDrawTextSize        (poker_deal, 15.000000, 90.000000);
  573.     TextDrawSetSelectable   (poker_deal, 1);
  574.  
  575.     poker_coinValue = TextDrawCreate(510.000000, 136.000000, "COIN VALUE~n~$100");
  576.     TextDrawAlignment       (poker_coinValue, 2);
  577.     TextDrawBackgroundColor (poker_coinValue, 255);
  578.     TextDrawFont            (poker_coinValue, 1);
  579.     TextDrawLetterSize      (poker_coinValue, 0.399998, 2.000000);
  580.     TextDrawColor           (poker_coinValue, -1);
  581.     TextDrawSetOutline      (poker_coinValue, 1);
  582.     TextDrawSetProportional (poker_coinValue, 1);
  583.     TextDrawSetSelectable   (poker_coinValue, 0);
  584.    
  585.     return 1;
  586. }
  587.  
  588. cPoker_hidePlayerCard(playerid, _card) {
  589.     if ((_card <0) || (_card >= 5))
  590.         return 0;
  591.  
  592.     if (PlayerText:poker_card[playerid][_card] != PlayerText:INVALID_TEXT_DRAW) {
  593.         PlayerTextDrawHide(playerid, poker_card[playerid][_card]);
  594.         PlayerTextDrawDestroy(playerid, poker_card[playerid][_card]);
  595.     }
  596.    
  597.     return 1;
  598. }
  599.  
  600. cPoker_showPlayerCard(playerid, _card, _cardType=CARD_TYPE_NONE, _cardValue=1) {
  601.     if ((_card <0) || (_card >= 5))
  602.         return 0;
  603.  
  604.     cPoker_hidePlayerCard(playerid, _card);
  605.    
  606.     new cardText[20];
  607.     switch (_cardType) {
  608.         case CARD_TYPE_NONE: { format(cardText, 20, "ld_poke:cdback"); }
  609.         case CARD_TYPE_CLUB: { format(cardText, 20, "ld_poke:cd%dc", _cardValue); }
  610.         case CARD_TYPE_DIAMOND: { format(cardText, 20, "ld_poke:cd%dd", _cardValue); }
  611.         case CARD_TYPE_HEART: { format(cardText, 20, "ld_poke:cd%dh", _cardValue); }
  612.         case CARD_TYPE_SPADE: { format(cardText, 20, "ld_poke:cd%ds", _cardValue); }
  613.     }
  614.    
  615.     poker_card[playerid][_card] = CreatePlayerTextDraw(playerid, cardPosX[_card], 262.000000, cardText);
  616.     PlayerTextDrawBackgroundColor   (playerid, poker_card[playerid][_card], 255);
  617.     PlayerTextDrawFont              (playerid, poker_card[playerid][_card], 4);
  618.     PlayerTextDrawLetterSize        (playerid, poker_card[playerid][_card], 0.009999, 0.100000);
  619.     PlayerTextDrawColor             (playerid, poker_card[playerid][_card], -1);
  620.     PlayerTextDrawSetOutline        (playerid, poker_card[playerid][_card], 0);
  621.     PlayerTextDrawSetProportional   (playerid, poker_card[playerid][_card], 1);
  622.     PlayerTextDrawSetShadow         (playerid, poker_card[playerid][_card], 1);
  623.     PlayerTextDrawUseBox            (playerid, poker_card[playerid][_card], 1);
  624.     PlayerTextDrawBoxColor          (playerid, poker_card[playerid][_card], 255);
  625.     PlayerTextDrawTextSize          (playerid, poker_card[playerid][_card], 93.000000, 149.000000);
  626.     PlayerTextDrawSetSelectable     (playerid, poker_card[playerid][_card], 0);
  627.  
  628.     PlayerTextDrawShow  (playerid, poker_card[playerid][_card]);
  629.    
  630.     return 1;
  631. }
  632.  
  633.  
  634. cPoker_hidePlayerCoins(playerid) {
  635.     if (PlayerText:poker_wager[playerid] != PlayerText:INVALID_TEXT_DRAW) {
  636.         PlayerTextDrawHide(playerid, poker_wager[playerid]);
  637.         PlayerTextDrawDestroy(playerid, poker_wager[playerid]);
  638.     }
  639.    
  640.     return 1;
  641. }
  642.  
  643. cPoker_showPlayerCoins(playerid) {
  644.     cPoker_hidePlayerCoins(playerid);
  645.     new _coins = GetPVarInt(playerid, "ss_pokerCoins");
  646.     new txt[64];
  647.     format(txt, 64, "WAGER~n~$%i", (_coins * 100));
  648.    
  649.     poker_wager[playerid] = CreatePlayerTextDraw(playerid, 510.000000, 176.000000, txt);
  650.     PlayerTextDrawAlignment         (playerid, poker_wager[playerid], 2);
  651.     PlayerTextDrawBackgroundColor   (playerid, poker_wager[playerid], 255);
  652.     PlayerTextDrawFont              (playerid, poker_wager[playerid], 1);
  653.     PlayerTextDrawLetterSize        (playerid, poker_wager[playerid], 0.399998, 2.000000);
  654.     PlayerTextDrawColor             (playerid, poker_wager[playerid], -1);
  655.     PlayerTextDrawSetOutline        (playerid, poker_wager[playerid], 1);
  656.     PlayerTextDrawSetProportional   (playerid, poker_wager[playerid], 1);
  657.     PlayerTextDrawSetSelectable     (playerid, poker_wager[playerid], 0);
  658.  
  659.     PlayerTextDrawShow  (playerid, poker_wager[playerid]);
  660. }
  661.  
  662. cPoker_updateCoins(playerid) {
  663.     if (PlayerText:poker_wager[playerid] != PlayerText:INVALID_TEXT_DRAW) {
  664.    
  665.         new _coins = GetPVarInt(playerid, "ss_pokerCoins");
  666.         new txt[64];
  667.         format(txt, 64, "WAGER~n~$%i", (_coins * 100));
  668.         PlayerTextDrawSetString(playerid, poker_wager[playerid], txt);
  669.        
  670.     }
  671. }
  672.  
  673. cPoker_hidePlayerHold(playerid, _hold) {
  674.     if ((_hold <0) || (_hold >= 5))
  675.         return 0;
  676.  
  677.     if (PlayerText:poker_hold[playerid][_hold] != PlayerText:INVALID_TEXT_DRAW) {
  678.         PlayerTextDrawHide(playerid, poker_hold[playerid][_hold]);
  679.         PlayerTextDrawDestroy(playerid, poker_hold[playerid][_hold]);
  680.     }
  681.    
  682.     return 1;
  683. }
  684.  
  685. cPoker_showPlayerHold(playerid, _hold, _buttonState=HOLD_BUTTON_DISABLED) {
  686.     if ((_hold <0) || (_hold >= 5))
  687.         return 0;
  688.  
  689.     cPoker_hidePlayerHold(playerid, _hold);
  690.    
  691.     poker_hold[playerid][_hold] = CreatePlayerTextDraw(playerid, holdPosX[_hold], 235.0, "Hold");
  692.     PlayerTextDrawAlignment         (playerid, poker_hold[playerid][_hold], 2);
  693.     PlayerTextDrawFont              (playerid, poker_hold[playerid][_hold], 2);
  694.     PlayerTextDrawLetterSize        (playerid, poker_hold[playerid][_hold], 0.299998, 2.000000);
  695.     PlayerTextDrawSetOutline        (playerid, poker_hold[playerid][_hold], 1);
  696.     PlayerTextDrawSetProportional   (playerid, poker_hold[playerid][_hold], 1);
  697.     PlayerTextDrawUseBox            (playerid, poker_hold[playerid][_hold], 1);
  698.     PlayerTextDrawTextSize          (playerid, poker_hold[playerid][_hold], 15.000000, 50.000000);
  699.  
  700.     switch (_buttonState) {
  701.         case HOLD_BUTTON_DISABLED: {
  702.             PlayerTextDrawBackgroundColor   (playerid, poker_hold[playerid][_hold], 808464639);
  703.             PlayerTextDrawColor             (playerid, poker_hold[playerid][_hold], 1077952767);
  704.             PlayerTextDrawBoxColor          (playerid, poker_hold[playerid][_hold], 1077952767);
  705.         }
  706.         case HOLD_BUTTON_NORMAL: {
  707.             PlayerTextDrawBackgroundColor   (playerid, poker_hold[playerid][_hold], 255);
  708.             PlayerTextDrawColor             (playerid, poker_hold[playerid][_hold], -1);
  709.             PlayerTextDrawBoxColor          (playerid, poker_hold[playerid][_hold], -286331649);
  710.             PlayerTextDrawSetSelectable     (playerid, poker_hold[playerid][_hold], 1);
  711.         }
  712.         case HOLD_BUTTON_SELECTED: {
  713.             PlayerTextDrawBackgroundColor   (playerid, poker_hold[playerid][_hold], 255);
  714.             PlayerTextDrawColor             (playerid, poker_hold[playerid][_hold], -1);
  715.             PlayerTextDrawBoxColor          (playerid, poker_hold[playerid][_hold], -7405313);
  716.             PlayerTextDrawSetSelectable     (playerid, poker_hold[playerid][_hold], 1);
  717.         }
  718.     }
  719.    
  720.     PlayerTextDrawShow              (playerid, poker_hold[playerid][_hold]);
  721.    
  722.     return 1;
  723. }
  724.  
  725. stock cPoker_openInterface(playerid) {
  726.     SetPVarInt(playerid, "ss_pokerCoins", 1);
  727.     TextDrawShowForPlayer(playerid, poker_background[0]);
  728.     TextDrawShowForPlayer(playerid, poker_background[1]);
  729.     for (new tdi=0; tdi<6; tdi++) {
  730.         TextDrawShowForPlayer(playerid, poker_coinSelectionBG[tdi]);
  731.         TextDrawShowForPlayer(playerid, poker_coinSelectionText[tdi]);
  732.         TextDrawShowForPlayer(playerid, poker_coinHeadingText[tdi]);
  733.     }
  734.     for (new _p=0; _p<5; _p++) {
  735.         cPoker_showPlayerCard(playerid, _p);
  736.         cPoker_showPlayerHold(playerid, _p);
  737.     }
  738.     cPoker_freshGame(playerid);
  739.     TextDrawShowForPlayer(playerid, poker_deal);
  740.     TextDrawShowForPlayer(playerid, poker_addCoin);
  741.     TextDrawShowForPlayer(playerid, poker_coinValue);
  742.     cPoker_showPlayerCoins(playerid);
  743.    
  744.     SelectTextDraw(playerid, 0xFF0000FF);
  745.     _gCasino_SetPlayerFreezeState(playerid, GC_FREEZESTATE_FROZEN);
  746.     //setPlayerGameTDs(playerid, 1);
  747.  
  748. }
  749.  
  750. stock cPoker_closeInterface(playerid) {
  751.     TextDrawHideForPlayer(playerid, poker_background[0]);
  752.     TextDrawHideForPlayer(playerid, poker_background[1]);
  753.     for (new tdi=0; tdi<6; tdi++) {
  754.         TextDrawHideForPlayer(playerid, poker_coinSelectionBG[tdi]);
  755.         TextDrawHideForPlayer(playerid, poker_coinSelectionText[tdi]);
  756.         TextDrawHideForPlayer(playerid, poker_coinHeadingText[tdi]);
  757.     }
  758.     for (new _p=0; _p<5; _p++) {
  759.         cPoker_hidePlayerCard(playerid, _p);
  760.         cPoker_hidePlayerHold(playerid, _p);
  761.     }
  762.     TextDrawHideForPlayer(playerid, poker_deal);
  763.     TextDrawHideForPlayer(playerid, poker_addCoin);
  764.     TextDrawHideForPlayer(playerid, poker_coinValue);
  765.     cPoker_hidePlayerCoins(playerid);
  766.  
  767.     CancelSelectTextDraw(playerid);
  768.     _gCasino_SetPlayerFreezeState(playerid, GC_FREEZESTATE_UNFROZEN);
  769.     //setPlayerGameTDs(playerid, 0);
  770. }
  771.  
  772. cPoker_deal(playerid) {
  773.     //printf("cPoker_deal(%i) [s]", playerid);
  774.     for (new _c=0; _c<5; _c++) {
  775.         //printf("cPoker_deal(%i) [card:%i] hold = %i", playerid, _c, cPokerGame[playerid][_c][2]);
  776.         if (cPokerGame[playerid][_c][2] == 0) {
  777.             new _c_suit = random(4) + 1;
  778.             new _c_value = random(CARD_KING) + 1;
  779.            
  780.             new cardUsed = true;
  781.             while (cardUsed) {
  782.                 //print ("card");
  783.                 if (cPoker_cardUsed(playerid, _c_suit, _c_value)) {
  784.                     _c_suit = random(4) + 1;
  785.                     _c_value = random(CARD_KING) + 1;
  786.                 } else {
  787.                     cardUsed = false;
  788.                 }
  789.             }
  790.  
  791.             cPoker_showPlayerCard(playerid, _c, _c_suit, _c_value);
  792.             cPokerGame[playerid][_c][0] = _c_suit;
  793.             cPokerGame[playerid][_c][1] = _c_value;
  794.         }
  795.     }
  796.     //printf("cPoker_deal(%i) [e]", playerid);
  797. }
  798.  
  799. cPoker_freshGame(playerid) {
  800.     //printf("cPoker_freshGame(%i) [s]", playerid);
  801.     SetPVarInt(playerid, "ss_pokerState", 0);
  802.     for (new _c=0; _c<5; _c++) {
  803.         cPokerGame[playerid][_c][0] = 0;
  804.         cPokerGame[playerid][_c][1] = 0;
  805.         cPokerGame[playerid][_c][2] = 0;
  806.     }
  807.     //printf("cPoker_freshGame(%i) [e]", playerid);
  808. }
  809.  
  810. cPoker_button(playerid, _button, _value=0) {
  811.     //printf("cPoker_button(%i, %i, %i);", playerid, _button, _value);
  812.     if (GetPVarInt(playerid, "ss_casino_use") == 1) {
  813.         new _machineID = GetPVarInt(playerid, "ss_casino_using");
  814.         new _playerGameState = GetPVarInt(playerid, "ss_pokerState");
  815.         new _coinsWagered = GetPVarInt(playerid, "ss_pokerCoins");
  816.         switch (_button) {
  817.             case CASINO_POKER_BTN_DEAL: {
  818.                 if (_playerGameState == 0) {
  819.                     //print("cPoker_button -> _playerGameState(0) [S]");
  820.                     if (CasinoGetPlayerMoney(playerid) >= (100 * _coinsWagered)) {
  821.                         CallLocalFunction("OnCasinoMoney", "iiii", playerid, _machineID, 100 * _coinsWagered, CASINO_MONEY_CHARGE);
  822.                         cPoker_freshGame(playerid);
  823.                         cPoker_deal(playerid);
  824.                         for (new _c=0; _c<5; _c++) {
  825.                             cPokerGame[playerid][_c][2] = 0;
  826.                             cPoker_showPlayerHold(playerid, _c, HOLD_BUTTON_NORMAL);
  827.                         }
  828.                         SetPVarInt(playerid, "ss_pokerState", 1);
  829.                         //print("cPoker_button -> _playerGameState(0) [E]");
  830.                         CallLocalFunction("OnCasinoMessage", "iis", playerid, _machineID, "Hold any or all of your cards and deal for the second time (Tip: if your happy with your hand, hold them all)");
  831.                     } else {
  832.                         CallLocalFunction("OnCasinoMoney", "iiii", playerid, _machineID, 100 * _coinsWagered, CASINO_MONEY_NOTENOUGH);
  833.                     }
  834.                 } else if (_playerGameState == 1) {
  835.                     //print("cPoker_button -> _playerGameState(1) [S]");
  836.                     cPoker_deal(playerid);
  837.                     SetPVarInt(playerid, "ss_pokerState", 0);
  838.                     new res = cPoker_checkGame(playerid);
  839.                    
  840.                     new msg[128];
  841.                     format(msg, 128, "Hand Result: %s", cPoker_winningType[res]);
  842.                     CallLocalFunction("OnCasinoMessage", "iis", playerid, _machineID, msg);
  843.                    
  844.                     for (new _c=0; _c<5; _c++) {
  845.                         cPokerGame[playerid][_c][2] = 0;
  846.                         cPoker_showPlayerHold(playerid, _c, HOLD_BUTTON_DISABLED);
  847.                     }
  848.                     new winAmm = 0;
  849.                     if (res>0) {
  850.                         winAmm = cPoker_winningCoins(res, _coinsWagered);
  851.                     }
  852.                     CallLocalFunction("OnCasinoMoney", "iiii", playerid, _machineID, 100 * winAmm, CASINO_MONEY_WIN);
  853.                 }
  854.             }
  855.             case CASINO_POKER_BTN_ADDCOIN: {
  856.                 if (_playerGameState == 0) {
  857.                     _coinsWagered++;
  858.                     if (_coinsWagered > 5) {
  859.                         _coinsWagered = 1;
  860.                     }
  861.                     SetPVarInt(playerid, "ss_pokerCoins", _coinsWagered);
  862.                     cPoker_updateCoins(playerid);
  863.                 }
  864.             }
  865.             case CASINO_POKER_BTN_HOLD: {
  866.                 if (_playerGameState == 1) {
  867.                     if (cPokerGame[playerid][_value][2] == 0) {
  868.                         cPoker_showPlayerHold(playerid, _value, HOLD_BUTTON_SELECTED);
  869.                         cPokerGame[playerid][_value][2] = 1;
  870.                     } else {
  871.                         cPoker_showPlayerHold(playerid, _value, HOLD_BUTTON_NORMAL);
  872.                         cPokerGame[playerid][_value][2] = 0;
  873.                     }
  874.                 }
  875.             }
  876.         }
  877.     }
  878.     return 1;
  879. }
  880.  
  881. cPoker_winningCoins(gameResult, coinsWagered) {
  882.     //printf("cPoker_winningCoins(%i, %i, %i)", gameResult, coinsWagered);
  883.     if ((gameResult>=1) && (gameResult<=9)) {
  884.         if ((coinsWagered>=1) && (coinsWagered<=5)) {
  885.             new win = cPoker_winningCoinsValue[gameResult-1][coinsWagered-1];
  886.             //printf(" > %i", win);
  887.             return win;
  888.         }
  889.     }
  890.     return 0;
  891. }
  892.  
  893. cPoker_cardUsed(playerid, _cardSuit, _cardValue) {
  894.     for (new _c=0; _c<5; _c++) {
  895.         if (cPokerGame[playerid][_c][0] == _cardSuit && cPokerGame[playerid][_c][1] == _cardValue) {
  896.             return 1;
  897.         }
  898.     }
  899.     return 0;
  900. }
  901.  
  902. cPoker_checkGameContains(playerid, _card, _suit=CARD_TYPE_NONE, _mode=CPOKER_CHECKMODE_CARD) {
  903.     for (new _c=0; _c<5; _c++) {
  904.         switch (_mode) {
  905.             case CPOKER_CHECKMODE_CARD: {
  906.                 if (cPokerGame[playerid][_c][1] == _card && cPokerGame[playerid][_c][0] == _suit) {
  907.                     return 1;
  908.                 }
  909.             }
  910.             case CPOKER_CHECKMODE_CARDSUIT: {
  911.                 if (cPokerGame[playerid][_c][1] == _card) {
  912.                     return cPokerGame[playerid][_c][0];
  913.                 }
  914.             }
  915.         }
  916.     }
  917.     return 0;
  918. }
  919.  
  920. cPoker_checkGame(playerid) {
  921.    
  922.     new suit_a = cPoker_checkGameContains(playerid, CARD_ACE, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
  923.     ////printf("suit_a: %i", suit_a);
  924.     new suit_2 = cPoker_checkGameContains(playerid, 2, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
  925.     ////printf("suit_2: %i", suit_2);
  926.     new suit_3 = cPoker_checkGameContains(playerid, 3, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
  927.     ////printf("suit_3: %i", suit_3);
  928.     new suit_4 = cPoker_checkGameContains(playerid, 4, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
  929.     ////printf("suit_4: %i", suit_4);
  930.     new suit_5 = cPoker_checkGameContains(playerid, 5, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
  931.     ////printf("suit_5: %i", suit_5);
  932.  
  933.     if (c_suitsEqual(suit_a,suit_2,suit_3,suit_4,suit_5)) {
  934.         ////print("CHECK_ROYALFLUSH");
  935.         return CHECK_ROYALFLUSH;
  936.     }
  937.    
  938.     new suit_10 = cPoker_checkGameContains(playerid, 10, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
  939.     ////printf("suit_10: %i", suit_10);
  940.     new suit_j = cPoker_checkGameContains(playerid, CARD_JACK, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
  941.     ////printf("suit_j: %i", suit_j);
  942.     new suit_q = cPoker_checkGameContains(playerid, CARD_QUEEN, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
  943.     ////printf("suit_q: %i", suit_q);
  944.     new suit_k = cPoker_checkGameContains(playerid, CARD_KING, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
  945.     ////printf("suit_k: %i", suit_k);
  946.    
  947.     if (c_suitsEqual(suit_10,suit_j,suit_q,suit_k,suit_a)) {
  948.         ////print("CHECK_ROYALFLUSH");
  949.         return CHECK_ROYALFLUSH;
  950.     }
  951.    
  952.     new suit_6 = cPoker_checkGameContains(playerid, 6, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
  953.     ////printf("suit_6: %i", suit_6);
  954.     new suit_7 = cPoker_checkGameContains(playerid, 7, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
  955.     ////printf("suit_7: %i", suit_7);
  956.     new suit_8 = cPoker_checkGameContains(playerid, 8, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
  957.     ////printf("suit_8: %i", suit_8);
  958.     new suit_9 = cPoker_checkGameContains(playerid, 9, CARD_TYPE_NONE, CPOKER_CHECKMODE_CARDSUIT);
  959.     ////printf("suit_9: %i", suit_9);
  960.    
  961.     ////print("CHECK_STRAIGHTFLUSH - START");
  962.     if (c_suitsEqual(suit_2,suit_3,suit_4,suit_5,suit_6)) {
  963.         return CHECK_STRAIGHTFLUSH;
  964.     } else if (c_suitsEqual(suit_3,suit_4,suit_5,suit_6,suit_7)) {
  965.         return CHECK_STRAIGHTFLUSH;
  966.     } else if (c_suitsEqual(suit_4,suit_5,suit_6,suit_7,suit_8)) {
  967.         return CHECK_STRAIGHTFLUSH;
  968.     } else if (c_suitsEqual(suit_5,suit_6,suit_7,suit_8,suit_9)) {
  969.         return CHECK_STRAIGHTFLUSH;
  970.     } else if (c_suitsEqual(suit_6,suit_7,suit_8,suit_9,suit_10)) {
  971.         return CHECK_STRAIGHTFLUSH;
  972.     } else if (c_suitsEqual(suit_7,suit_8,suit_9,suit_10,suit_j)) {
  973.         return CHECK_STRAIGHTFLUSH;
  974.     } else if (c_suitsEqual(suit_8,suit_9,suit_10,suit_j,suit_q)) {
  975.         return CHECK_STRAIGHTFLUSH;
  976.     } else if (c_suitsEqual(suit_9,suit_10,suit_j,suit_q,suit_k)) {
  977.         return CHECK_STRAIGHTFLUSH;
  978.     }
  979.     ////print("CHECK_STRAIGHTFLUSH - END");
  980.    
  981.     new countC[13];
  982.     ////print("CHECK_FOUROFAKIND - START");
  983.     for (new _c=0; _c<5; _c++) {
  984.         new _n = cPokerGame[playerid][_c][1];
  985.         ////printf("_n: %i", _n);
  986.         countC[_n-1]++;
  987.         if (countC[_n-1]==4) {
  988.             ////print("CHECK_FOUROFAKIND");
  989.             return CHECK_FOUROFAKIND;
  990.         }
  991.     }
  992.     ////print("CHECK_FOUROFAKIND - END");
  993.    
  994.     ////print("CHECK_FULLHOUSE - START");
  995.     for (new _card=1; _card<=13; _card++) {
  996.         if (countC[_card-1]==3) {
  997.             for (new _subCard=1; _subCard<=13; _subCard++) {
  998.                 if (_subCard != _card) {
  999.                     if (countC[_subCard-1]==2) {
  1000.                         //print("CHECK_FULLHOUSE");
  1001.                         return CHECK_FULLHOUSE;
  1002.                     }
  1003.                 }
  1004.             }
  1005.         }
  1006.     }
  1007.     ////print("CHECK_FULLHOUSE - END");
  1008.    
  1009.     if (c_Equal(cPokerGame[playerid][0][0],cPokerGame[playerid][1][0],cPokerGame[playerid][2][0],cPokerGame[playerid][3][0],cPokerGame[playerid][4][0])) {
  1010.         ////print("CHECK_FLUSH");
  1011.         return CHECK_FLUSH;
  1012.     }
  1013.  
  1014.     ////print("CHECK_STRAIGHT - START");
  1015.     if (c_anySuits(suit_a,suit_2,suit_3,suit_4,suit_5)) {
  1016.         return CHECK_STRAIGHT;
  1017.     } else if (c_anySuits(suit_2,suit_3,suit_4,suit_5,suit_6)) {
  1018.         return CHECK_STRAIGHT;
  1019.     } else if (c_anySuits(suit_3,suit_4,suit_5,suit_6,suit_7)) {
  1020.         return CHECK_STRAIGHT;
  1021.     } else if (c_anySuits(suit_4,suit_5,suit_6,suit_7,suit_8)) {
  1022.         return CHECK_STRAIGHT;
  1023.     } else if (c_anySuits(suit_5,suit_6,suit_7,suit_8,suit_9)) {
  1024.         return CHECK_STRAIGHT;
  1025.     } else if (c_anySuits(suit_6,suit_7,suit_8,suit_9,suit_10)) {
  1026.         return CHECK_STRAIGHT;
  1027.     } else if (c_anySuits(suit_7,suit_8,suit_9,suit_10,suit_j)) {
  1028.         return CHECK_STRAIGHT;
  1029.     } else if (c_anySuits(suit_8,suit_9,suit_10,suit_j,suit_q)) {
  1030.         return CHECK_STRAIGHT;
  1031.     } else if (c_anySuits(suit_9,suit_10,suit_j,suit_q,suit_k)) {
  1032.         return CHECK_STRAIGHT;
  1033.     } else if (c_anySuits(suit_10,suit_j,suit_q,suit_k,suit_a)) {
  1034.         return CHECK_STRAIGHT;
  1035.     }
  1036.     ////print("CHECK_STRAIGHT - END");
  1037.    
  1038.     ////print("CHECK_THREEOFAKIND - START");
  1039.     for (new _card=1; _card<=13; _card++) {
  1040.         if (countC[_card-1]==3) {
  1041.             for (new _subCard=1; _subCard<=13; _subCard++) {
  1042.                 if (_subCard != _card) {
  1043.                     if (countC[_subCard-1]==1) {
  1044.                         for (new _subSubCard=1; _subSubCard<=13; _subSubCard++) {
  1045.                             if (_subCard != _card && _subSubCard != _card && _subCard != _subSubCard) {
  1046.                                 if (countC[_subSubCard-1]==1) {
  1047.                                     return CHECK_THREEOFAKIND;
  1048.                                 }
  1049.                             }
  1050.                         }
  1051.                     }
  1052.                 }
  1053.             }
  1054.         }
  1055.     }
  1056.     ////print("CHECK_THREEOFAKIND - END");
  1057.    
  1058.     ////print("CHECK_TWOPAIRS - START");
  1059.     for (new _card=1; _card<=13; _card++) {
  1060.         ////printf("_card: %i", _card);
  1061.         if (countC[_card-1]==2) {
  1062.             ////printf("countC[_card-1]: %i", countC[_card-1]);
  1063.             for (new _subCard=1; _subCard<=13; _subCard++) {
  1064.                 ////printf("_subCard: %i", _subCard);
  1065.                 if (_subCard != _card) {
  1066.                     if (countC[_subCard-1]==2) {
  1067.                         ////printf("countC[_subCard-1]: %i", countC[_subCard-1]);
  1068.                         return CHECK_TWOPAIRS;
  1069.                     }
  1070.                 }
  1071.             }
  1072.         }
  1073.     }
  1074.     ////print("CHECK_TWOPAIRS - END");
  1075.    
  1076.     ////print("CHECK_JACKORBETTER - START");
  1077.     for (new _c=0; _c<5; _c++) {
  1078.         new _c_v = cPokerGame[playerid][_c][1];
  1079.         if (_c_v >= CARD_JACK || _c_v == CARD_ACE) {
  1080.             return CHECK_JACKORBETTER;
  1081.         }
  1082.     }
  1083.     ////print("CHECK_JACKORBETTER - END");
  1084.    
  1085.     return CHECK_NONE;
  1086. }
  1087.  
  1088.  
  1089.  
  1090.  
  1091. /* HOOKS */
  1092. public OnGameModeInit() {
  1093.     cPoker_genTDs();
  1094.  
  1095.     if (funcidx("_gCasino_OGMI") != -1){
  1096.         return CallLocalFunction("_gCasino_OGMI", "");
  1097.     }
  1098.     return 1;
  1099. }
  1100.  
  1101. public OnPlayerConnect(playerid) {
  1102.     for (new _m=0; _m<5; _m++) {
  1103.         poker_card[playerid][_m] = PlayerText:INVALID_TEXT_DRAW;
  1104.         poker_hold[playerid][_m] = PlayerText:INVALID_TEXT_DRAW;
  1105.     }
  1106.     poker_wager[playerid] = PlayerText:INVALID_TEXT_DRAW;
  1107.  
  1108.     if (funcidx("_gCasino_OPC") != -1){
  1109.         return CallLocalFunction("_gCasino_OPC", "i", playerid);
  1110.     }
  1111.     return 1;
  1112. }
  1113.  
  1114. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
  1115.     if (_gCasino_PRESSED(_gCasino_KEY)) {
  1116.         new _machine = ClosestCasinoMachine(playerid);
  1117.         if (_machine != INVALID_CASINO_MACHINE_ID) {
  1118.             openPlayerCasinoInterface(playerid, _machine);
  1119.             return 0;
  1120.         }
  1121.     }
  1122.  
  1123.     if (funcidx("_gCasino_OPKSC") != -1){
  1124.         return CallLocalFunction("_gCasino_OPKSC", "iii", playerid, newkeys, oldkeys);
  1125.     }
  1126.     return 1;
  1127. }
  1128.  
  1129. public OnPlayerClickTextDraw(playerid, Text:clickedid) {
  1130.     if (GetPVarInt(playerid, "ss_casino_use") == 1) {
  1131.         new _machineID = GetPVarInt(playerid, "ss_casino_using");
  1132.         if (clickedid == Text:INVALID_TEXT_DRAW) {
  1133.             closePlayerCasinoInterface(playerid);
  1134.         } else {
  1135.             switch (_machines[_machineID][cm_type]) {
  1136.                 case CASINO_MACHINE_POKER: {
  1137.                     if (clickedid == poker_deal) {
  1138.                         cPoker_button(playerid, CASINO_POKER_BTN_DEAL);
  1139.                     } else if (clickedid == poker_addCoin) {
  1140.                         cPoker_button(playerid, CASINO_POKER_BTN_ADDCOIN);
  1141.                     }
  1142.                 }
  1143.             }
  1144.         }
  1145.     }
  1146.  
  1147.     if (funcidx("_gCasino_OPCTD") != -1){
  1148.         return CallLocalFunction("_gCasino_OPCTD", "ii", playerid, _:clickedid);
  1149.     }
  1150.     return 1;
  1151. }
  1152.  
  1153. public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid) {
  1154.     if (GetPVarInt(playerid, "ss_casino_use") == 1) {
  1155.         new _machineID = GetPVarInt(playerid, "ss_casino_using");
  1156.         switch (_machines[_machineID][cm_type]) {
  1157.             case CASINO_MACHINE_POKER: {
  1158.                 for (new _b=0; _b<5; _b++) {
  1159.                     if (playertextid == poker_hold[playerid][_b]) {
  1160.                         cPoker_button(playerid, CASINO_POKER_BTN_HOLD, _b);
  1161.                     }
  1162.                 }
  1163.             }
  1164.         }
  1165.     }
  1166.  
  1167.     if (funcidx("_gCasino_OPCPTD") != -1){
  1168.         return CallLocalFunction("_gCasino_OPCPTD", "ii", playerid, _:playertextid);
  1169.     }
  1170.     return 1;
  1171. }
  1172.  
  1173. #if defined _ALS_OnGameModeInit
  1174.   #undef OnGameModeInit
  1175. #else
  1176.   #define _ALS_OnGameModeInit
  1177. #endif
  1178.  
  1179. #if defined _ALS_OnPlayerConnect
  1180.   #undef OnPlayerConnect
  1181. #else
  1182.   #define _ALS_OnPlayerConnect
  1183. #endif
  1184.  
  1185. #if defined _ALS_OnPlayerKeyStateChange
  1186.   #undef OnPlayerKeyStateChange
  1187. #else
  1188.   #define _ALS_OnPlayerKeyStateChange
  1189. #endif
  1190.  
  1191. #if defined _ALS_OnPlayerClickTextDraw
  1192.   #undef OnPlayerClickTextDraw
  1193. #else
  1194.   #define _ALS_OnPlayerClickTextDraw
  1195. #endif
  1196.  
  1197. #if defined _ALS_OnPlayerClickPlayerTextDra
  1198.   #undef OnPlayerClickPlayerTextDraw
  1199. #else
  1200.   #define _ALS_OnPlayerClickPlayerTextDra
  1201. #endif
  1202.  
  1203. #define OnGameModeInit                  _gCasino_OGMI
  1204. #define OnPlayerConnect                 _gCasino_OPC
  1205. #define OnPlayerKeyStateChange          _gCasino_OPKSC
  1206. #define OnPlayerClickTextDraw           _gCasino_OPCTD
  1207. #define OnPlayerClickPlayerTextDraw     _gCasino_OPCPTD
  1208.  
  1209. forward _gCasino_OGMI();
  1210. forward _gCasino_OPC(playerid);
  1211. forward _gCasino_OPKSC(playerid, newkeys, oldkeys);
  1212. forward _gCasino_OPCTD(playerid, Text:clickedid);
  1213. forward _gCasino_OPCPTD(playerid, PlayerText:playertextid);
  1214.  
  1215. /* _gCasino Callbacks */
  1216. forward OnCasinoMoney(playerid, machineid, amount, result);
  1217. forward OnCasinoStart(playerid, machineid);
  1218. forward OnCasinoEnd(playerid, machineid);
  1219. forward OnCasinoMessage(playerid, machineid, message[]);
Add Comment
Please, Sign In to add comment