Advertisement
grimrandomer

Grimrandomer's Casino Script - V1.0.0.2

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