Advertisement
Schneider1988

[FS]Lottery/Keno - by Schneider

Feb 13th, 2015
1,957
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 61.89 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3.  
  4. #define MIN_BET 100
  5. #define MAX_BET 50000
  6.  
  7. #define TIME_BETWEEN_NUMBERS 2000     //(1000 = 1 second)
  8.  
  9. #define DEFAULT_JACKPOT 1000000     // In case a player wins the Jackpot, it will get reset to this amount.
  10. #define JACKPOT_MULTIPLIER 3    // Players bet will be multiplied by this amount and added to the jackpot.
  11.                                 //For example: if JACKPOT_MULTIPLIER is set to '3' and a player bets $1200,  $3600 will be added to the jackpot.
  12.  
  13. #define FILE_PATH "LotteryJackpot.ini"
  14.  
  15. #define HELP_DIALOG 28503
  16.  
  17. new Float:RM[11] =   // Reward Multiplier
  18. {
  19.     0.0,    // 0 matches
  20.     0.5,    // 1 match
  21.     1.0,    // 2 matches
  22.     2.0,    // 3 matches
  23.     4.0,    // 4 matches
  24.     8.0,    // 5 matches
  25.     16.0,   // 6 matches
  26.     32.0,   // 7 matches
  27.     64.0,   // 8 matches
  28.     128.0,  // 9 matches
  29.             // 10 matches will get the jackpot, defined somewhere else.
  30. };
  31.  
  32.  
  33. //PlayerTextdraws
  34. new PlayerText:TD[MAX_PLAYERS][100];        // 100x PlayerTextDraws for the numbers (0-99)
  35. new PlayerText:TDHeader[MAX_PLAYERS];       // PlayerTextDraw for Header  (Either "Lottery", "Winner" or "Loser");
  36. new PlayerText:TDPrize[MAX_PLAYERS][2];     // 2x PlayerTextDraws for showing the rewards  0 = left side (1 to 5 matches),  1 = right side (6 to 10 matches)
  37. new PrizeString[MAX_PLAYERS][2][128];       // These strings will hold the info for above Reward-Textdraws.
  38.  
  39. new PlayerText:TDBet[MAX_PLAYERS];          // PlayerTextDraw that shows the players current bet
  40. new PlayerText:TDNumber[MAX_PLAYERS];       // PlayerTextDraw that shows the current random drawn number
  41. new PlayerText:TDDots[MAX_PLAYERS][10];     // 10x PlayerTextDraws for the circles, encircling the drawn numbers
  42. new PlayerText:TDError[MAX_PLAYERS];        // PlayerTextDraw that will show different Error-Messages.
  43.  
  44. //Global Textdraws
  45. new Text:gTD[34];                           // 33 TextDraws for the main design (Main background, out-/inner-lines, header-background, reset- & help-button.
  46.  
  47. //Buttons
  48. new Text:TDLowerBet;                        // TextDraw for the Lower-bet button
  49. new Text:TDRaiseBet;                        // TextDraw for the Raise-bet button
  50. new Text:TDStart;                           // TextDraw for the PLAY-button
  51. new Text:TDClose;                           // TextDraw for the CLOSE-button
  52.  
  53. //Booleans
  54. new bool:TDSelected[MAX_PLAYERS][100];      // 100x Boolean to check if player has selected/deselected a certain number on his lottery-card.
  55. new bool:AreTDCreated[MAX_PLAYERS];         // Boolean to check if the TextDraws are created for the player.
  56. new bool:AreDotsCreated[MAX_PLAYERS];       // Boolean to check if all 10 Circle-TextDraws are created.
  57.  
  58. //Variables
  59. new Jackpot;                                // This variable will hold the current Jackpot.
  60.  
  61. //Timers
  62. new RandomNumbersTimer[MAX_PLAYERS];        // Timer that shows fast random numbers before revealing the 'REAL' number. On default it does 20 loops of 50ms = 1 second.
  63. new LotteryTimer[MAX_PLAYERS];              // Timer that will trigger the process to pick the next random number.
  64.  
  65. //Other Arrays:
  66. new Bet[MAX_PLAYERS];                       // This array will hold each players current bet.
  67. new LotteryStage[MAX_PLAYERS];              // This array will hold the progress for each player during the whole Lottery-process.
  68. new SelectedNumbers[MAX_PLAYERS];           // This array will count how many numbers each player has selected on his lottery-card.
  69. new RandomNumbersCount[MAX_PLAYERS];        // This array is used to count the number of fast random numbers that are shows before the 'REAL' number is revealed. Used to kill the timer when reaches 20  (x 50ms = 1 second).
  70. new LotteryNumbers[MAX_PLAYERS][10];        // This array will store the final numbers generated by the server for each player.
  71. new LotteryNumbersPicked[MAX_PLAYERS];      // This array will count how many numbers have been picked by the server.
  72. new Lot[MAX_PLAYERS][10];                   // This array will store the numbers selected by each player.
  73. new Matches[MAX_PLAYERS];                   // This array will count how many matches the player got during the drawing.
  74.  
  75.  
  76. // Main Callbacks
  77. public OnFilterScriptInit()
  78. {
  79.     CreateGlobalTextDraws();                // Create Global Textdraws
  80.     for(new i; i<MAX_PLAYERS; i++)          // Loop through the online players
  81.     {
  82.         LotteryStage[i] = -1;               // Reset info
  83.         if(IsPlayerConnected(i))
  84.         {
  85.             for(new j; j<10; j++)
  86.             {
  87.                 LotteryNumbers[i][j] = -1// Reset info
  88.                 Lot[i][j] = -1;             // Reset info
  89.             }
  90.             Bet[i] = MIN_BET;               // Set players bet to minimal bet
  91.             CreatePlayerTextDraws(i);       // Create the PlayerTextDraw
  92.             LotteryNumbersPicked[i] = 0;    // Reset info
  93.         }
  94.     }
  95.     new File:file;
  96.     if (!fexist(FILE_PATH))                 // Check if Jackpot-file not exists
  97.     {
  98.         file = fopen(FILE_PATH,io_write);   // Create new file
  99.         new str[12];
  100.         format(str, 12, "%d", DEFAULT_JACKPOT);
  101.         fwrite(file, str);                  // Write default jackpot value to file
  102.         fclose(file);                       // Close file
  103.         Jackpot = DEFAULT_JACKPOT;          // Set Jackpot-variable to default value
  104.     }
  105.     else                                    // ..if the file already exists..
  106.     {
  107.         file=fopen(FILE_PATH, io_read);     // Open the file
  108.         new str[12];
  109.         while(fread(file, str))             // Read the value from the file
  110.         {
  111.             Jackpot = strval(str);          // Assign the value from the file to the Jackpot-variable
  112.         }
  113.         fclose(file);                       // Close the file
  114.     }
  115.     print("\n--------------------------------------");
  116.     print(" Lottery Filterscript by Schneider");
  117.     print("--------------------------------------\n");
  118.     return 1;
  119. }
  120.  
  121. public OnFilterScriptExit()
  122. {
  123.     for(new i; i<MAX_PLAYERS; i++)                      // Loop through the online players (in case this filterscript gets unloaded before server is shut down)
  124.     {
  125.         if(AreTDCreated[i] == true)                     // Check if PlayerTextDraws are created
  126.         {
  127.             for(new j; j<100; j++)
  128.             {
  129.                 PlayerTextDrawDestroy(i, TD[i][j]);     // Destroy all 100 numbers
  130.             }
  131.             PlayerTextDrawDestroy(i, TDPrize[i][0]);    // Destroy PlayerTextDraw
  132.             PlayerTextDrawDestroy(i, TDPrize[i][1]);    // Destroy PlayerTextDraw
  133.             PlayerTextDrawDestroy(i, TDBet[i]);         // Destroy PlayerTextDraw
  134.             PlayerTextDrawDestroy(i, TDNumber[i]);      // Destroy PlayerTextDraw
  135.             PlayerTextDrawDestroy(i, TDHeader[i]);      // Destroy PlayerTextDraw
  136.             PlayerTextDrawDestroy(i, TDError[i]);       // Destroy PlayerTextDraw
  137.             for(new j; j<10; j++)
  138.             {
  139.                 PlayerTextDrawDestroy(i, TDDots[i][j]); // Destroy the 10 circles
  140.             }
  141.         }
  142.     }
  143.     for(new i=0; i<sizeof(gTD); i++)
  144.     {
  145.         TextDrawDestroy(gTD[i]);                        // Destroy global Textdraws
  146.     }
  147.     TextDrawDestroy(TDLowerBet);                        // Destroy Button Textdraw
  148.     TextDrawDestroy(TDRaiseBet);                        // Destroy Button Textdraw
  149.     TextDrawDestroy(TDStart);                           // Destroy Button Textdraw
  150.     TextDrawDestroy(TDClose);                           // Destroy Button Textdraw
  151.     return 1;
  152. }
  153.  
  154. public OnPlayerConnect(playerid)
  155. {
  156.     LotteryStage[playerid] = -1;            // Reset playerinfo
  157.     Bet[playerid] = MIN_BET;                // Reset playerinfo
  158.     SelectedNumbers[playerid] = 0;          // Reset playerinfo
  159.     RandomNumbersCount[playerid] = 0;       // Reset playerinfo
  160.     LotteryNumbersPicked[playerid] = 0;     // Reset playerinfo
  161.    
  162.     for(new j; j<10; j++)
  163.     {
  164.         LotteryNumbers[playerid][j] = -1;   // Reset playerinfo
  165.         Lot[playerid][j] = -1;              // Reset playerinfo
  166.     }
  167.  
  168.     CreatePlayerTextDraws(playerid);        // Create PlayerTextDraws
  169.     return 1;
  170. }
  171.  
  172. public OnPlayerDisconnect(playerid, reason)
  173. {
  174.     if(AreTDCreated[playerid] == true)                              // Delete PlayerTextDraws if they are created
  175.     {
  176.         for(new i; i<100; i++)
  177.         {
  178.             PlayerTextDrawDestroy(playerid, TD[playerid][i]);       // Destroy PlayerTextDraw
  179.         }
  180.         for(new j; j<10; j++)
  181.         {
  182.             PlayerTextDrawDestroy(playerid, TDDots[playerid][j]);   // Destroy PlayerTextDraw
  183.         }
  184.         PlayerTextDrawDestroy(playerid, TDPrize[playerid][0]);      // Destroy PlayerTextDraw
  185.         PlayerTextDrawDestroy(playerid, TDPrize[playerid][1]);      // Destroy PlayerTextDraw
  186.         PlayerTextDrawDestroy(playerid, TDBet[playerid]);           // Destroy PlayerTextDraw
  187.         PlayerTextDrawDestroy(playerid, TDNumber[playerid]);        // Destroy PlayerTextDraw
  188.         PlayerTextDrawDestroy(playerid, TDHeader[playerid]);        // Destroy PlayerTextDraw
  189.         PlayerTextDrawDestroy(playerid, TDError[playerid]);         // Destroy PlayerTextDraw
  190.         AreTDCreated[playerid] = false;                             // Reset playerinfo
  191.     }
  192.     return 1;
  193. }
  194.  
  195.  
  196. public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
  197. {
  198.     if((LotteryStage[playerid] == 0))                                           // Check if player is in first stage (Stage 0 = Player is able to select numbers)
  199.     {
  200.         if(AreDotsCreated[playerid] == true)                                    // Check if the player has already played a game, so we can reset screen
  201.         {                                  
  202.             for(new i; i<10; i++)
  203.             {
  204.                 PlayerTextDrawDestroy(playerid, TDDots[playerid][i]);           // Destroy the circles around the numbers from previous drawing.
  205.             }
  206.             AreDotsCreated[playerid] = false;                                   // Reset player info
  207.             PlayerTextDrawHide(playerid, TDHeader[playerid]);                   // Hide Header-TextDraw
  208.             PlayerTextDrawSetString(playerid, TDHeader[playerid], "~w~Lottery");// Change the Header-Text to "Lottery";
  209.             PlayerTextDrawShow(playerid, TDHeader[playerid]);                   // Show the Header-TextDraw
  210.            
  211.             PlayerTextDrawHide(playerid, TDPrize[playerid][0]);                 // Hide left reward-textdraw
  212.             PlayerTextDrawHide(playerid, TDPrize[playerid][1]);                 // Hide right reward-textdraw
  213.             new b = Bet[playerid];                                              // Just for shorter writing, store the players bet in a new variable
  214.             format(PrizeString[playerid][0], 128, "01: $%d~n~02: $%d~n~03: $%d~n~04: $%d~n~05: $%d", floatround(b*RM[1]), floatround(b*RM[2]), floatround(b*RM[3]), floatround(b*RM[4]), floatround(b*RM[5]));  // Format left reward-textdraw, showing the possible rewards based on the players bet.
  215.             format(PrizeString[playerid][1], 128, "$%d :06 ~n~$%d :07 ~n~$%d :08 ~n~$%d :09 ~n~$%d :10", floatround(b*RM[6]), floatround(b*RM[7]), floatround(b*RM[8]), floatround(b*RM[9]), Jackpot);          // Format right reward-textdraw, showing the possible rewards based on the players bet.
  216.             PlayerTextDrawSetString(playerid, TDPrize[playerid][0], PrizeString[playerid][0]);  // Set string
  217.             PlayerTextDrawSetString(playerid, TDPrize[playerid][1], PrizeString[playerid][1]);  // Set string
  218.             PlayerTextDrawShow(playerid, TDPrize[playerid][0]);                 // Show updated rewards-textdraw
  219.             PlayerTextDrawShow(playerid, TDPrize[playerid][1]);                 // Show updated rewards-textdraw
  220.  
  221.             PlayerTextDrawHide(playerid, TDNumber[playerid]);                   // Hide the TextDraw that showed the last drawn number
  222.             PlayerTextDrawSetString(playerid, TDNumber[playerid], "  ");        // Change the text to an empty string
  223.             PlayerTextDrawShow(playerid, TDNumber[playerid]);                   // Show the  Textdraw
  224.             PlayerPlaySound(playerid, 1184, 0.0, 0.0, 0.0);                     // Stop the music that is started when player wins the jackpot
  225.         }
  226.         new td;                                                                 // This variable will hold the number the player clicks
  227.         for(new j; j<100; j++)                                                  // Loop through all 100 Number-textdraw
  228.         {
  229.             if(playertextid == TD[playerid][j])                                 // Check on which number the player clicked
  230.             {
  231.                 td = j;                                                         // Store the number in td-variable.
  232.                 break;                                                          // Stop the loop
  233.             }
  234.         }
  235.         PlayerTextDrawHide(playerid, TD[playerid][td]);                         // Hide the clicked number
  236.         if(TDSelected[playerid][td] == false)                                   // Check if the number was NOT selected yet
  237.         {
  238.             if(SelectedNumbers[playerid] == 10)                                 // Check if the player has already selected 10 numbers (so we can give him an error).
  239.             {
  240.                 PlayerTextDrawHide(playerid, TDHeader[playerid]);               // Temporarily hide the header (showing "Lottery")
  241.                 PlayerTextDrawHide(playerid, TDError[playerid]);                // Hide Error Message (in case an error was already showing)
  242.                 PlayerTextDrawSetString(playerid, TDError[playerid], "~r~[Error] ~n~~w~You have already selected ~r~10 ~w~numbers!~n~Press ~g~PLAY ~w~to start!"); // Format an error-message
  243.                 PlayerTextDrawShow(playerid, TDError[playerid]);                // Show the error message
  244.                 SetTimerEx("HideError", 3500, 0, "u", playerid);                // Start timer to hide the Error-message and show the Lottery-header
  245.             }
  246.             else                                                                // ...if player has not selected 10 numbers yet.
  247.             {
  248.                 PlayerTextDrawColor(playerid,TD[playerid][td], 0x46F255FF);     // Change the number-color to green
  249.                 TDSelected[playerid][td] = true;                                // Switch the boolean to true.   (= selected)
  250.                 new slot = GetFreeSlot(playerid);                               // Get a free slot in the Lots[playerid]-array.
  251.                 if(slot != -1)                                                  // Check if no invalid slot has been returned
  252.                 {
  253.                     Lot[playerid][slot] = td;                                   // Store the selected number in the free slot in the players' Lot-array
  254.                 }
  255.                 SelectedNumbers[playerid]++;                                    // Increae the number of selected numbers by 1
  256.             }
  257.         }
  258.         else                                                                    // ... else if the number was already selected by the player
  259.         {
  260.             PlayerTextDrawColor(playerid,TD[playerid][td], 0xD1D1D1FF);         // Change the number-color to grey
  261.             TDSelected[playerid][td] = false;                                   // Switch the boolean to false  (= not selected)
  262.             new slot = FindSlot(playerid, td);                                  // Find in which slot the number was stored in the players Lot-array
  263.             if(slot != -1)
  264.             {
  265.                 Lot[playerid][slot] = -1;                                       // Free up the slot
  266.             }
  267.             SelectedNumbers[playerid]--;                                        // Decrease the number of selected numbers by 1
  268.         }
  269.         PlayerTextDrawShow(playerid, TD[playerid][td]);                         // Show the updated number-textdraw
  270.     }
  271.     return 1;
  272. }
  273.  
  274. public OnPlayerClickTextDraw(playerid, Text:clickedid)
  275. {
  276.     if((_:clickedid != INVALID_TEXT_DRAW) && (LotteryStage[playerid] == 0))     // Check if player is in Stage 0 and if the player has not pressed ESC
  277.     {
  278.         if(AreDotsCreated[playerid] == true)                                    // Same as above... if the player has already finished a game, the screen will be reset for a new game
  279.         {
  280.             for(new i; i<10; i++)
  281.             {
  282.                 PlayerTextDrawDestroy(playerid, TDDots[playerid][i]);           // Destroy the circles from previous game
  283.             }
  284.             AreDotsCreated[playerid] = false;                                   // Reset player info
  285.             PlayerTextDrawHide(playerid, TDHeader[playerid]);                   // Hide the header
  286.             PlayerTextDrawSetString(playerid, TDHeader[playerid], "~w~Lottery");// Change header text back to "Lottery"
  287.             PlayerTextDrawShow(playerid, TDHeader[playerid]);                   // Show updated header
  288.            
  289.             PlayerTextDrawHide(playerid, TDPrize[playerid][0]);                 // Hide left reward-textdraw
  290.             PlayerTextDrawHide(playerid, TDPrize[playerid][1]);                 // Hide right reward-textdraw
  291.             new b = Bet[playerid];                                              // Just for shorter writing, store the players bet in a new variable
  292.             format(PrizeString[playerid][0], 128, "01: $%d~n~02: $%d~n~03: $%d~n~04: $%d~n~05: $%d", floatround(b*RM[1]), floatround(b*RM[2]), floatround(b*RM[3]), floatround(b*RM[4]), floatround(b*RM[5]));  // Format left reward-textdraw, showing the possible rewards based on the players bet.
  293.             format(PrizeString[playerid][1], 128, "$%d :06 ~n~$%d :07 ~n~$%d :08 ~n~$%d :09 ~n~$%d :10", floatround(b*RM[6]), floatround(b*RM[7]), floatround(b*RM[8]), floatround(b*RM[9]), Jackpot);          // Format right reward-textdraw, showing the possible rewards based on the players bet.
  294.             PlayerTextDrawSetString(playerid, TDPrize[playerid][0], PrizeString[playerid][0]);  // Set string
  295.             PlayerTextDrawSetString(playerid, TDPrize[playerid][1], PrizeString[playerid][1]);  // Set string
  296.             PlayerTextDrawShow(playerid, TDPrize[playerid][0]);                 // Show updated rewards-textdraw
  297.             PlayerTextDrawShow(playerid, TDPrize[playerid][1]);                 // Show updated rewards-textdraw
  298.  
  299.             PlayerTextDrawHide(playerid, TDNumber[playerid]);                   // Hide last drawn number-textdraw
  300.             PlayerTextDrawSetString(playerid, TDNumber[playerid], "  ");        // Empty the string
  301.             PlayerTextDrawShow(playerid, TDNumber[playerid]);                   // Show updated textdraw
  302.            
  303.             PlayerPlaySound(playerid, 1184, 0.0, 0.0, 0.0);                     // Stop the music that is started when player wins the jackpot
  304.         }
  305.        
  306.         if(clickedid == TDLowerBet)                                             // If player clicked the Lower-bet button
  307.         {
  308.             if(Bet[playerid] > MIN_BET)                                         // Check if the players bet is still higher than MIN_BET
  309.             {
  310.                 new str[8];
  311.                 Bet[playerid] -= 100;                                           // Subtract $100 from the players' bet
  312.                 format(str, sizeof(str), "$%d", Bet[playerid]);
  313.                 PlayerTextDrawHide(playerid, TDBet[playerid]);                  // Hide the bet-textdraw
  314.                 PlayerTextDrawSetString(playerid, TDBet[playerid], str);        // Update the textdraw string
  315.                 PlayerTextDrawShow(playerid, TDBet[playerid]);                  // Show the updated bet-textdraw
  316.                
  317.                 new b = Bet[playerid];                                          // For shorter writing, store players' current bet in new variable
  318.                 format(PrizeString[playerid][0], 128, "01: $%d~n~02: $%d~n~03: $%d~n~04: $%d~n~05: $%d", floatround(b*RM[1]), floatround(b*RM[2]), floatround(b*RM[3]), floatround(b*RM[4]), floatround(b*RM[5]));  // Format left reward-textdraw, showing the possible rewards based on the players bet.
  319.                 format(PrizeString[playerid][1], 128, "$%d :06 ~n~$%d :07 ~n~$%d :08 ~n~$%d :09 ~n~$%d :10", floatround(b*RM[6]), floatround(b*RM[7]), floatround(b*RM[8]), floatround(b*RM[9]), Jackpot);          // Format right reward-textdraw, showing the possible rewards based on the players bet.
  320.                 PlayerTextDrawSetString(playerid, TDPrize[playerid][0], PrizeString[playerid][0]);      // Update reward-textdraw
  321.                 PlayerTextDrawSetString(playerid, TDPrize[playerid][1], PrizeString[playerid][1]);      // Update reward-textdraw
  322.                 PlayerTextDrawShow(playerid, TDPrize[playerid][0]);
  323.                 PlayerTextDrawShow(playerid, TDPrize[playerid][1]);
  324.             }
  325.         }
  326.         if(clickedid == TDRaiseBet)                                             // Same as above... but raise the bet by $100 instead of decrease.
  327.         {
  328.             if(Bet[playerid] < MAX_BET)
  329.             {
  330.                 new str[8];
  331.                 Bet[playerid] += 100;                                           // Add $100 to the players' bet
  332.                 format(str, sizeof(str), "$%d", Bet[playerid]);
  333.                 PlayerTextDrawHide(playerid, TDBet[playerid]);
  334.                 PlayerTextDrawSetString(playerid, TDBet[playerid], str);
  335.                 PlayerTextDrawShow(playerid, TDBet[playerid]);
  336.                 new b = Bet[playerid];
  337.                 format(PrizeString[playerid][0], 128, "01: $%d~n~02: $%d~n~03: $%d~n~04: $%d~n~05: $%d", floatround(b*RM[1]), floatround(b*RM[2]), floatround(b*RM[3]), floatround(b*RM[4]), floatround(b*RM[5]));
  338.                 format(PrizeString[playerid][1], 128, "$%d :06 ~n~$%d :07 ~n~$%d :08 ~n~$%d :09 ~n~$%d :10", floatround(b*RM[6]), floatround(b*RM[7]), floatround(b*RM[8]), floatround(b*RM[9]), Jackpot);
  339.                 PlayerTextDrawSetString(playerid, TDPrize[playerid][0], PrizeString[playerid][0]);
  340.                 PlayerTextDrawSetString(playerid, TDPrize[playerid][1], PrizeString[playerid][1]);
  341.                 PlayerTextDrawShow(playerid, TDPrize[playerid][0]);
  342.                 PlayerTextDrawShow(playerid, TDPrize[playerid][1]);
  343.             }
  344.         }
  345.         if(clickedid == TDStart)                                                // If the player clicked the PLAY-button
  346.         {
  347.             if(SelectedNumbers[playerid] != 10)                                 // Check if player has NOT selected 10 numbers yet. Give him error in that case.
  348.             {
  349.                 PlayerTextDrawHide(playerid, TDHeader[playerid]);
  350.                 PlayerTextDrawHide(playerid, TDError[playerid]);
  351.                 PlayerTextDrawSetString(playerid, TDError[playerid], "~r~[Error] ~n~~w~You first have to select ~r~10 ~w~numbers!");
  352.                 PlayerTextDrawShow(playerid, TDError[playerid]);
  353.                 SetTimerEx("HideError", 3500, 0, "u", playerid);
  354.             }
  355.             else if(GetPlayerMoney(playerid) < Bet[playerid])                   // Check if player has NOT enough money. Give him error in that case.
  356.             {
  357.                 PlayerTextDrawHide(playerid, TDHeader[playerid]);
  358.                 PlayerTextDrawHide(playerid, TDError[playerid]);
  359.                 PlayerTextDrawSetString(playerid, TDError[playerid], "~r~[Error] ~n~~w~You do not have enough money.");
  360.                 PlayerTextDrawShow(playerid, TDError[playerid]);
  361.                 SetTimerEx("HideError", 3500, 0, "u", playerid);
  362.             }
  363.             else                                                                // If the player has selected 10 numbers and has enough money:
  364.             {
  365.                 GivePlayerMoney(playerid, -Bet[playerid]);                      // Remove the bet from the players' money
  366.                 Jackpot += (Bet[playerid]*JACKPOT_MULTIPLIER);                  // Increase the jackpot by the players bet, multiplied with the defined multiplier (at top of script)
  367.                 new File:file;
  368.                 if (fexist(FILE_PATH))
  369.                 {
  370.                     file = fopen(FILE_PATH,io_write);
  371.                     new str[12];
  372.                     format(str, 12, "%d", Jackpot);
  373.                     fwrite(file, str);                                          // Update the Jackpot-value in the file
  374.                     fclose(file);
  375.                 }
  376.                 LotteryStage[playerid] = 1;                                     // Set the players stage to '1' (= show fast random numbers)
  377.                 LotteryTimer[playerid] = SetTimerEx("Lottery", 50, 0, "u", playerid);   // Start timer to start the lottery.
  378.                 CancelSelectTextDraw(playerid);                                 // Remove the cursor
  379.                 TogglePlayerControllable(playerid, 0);                          // Freeze the player
  380.                 RandomNumbersCount[playerid] = 0;                               // Reset player info
  381.             }
  382.         }
  383.         if(clickedid == TDClose)                                                // If player clicked the CLOSE-button
  384.         {
  385.             HideTDForPlayer(playerid);                                          // Hide all textdraws
  386.             TogglePlayerControllable(playerid, 1);                              // Unfreeze the player
  387.             CancelSelectTextDraw(playerid);                                     // Remove the cursor
  388.         }
  389.         if(clickedid == gTD[10])                                                // If player clicked the Reset-Button
  390.         {
  391.             Bet[playerid] = MIN_BET;                                            // Reset players' bet to default min-value
  392.             new b = Bet[playerid];                                              // For short writing, store players bet in new variable
  393.             format(PrizeString[playerid][0], 128, "01: $%d~n~02: $%d~n~03: $%d~n~04: $%d~n~05: $%d", floatround(b*RM[1]), floatround(b*RM[2]), floatround(b*RM[3]), floatround(b*RM[4]), floatround(b*RM[5]));  // Update the left rewards-textdraw string
  394.             format(PrizeString[playerid][1], 128, "$%d :06 ~n~$%d :07 ~n~$%d :08 ~n~$%d :09 ~n~$%d :10", floatround(b*RM[6]), floatround(b*RM[7]), floatround(b*RM[8]), floatround(b*RM[9]), Jackpot);          // Update the right rewards-textdraw string
  395.             PlayerTextDrawSetString(playerid, TDPrize[playerid][0], PrizeString[playerid][0]);
  396.             PlayerTextDrawSetString(playerid, TDPrize[playerid][1], PrizeString[playerid][1]);
  397.             PlayerTextDrawShow(playerid, TDPrize[playerid][0]);                 // Show updated rewards-textdraw
  398.             PlayerTextDrawShow(playerid, TDPrize[playerid][1]);                 // Show updated rewards-textdraw
  399.            
  400.             new str[8];
  401.             format(str, sizeof(str), "$%d", Bet[playerid]);                     // Update bet-textdraw
  402.             PlayerTextDrawHide(playerid, TDBet[playerid]);
  403.             PlayerTextDrawSetString(playerid, TDBet[playerid], str);
  404.             PlayerTextDrawShow(playerid, TDBet[playerid]);
  405.            
  406.             SelectedNumbers[playerid] = 0;                                      // Reset player info
  407.            
  408.             for(new i; i<10; i++)
  409.             {
  410.                 Lot[playerid][i] = -1;                                          // Reset players lot
  411.             }
  412.             for(new i; i<100; i++)
  413.             {
  414.                 PlayerTextDrawHide(playerid, TD[playerid][i]);
  415.                 PlayerTextDrawColor(playerid,TD[playerid][i], 0xD1D1D1FF);      // Change the color of all numbers back to grey
  416.                 PlayerTextDrawShow(playerid, TD[playerid][i]);
  417.                 TDSelected[playerid][i] = false;                                // Reset info
  418.             }
  419.         }
  420.         if(clickedid == gTD[11])   // Clicked Help-Button                       // If player clicked the Help-button
  421.         {
  422.             new string[800];
  423.             new string2[300];
  424.             format(string2, sizeof(string2), "\n\nYour selected numbers and bet will be remembered and you can\npress the {FF0000}reset{FFFFFF}-button to restore your game to default settings.\n\nMatch all 10 numbers to win the {FFE882}JACKPOT {FFFFFF}of {FFE882}$%d!\n\n\n\t\t{FFE882}GOOD LUCK!", Jackpot);
  425.             format(string, sizeof(string), "{FFFFFF}Welcome to the {9BDB76}Lottery Game! \n\n{FFFFFF}To play this game you have to \nselect {E36B73}10 numbers {FFFFFF}of your choise and {E36B73}set your bet.\n{FFFFFF}You can lower/raise your bet by clicking the arrows({E36B73} <  > {FFFFFF})\n\nWhen you are ready, press the {B1FAC0}'PLAY' {FFFFFF}button to start. \n10 random numbers will be drawn and you will\nreceive a prize depending on the amount of matches and your bet.%s", string2);
  426.             ShowPlayerDialog(playerid, HELP_DIALOG, DIALOG_STYLE_MSGBOX, "Lottery Help", string, "OK", ""); // Show Help-dialog
  427.         }
  428.     }
  429.    
  430.     if((_:clickedid == INVALID_TEXT_DRAW) && (LotteryStage[playerid] == 0))     // If player pressed ESC while in the number-selecting-stage
  431.     {
  432.         HideTDForPlayer(playerid);                                              // Hide all textdraws
  433.         TogglePlayerControllable(playerid, 1);                                  // Unfreeze player
  434.     }
  435.     return 1;
  436. }
  437.  
  438.  
  439. COMMAND:lottery(playerid, params[])                                             //Command: /lottery  to start.
  440. {
  441.     if(LotteryStage[playerid] != -1) return SendClientMessage(playerid, 0xF25D46FF, "{F4C670}[Lottery]: {FFFFFF}You are already playing!");  // Check if player has already opened the Lottery
  442.     LotteryStage[playerid] = 0;                                                 // Set players stage to 0  ( = select numbers)
  443.     new b = Bet[playerid];                                                      // For shorter writing, store players' bet in new variable
  444.     format(PrizeString[playerid][0], 128, "01: $%d~n~02: $%d~n~03: $%d~n~04: $%d~n~05: $%d", floatround(b*RM[1]), floatround(b*RM[2]), floatround(b*RM[3]), floatround(b*RM[4]), floatround(b*RM[5]));
  445.     format(PrizeString[playerid][1], 128, "$%d :06 ~n~$%d :07 ~n~$%d :08 ~n~$%d :09 ~n~$%d :10", floatround(b*RM[6]), floatround(b*RM[7]), floatround(b*RM[8]), floatround(b*RM[9]), Jackpot);
  446.     PlayerTextDrawSetString(playerid, TDPrize[playerid][0], PrizeString[playerid][0]);  // Update rewards-textdraw string
  447.     PlayerTextDrawSetString(playerid, TDPrize[playerid][1], PrizeString[playerid][1]);  // Update rewards-textdraw string
  448.     for(new i; i<sizeof(gTD); i++)
  449.     {
  450.         TextDrawShowForPlayer(playerid, gTD[i]);                                // Show global textdraws
  451.     }
  452.     for(new i; i<100; i++)
  453.     {
  454.         PlayerTextDrawShow(playerid, TD[playerid][i]);                          // Show the numbers
  455.     }
  456.     PlayerTextDrawShow(playerid, TDPrize[playerid][0]);                         // Show rewards (left)
  457.     PlayerTextDrawShow(playerid, TDPrize[playerid][1]);                         // Show rewards (right)
  458.  
  459.     PlayerTextDrawShow(playerid, TDNumber[playerid]);
  460.     PlayerTextDrawShow(playerid, TDHeader[playerid]);
  461.  
  462.     TextDrawShowForPlayer(playerid, TDLowerBet);                                // Show lower-bet button
  463.     TextDrawShowForPlayer(playerid, TDRaiseBet);                                // Show raise-bet button
  464.  
  465.     TextDrawShowForPlayer(playerid, TDStart);                                   // Show PLAY-button
  466.     TextDrawShowForPlayer(playerid, TDClose);                                   // Show CLOSE-button
  467.     new str[8];
  468.     format(str, sizeof(str), "$%d", Bet[playerid]);                             // Format the bet-textdraw
  469.     PlayerTextDrawSetString(playerid, TDBet[playerid], str);
  470.     PlayerTextDrawShow(playerid, TDBet[playerid]);                              // Show the bet-textdraw
  471.  
  472.     SelectTextDraw(playerid, 0xFF4040AA);                                       // Show the cursor
  473.     return 1;
  474. }
  475.  
  476. forward Lottery(playerid);
  477. public Lottery(playerid)                                                        // Main timer
  478. {
  479.     switch(LotteryStage[playerid])                                              // Switch the players stage
  480.     {
  481.         case 1:                                                                 // Stage 1: Intro showing random nummbers 20x/second
  482.         {
  483.             RandomNumbersTimer[playerid] = SetTimerEx("ShowRandomNumbers", 50, 1, "u", playerid); // Start 50ms repeating timer to show fast random numbers before revealing real number.
  484.         }
  485.         case 2:                                                                 // Stage 2: Draw a Number
  486.         {
  487.             new Draw = LotteryNumbersPicked[playerid];                          // For shorter writing, store the amount of picked numbers in new variable
  488.             new bool:found, bool:taken, number;                                 // Create few new variables
  489.             while (found == false)                                              // Loop until a unique number has been found
  490.             {
  491.                 taken = false;                                                  // Reset boolean to false
  492.                 number = random(100);                                           // Generate a random number from 0 to 99
  493.                 for(new i; i<10; i++)                                           // Loop through the already drawn numbers
  494.                 {
  495.                     if(number == LotteryNumbers[playerid][i])                   // Check if generated number has already been picked
  496.                     {
  497.                         taken = true;                                           // ..if yes, set 'taken'  to true
  498.                     }
  499.                 }
  500.                 if(taken == false)                                              // if loop is finished an 'taken' is still 'false' it means we found a unique number
  501.                 {
  502.                     LotteryNumbers[playerid][Draw] = number;                    // Store the new number in the array
  503.                     found = true;                                               // Set 'found' to true to stop the loop
  504.                 }
  505.             }
  506.             new str[5], Float:X = 258.0, Float:Y = 189.0;                       // Create new varibles. The X and Y are the textdraw-coordinates for the circle around number "00", the other coordinates will be caclulated from this point
  507.             format(str, 5, "%02d", number);                                     // Format string to show the generated number
  508.             PlayerTextDrawHide(playerid, TDNumber[playerid]);
  509.             PlayerTextDrawSetString(playerid, TDNumber[playerid], str);
  510.             PlayerTextDrawShow(playerid, TDNumber[playerid]);
  511.    
  512.             new bool:match;                                                     // Create new boolean that will check if a match has been found
  513.             for(new i; i<10; i++)                                               // Loop through all numbers selected by the player
  514.             {
  515.                 if(Lot[playerid][i] == number)                                  // If the new generated number matches a number in the players array...
  516.                 {
  517.                     Matches[playerid]++;                                        // Increase the number of matches by 1
  518.                     match = true;                                               // Set match-boolean to true
  519.                 }
  520.             }
  521.  
  522.             new horizontal;                                                     // Create new variable to keep track of the horizontal collumns
  523.             for(new c; c<(number); c++)                                         // Now we have to calculate the coordinates for the circle around the generated number.
  524.             {
  525.                 X = floatadd(X, 16.0);                                          // Increase the X-coordinate by 16.0
  526.                 horizontal++;                                                   // Increase the horizontal variable by 1
  527.                 if(horizontal == 10)                                            // If we have moved 10 collumns
  528.                 {
  529.                     horizontal = 0;                                             // Set horizontal variable back to 0
  530.                     X = 258.0;                                                  // Set the X-coordinate back to 258.0   (go to first collumn)
  531.                     Y = floatadd(Y, 16.0);                                      // Increase the Y-coordinate by 16.0    (go to next row)
  532.                 }
  533.             }                                                                   // When the loop is finished, we will have the right X- and Y-coordinates for the circle around the number
  534.            
  535.             new Float:x, Float:y, Float:z;
  536.             GetPlayerPos(playerid, x, y, z);
  537.             if(match == true) PlayerPlaySound(playerid, 1057, x, y, z);         // If a match was found, play high beep-sound
  538.             else PlayerPlaySound(playerid, 1085, x, y, z);                      // else if no match was found, play low beep-sound
  539.  
  540.             TDDots[playerid][Draw] = CreatePlayerTextDraw(playerid, X, Y, "O"); // Create Circle-textdraw at the calculated coordinates
  541.             PlayerTextDrawBackgroundColor(playerid,TDDots[playerid][Draw], 255);
  542.             PlayerTextDrawFont(playerid,TDDots[playerid][Draw], 2);
  543.             PlayerTextDrawLetterSize(playerid,TDDots[playerid][Draw], 0.650000, 3.400000);
  544.             if(match == true) PlayerTextDrawColor(playerid,TDDots[playerid][Draw], 0x7DFA2AFF);     // If number matched, make circle bright green
  545.             else PlayerTextDrawColor(playerid,TDDots[playerid][Draw], 0xB3D69CFF);                  // If no match, make circle pale-green
  546.             PlayerTextDrawSetOutline(playerid,TDDots[playerid][Draw], 0);
  547.             PlayerTextDrawSetProportional(playerid,TDDots[playerid][Draw], 1);
  548.             PlayerTextDrawSetShadow(playerid,TDDots[playerid][Draw], 1);
  549.             PlayerTextDrawSetSelectable(playerid,TDDots[playerid][Draw], 0);
  550.             PlayerTextDrawShow(playerid, TDDots[playerid][Draw]);
  551.             new b = Bet[playerid];
  552.             switch(Matches[playerid])   // Switch through the current amount of matches. Giving the current amount a red color while the rest is white.
  553.             {
  554.                 case 0: format(PrizeString[playerid][0], 128, "~w~01: $%d~n~02: $%d~n~03: $%d~n~04: $%d~n~05: $%d", floatround(b*RM[1]), floatround(b*RM[2]), floatround(b*RM[3]), floatround(b*RM[4]), floatround(b*RM[5]));
  555.                 case 1: format(PrizeString[playerid][0], 128, "~r~01: $%d~n~~w~02: $%d~n~03: $%d~n~04: $%d~n~05: $%d", floatround(b*RM[1]), floatround(b*RM[2]), floatround(b*RM[3]), floatround(b*RM[4]), floatround(b*RM[5]));
  556.                 case 2: format(PrizeString[playerid][0], 128, "~w~01: $%d~n~~r~02: $%d~n~~w~03: $%d~n~04: $%d~n~05: $%d", floatround(b*RM[1]), floatround(b*RM[2]), floatround(b*RM[3]), floatround(b*RM[4]), floatround(b*RM[5]));
  557.                 case 3: format(PrizeString[playerid][0], 128, "~w~01: $%d~n~02: $%d~n~~r~03: $%d~n~~w~04: $%d~n~05: $%d", floatround(b*RM[1]), floatround(b*RM[2]), floatround(b*RM[3]), floatround(b*RM[4]), floatround(b*RM[5]));
  558.                 case 4: format(PrizeString[playerid][0], 128, "~w~01: $%d~n~02: $%d~n~03: $%d~n~~r~04: $%d~n~~w~05: $%d",floatround(b*RM[1]), floatround(b*RM[2]), floatround(b*RM[3]), floatround(b*RM[4]), floatround(b*RM[5]));
  559.                 case 5: format(PrizeString[playerid][0], 128, "~w~01: $%d~n~02: $%d~n~03: $%d~n~04: $%d~n~~r~05: $%d", floatround(b*RM[1]), floatround(b*RM[2]), floatround(b*RM[3]), floatround(b*RM[4]), floatround(b*RM[5]));
  560.                
  561.                 case 6: format(PrizeString[playerid][1], 128, "~r~$%d :06 ~n~~w~$%d :07 ~n~$%d :08 ~n~$%d :09 ~n~$%d :10", floatround(b*RM[6]), floatround(b*RM[7]), floatround(b*RM[8]), floatround(b*RM[9]), Jackpot);
  562.                 case 7: format(PrizeString[playerid][1], 128, "~w~$%d :06 ~n~~r~$%d :07 ~n~~w~$%d :08 ~n~$%d :09 ~n~$%d :10", floatround(b*RM[6]), floatround(b*RM[7]), floatround(b*RM[8]), floatround(b*RM[9]), Jackpot);
  563.                 case 8: format(PrizeString[playerid][1], 128, "~w~$%d :06 ~n~$%d :07 ~n~~r~$%d :08 ~n~~w~$%d :09 ~n~$%d :10", floatround(b*RM[6]), floatround(b*RM[7]), floatround(b*RM[8]), floatround(b*RM[9]), Jackpot);
  564.                 case 9: format(PrizeString[playerid][1], 128, "~w~$%d :06 ~n~$%d :07 ~n~$%d :08 ~n~~r~$%d :09 ~n~~w~$%d :10", floatround(b*RM[6]), floatround(b*RM[7]), floatround(b*RM[8]), floatround(b*RM[9]), Jackpot);
  565.                 case 10: format(PrizeString[playerid][1], 128, "~w~$%d :06 ~n~$%d :07 ~n~$%d :08 ~n~$%d :09 ~n~~r~$%d :10", floatround(b*RM[6]), floatround(b*RM[7]), floatround(b*RM[8]), floatround(b*RM[9]), Jackpot);
  566.             }
  567.             switch(Matches[playerid])
  568.             {
  569.                 case 0..5: format(PrizeString[playerid][1], 128, "~w~$%d :06 ~n~$%d :07 ~n~$%d :08 ~n~$%d :09 ~n~$%d :10", floatround(b*RM[6]), floatround(b*RM[7]), floatround(b*RM[8]), floatround(b*RM[9]), Jackpot);
  570.                 case 6..10: format(PrizeString[playerid][0], 128, "~w~01: $%d~n~02: $%d~n~03: $%d~n~04: $%d~n~05: $%d", floatround(b*RM[1]), floatround(b*RM[2]), floatround(b*RM[3]), floatround(b*RM[4]), floatround(b*RM[5]));
  571.             }
  572.             PlayerTextDrawHide(playerid, TDPrize[playerid][0]);
  573.             PlayerTextDrawHide(playerid, TDPrize[playerid][1]);
  574.             PlayerTextDrawSetString(playerid, TDPrize[playerid][0], PrizeString[playerid][0]);
  575.             PlayerTextDrawSetString(playerid, TDPrize[playerid][1], PrizeString[playerid][1]);
  576.             PlayerTextDrawShow(playerid, TDPrize[playerid][0]);                 // Show the updates rewards-textdraws
  577.             PlayerTextDrawShow(playerid, TDPrize[playerid][1]);                 // Show the updates rewards-textdraws
  578.  
  579.             Draw++;                                                             // Increase the count of drawn numbers by 1
  580.             if(Draw == 10)                                                      // If 10 numbers have been drawn then finish the game
  581.             {
  582.                 AreDotsCreated[playerid] = true;                                // Set boolian to check if all cicles have been created to 'true'
  583.                 LotteryStage[playerid] = 3;                                     // Set stage to 3  ( = finish game)
  584.                 LotteryTimer[playerid] = SetTimerEx("Lottery", 400, 0, "u", playerid);  // Start timer to finish the game
  585.             }
  586.             else                                                                // If less than 10 numbers have been draws
  587.             {
  588.                 LotteryNumbersPicked[playerid]++;                               // Increase the global amount of drawn numbers by 1
  589.                 LotteryStage[playerid] = 1;                                     // Set stage to '1'  ( = show fast random numbers)
  590.                 LotteryTimer[playerid] = SetTimerEx("Lottery", TIME_BETWEEN_NUMBERS, 0, "u", playerid);     //Start timer to pick next number
  591.             }
  592.         }
  593.         case 3:                                                                 // End of the Game
  594.         {
  595.             new str[128];
  596.             switch (Matches[playerid])                                          // Switch through the amount of matches
  597.             {
  598.                 case 0:                                                         // If no matches at all...
  599.                 {
  600.                     format(str, sizeof(str), "{F4C670}[Lottery]: {FFFFFF}Sorry, you do not have any matches.. Better luck next time!"),  // Player = loser
  601.                     SendClientMessage(playerid, 0xF2B346FF, str);
  602.                     PlayerTextDrawHide(playerid, TDHeader[playerid]);
  603.                     PlayerTextDrawSetString(playerid, TDHeader[playerid], "~r~Loser!");
  604.                     PlayerTextDrawShow(playerid, TDHeader[playerid]);
  605.                 }
  606.                 case 1..9:                                                      // If 1 to 9 numbers match with the players selection...
  607.                 {
  608.                     format(str, sizeof(str), "{F4C670}[Lottery]: {FFFFFF}Congratulations! You've got {55CF5F}%d {FFFFFF}match(es) and won {55CF5F}$%d{FFFFFF}!", Matches[playerid], floatround(Bet[playerid]*RM[Matches[playerid]]));
  609.                     SendClientMessage(playerid, 0x00FF00FF, str);
  610.                     GivePlayerMoney(playerid, floatround(Bet[playerid]*RM[Matches[playerid]])); // Give player his prize
  611.                     PlayerTextDrawHide(playerid, TDHeader[playerid]);
  612.                     PlayerTextDrawSetString(playerid, TDHeader[playerid], "~w~Winner!");
  613.                     PlayerTextDrawShow(playerid, TDHeader[playerid]);
  614.                 }
  615.                 case 10:                                                        // If all 10 selected numbers match, the player wins the Jackpot
  616.                 {
  617.                     PlayerTextDrawHide(playerid, TDHeader[playerid]);
  618.                     PlayerTextDrawSetString(playerid, TDHeader[playerid], "~w~Jackpot!!");
  619.                     PlayerTextDrawShow(playerid, TDHeader[playerid]);
  620.                     new pName[MAX_PLAYER_NAME];
  621.                     GetPlayerName(playerid, pName, sizeof(pName));
  622.                     format(str, sizeof(str), "{F4C670}[Lottery]: {55CF5F}%s {FFFFFF}has won the {FF0000}JACKPOT {FFFFFF}of {55CF5F}$%d! {FFFFFF}Congratulations!!", pName, Jackpot);
  623.                     SendClientMessageToAll(-1, str);
  624.                     format(str, sizeof(str), " {FFFFFF}Congratulations! You've got {55CF5F}10 {FFFFFF}matches and won the {FF0000}JACKPOT {FFFFFF}of {55CF5F}$%d!!!", Jackpot);
  625.                     SendClientMessage(playerid, -1, str);
  626.  
  627.                     GivePlayerMoney(playerid, Jackpot);                         // Give player the Jackpot
  628.                    
  629.                     new Float:x, Float:y, Float:z;
  630.                     GetPlayerPos(playerid, x, y, z);
  631.                     PlayerPlaySound(playerid, 1183, x, y, z);                   // Play music
  632.  
  633.                     new File:file, string[12];                                  // Reset the jackpot to its default in the file
  634.                     file = fopen(FILE_PATH,io_write);
  635.                     format(string, 12, "%d", DEFAULT_JACKPOT);
  636.                     fwrite(file, string);
  637.                     fclose(file);
  638.                     Jackpot = DEFAULT_JACKPOT;
  639.                 }
  640.             }
  641.             LotteryNumbersPicked[playerid] = 0;                                 // Reset player info
  642.             LotteryStage[playerid] = 0;                                         // Reset player info (Let player select new numbers)
  643.             Matches[playerid] = 0;                                              // Reset player info
  644.             SelectTextDraw(playerid, 0xFF4040AA);                               // Show cursor to select new numbers
  645.         }
  646.     }
  647.     return 1;
  648. }
  649.  
  650. forward ShowRandomNumbers(playerid);
  651. public ShowRandomNumbers(playerid)                                              // Before a random number is drawn, a bunch of random numbers will flash for a second
  652. {
  653.     new str[5];
  654.     format(str, 5, "%02d", random(100));                                        // Format a string with a random number
  655.     PlayerTextDrawHide(playerid, TDNumber[playerid]);
  656.     PlayerTextDrawSetString(playerid, TDNumber[playerid], str);
  657.     PlayerTextDrawShow(playerid, TDNumber[playerid]);                           // Show the number
  658.     RandomNumbersCount[playerid]++;                                             // Increase the counter by 1
  659.     if(RandomNumbersCount[playerid] == 20)                                      // If 20 random numbers have been shown
  660.     {
  661.         KillTimer(RandomNumbersTimer[playerid]);                                // Kill the timer
  662.         RandomNumbersCount[playerid] = 0;                                       // Reset player info
  663.         LotteryStage[playerid] = 2;                                             // Set stage to 2 ( = draw next number)
  664.         Lottery(playerid);                                                      // Call the lottery-function
  665.     }
  666.     return 1;
  667. }
  668.  
  669. forward HideError(playerid);
  670. public HideError(playerid)                                                      // Triggered by timer when an error-message is shown
  671. {
  672.     PlayerTextDrawHide(playerid, TDError[playerid]);                            // Hide the error-textdraw
  673.     PlayerTextDrawShow(playerid, TDHeader[playerid]);                           // Show the Lottery-header
  674.     return 1;
  675. }
  676.  
  677. GetFreeSlot(playerid)                                                           // This function will return a free (if any) slot in the players Lot-array
  678. {
  679.     for(new i; i<10; i++)                                                       // Loop through the 10 slots in the  players' Lot-array
  680.     {
  681.         if(Lot[playerid][i] == -1) return i;                                    // If the value in this slot is empty (-1) return the slot
  682.     }
  683.     return -1;                                                                  // If all slots are full, return -1
  684. }
  685.  
  686. FindSlot(playerid, number)                                                      // This function look in which slot a given number is stored
  687. {
  688.     for(new i; i<10; i++)                                                       // Loop through the 10 slots in the players' Lot-array
  689.     {
  690.         if(Lot[playerid][i] == number) return i;                                // If the given number matches with the stored number in this slot, return the slot
  691.     }
  692.     return -1;                                                                  // If the given number is not in the array, return -1
  693. }
  694.  
  695. CreatePlayerTextDraws(playerid)                                                 // Create all PlayerTextDraws
  696. {
  697.     new str[5], Float:X = 267.0, Float:Y = 200.0, count;                        // Start with the 100 numbers, they are placed in a 10x10 grid. The coordinates will be calculated from 1 starting point (location of number "00")
  698.     for(new i; i<10; i++)                                                       // Loop 10x to create the rows
  699.     {
  700.         X = 267.0;
  701.         for(new j; j<10; j++)                                                   // Loop 10x to create the collumns.
  702.         {
  703.             format(str, sizeof(str), "%02d", count);
  704.             TD[playerid][count] = CreatePlayerTextDraw(playerid, X, Y, str);
  705.             PlayerTextDrawAlignment(playerid,TD[playerid][count], 2);
  706.             PlayerTextDrawBackgroundColor(playerid,TD[playerid][count], 255);
  707.             PlayerTextDrawFont(playerid,TD[playerid][count], 1);
  708.             PlayerTextDrawLetterSize(playerid,TD[playerid][count], 0.220000, 1.200000);
  709.             PlayerTextDrawColor(playerid,TD[playerid][count], 0xD1D1D1FF);
  710.             PlayerTextDrawSetOutline(playerid,TD[playerid][count], 1);
  711.             PlayerTextDrawSetProportional(playerid,TD[playerid][count], 1);
  712.             PlayerTextDrawSetShadow(playerid,TD[playerid][count], 1);
  713.             PlayerTextDrawUseBox(playerid,TD[playerid][count], 1);
  714.             PlayerTextDrawBoxColor(playerid,TD[playerid][count], 0);
  715.             PlayerTextDrawTextSize(playerid,TD[playerid][count], 8.000000, 10.000000);
  716.             PlayerTextDrawSetSelectable(playerid,TD[playerid][count], 1);
  717.             X = floatadd(X, 16.0);
  718.             count++;
  719.         }
  720.         Y = floatadd(Y, 16.0);
  721.     }
  722.     TDPrize[playerid][0] = CreatePlayerTextDraw(playerid, 259.000000, 150.000000, "01: $000~n~02: $000~n~03: $000~n~04: $000~n~05: $000");
  723.     PlayerTextDrawBackgroundColor(playerid, TDPrize[playerid][0], 255);
  724.     PlayerTextDrawFont(playerid, TDPrize[playerid][0], 1);
  725.     PlayerTextDrawLetterSize(playerid, TDPrize[playerid][0], 0.230000, 0.95);
  726.     PlayerTextDrawColor(playerid, TDPrize[playerid][0], 0xF2E4CEFF);
  727.     PlayerTextDrawSetOutline(playerid, TDPrize[playerid][0], 0);
  728.     PlayerTextDrawSetProportional(playerid, TDPrize[playerid][0], 0);
  729.     PlayerTextDrawSetShadow(playerid, TDPrize[playerid][0], 1);
  730.     PlayerTextDrawSetSelectable(playerid, TDPrize[playerid][0], 0);
  731.    
  732.     TDPrize[playerid][1] = CreatePlayerTextDraw(playerid, 418.000000, 150.000000, "$000 :06 ~n~$000 :07 ~n~$000 :08 ~n~$000 :09 ~n~$000 :10");
  733.     PlayerTextDrawAlignment(playerid, TDPrize[playerid][1], 3);
  734.     PlayerTextDrawBackgroundColor(playerid, TDPrize[playerid][1], 255);
  735.     PlayerTextDrawFont(playerid, TDPrize[playerid][1], 1);
  736.     PlayerTextDrawLetterSize(playerid, TDPrize[playerid][1], 0.230000, 0.95);
  737.     PlayerTextDrawColor(playerid, TDPrize[playerid][1], 0xF2E4CEFF);
  738.     PlayerTextDrawSetOutline(playerid, TDPrize[playerid][1], 0);
  739.     PlayerTextDrawSetProportional(playerid, TDPrize[playerid][1], 0);
  740.     PlayerTextDrawSetShadow(playerid, TDPrize[playerid][1], 1);
  741.     PlayerTextDrawSetSelectable(playerid, TDPrize[playerid][1], 0);
  742.    
  743.     TDBet[playerid] = CreatePlayerTextDraw(playerid,340.000000, 150.000000, "$0000");   // Current Bet Text
  744.     PlayerTextDrawAlignment(playerid,TDBet[playerid], 2);
  745.     PlayerTextDrawBackgroundColor(playerid,TDBet[playerid], 255);
  746.     PlayerTextDrawFont(playerid,TDBet[playerid], 1);
  747.     PlayerTextDrawLetterSize(playerid,TDBet[playerid], 0.230000, 1.000000);
  748.     PlayerTextDrawColor(playerid,TDBet[playerid], -173980929);
  749.     PlayerTextDrawSetOutline(playerid,TDBet[playerid], 0);
  750.     PlayerTextDrawSetProportional(playerid,TDBet[playerid], 1);
  751.     PlayerTextDrawSetShadow(playerid,TDBet[playerid], 1);
  752.     PlayerTextDrawSetSelectable(playerid,TDBet[playerid], 0);
  753.    
  754.     TDNumber[playerid] = CreatePlayerTextDraw(playerid,340.000000, 167.000000, "  ");     // Drawn Number
  755.     PlayerTextDrawAlignment(playerid,TDNumber[playerid], 2);
  756.     PlayerTextDrawBackgroundColor(playerid,TDNumber[playerid], 255);
  757.     PlayerTextDrawFont(playerid,TDNumber[playerid], 1);
  758.     PlayerTextDrawLetterSize(playerid,TDNumber[playerid], 0.549999, 2.199999);
  759.     PlayerTextDrawColor(playerid,TDNumber[playerid], -1);
  760.     PlayerTextDrawSetOutline(playerid,TDNumber[playerid], 1);
  761.     PlayerTextDrawSetProportional(playerid,TDNumber[playerid], 1);
  762.     PlayerTextDrawSetSelectable(playerid,TDNumber[playerid], 0);
  763.  
  764.     TDHeader[playerid] = CreatePlayerTextDraw(playerid, 340.000000, 104.000000, "Lottery");   // Header Text
  765.     PlayerTextDrawAlignment(playerid, TDHeader[playerid], 2);
  766.     PlayerTextDrawBackgroundColor(playerid, TDHeader[playerid], 255);
  767.     PlayerTextDrawFont(playerid, TDHeader[playerid], 0);
  768.     PlayerTextDrawLetterSize(playerid, TDHeader[playerid], 0.910000, 3.000000);
  769.     PlayerTextDrawColor(playerid, TDHeader[playerid], 0xF2E4CEFF);
  770.     PlayerTextDrawSetOutline(playerid, TDHeader[playerid], 1);
  771.     PlayerTextDrawSetProportional(playerid, TDHeader[playerid], 1);
  772.     PlayerTextDrawSetShadow(playerid, TDHeader[playerid], 1);
  773.  
  774.     TDError[playerid] = CreatePlayerTextDraw(playerid,340.000000, 107.000000, "~r~[Error] ~n~~w~You have already selected ~r~10 ~w~numbers!~n~Press ~g~PLAY ~w~to start!");
  775.     PlayerTextDrawAlignment(playerid,TDError[playerid], 2);
  776.     PlayerTextDrawBackgroundColor(playerid,TDError[playerid], 255);
  777.     PlayerTextDrawFont(playerid,TDError[playerid], 1);
  778.     PlayerTextDrawLetterSize(playerid,TDError[playerid], 0.200000, 1.100000);
  779.     PlayerTextDrawColor(playerid,TDError[playerid], -1);
  780.     PlayerTextDrawSetOutline(playerid,TDError[playerid], 1);
  781.     PlayerTextDrawSetProportional(playerid,TDError[playerid], 1);
  782.     PlayerTextDrawSetSelectable(playerid,TDError[playerid], 0);
  783.  
  784.     AreTDCreated[playerid] = true;
  785. }
  786.  
  787. CreateGlobalTextDraws()
  788. {
  789.     new count, Float:X = 259.0, Float:Y = 199.0;
  790.    
  791.     gTD[count] = TextDrawCreate(339.000000, 107.000000, "~n~");   // Background
  792.     TextDrawAlignment(gTD[count], 2);
  793.     TextDrawBackgroundColor(gTD[count], 255);
  794.     TextDrawFont(gTD[count], 1);
  795.     TextDrawLetterSize(gTD[count], 0.759999, 27.700000);
  796.     TextDrawColor(gTD[count], -1);
  797.     TextDrawSetOutline(gTD[count], 0);
  798.     TextDrawSetProportional(gTD[count], 1);
  799.     TextDrawSetShadow(gTD[count], 1);
  800.     TextDrawUseBox(gTD[count], 1);
  801.     TextDrawBoxColor(gTD[count], 120);
  802.     TextDrawTextSize(gTD[count], 124.000000, 159.000000);
  803.     TextDrawSetSelectable(gTD[count], 0);
  804.    
  805.     count++;
  806.    
  807.     gTD[count] = TextDrawCreate(339.000000, 108.000000, "~n~");   //Header Background
  808.     TextDrawAlignment(gTD[count], 2);
  809.     TextDrawBackgroundColor(gTD[count], 255);
  810.     TextDrawFont(gTD[count], 1);
  811.     TextDrawLetterSize(gTD[count], 0.500000, 3.099999);
  812.     TextDrawColor(gTD[count], 0xB5FFF6FF);
  813.     TextDrawSetOutline(gTD[count], 0);
  814.     TextDrawSetProportional(gTD[count], 1);
  815.     TextDrawSetShadow(gTD[count], 1);
  816.     TextDrawUseBox(gTD[count], 1);
  817.     TextDrawBoxColor(gTD[count], 0xB5FFF655);
  818.     TextDrawTextSize(gTD[count], 40.000000, -170.000000);
  819.     TextDrawSetSelectable(gTD[count], 0);
  820.  
  821.     count++;
  822.  
  823.     gTD[count] = TextDrawCreate(257.000000, 107.000000, "~n~");    //Outline Right
  824.     TextDrawAlignment(gTD[count], 2);
  825.     TextDrawBackgroundColor(gTD[count], 255);
  826.     TextDrawFont(gTD[count], 1);
  827.     TextDrawLetterSize(gTD[count], 0.500000, 27.799999);
  828.     TextDrawColor(gTD[count], -1);
  829.     TextDrawSetOutline(gTD[count], 0);
  830.     TextDrawSetProportional(gTD[count], 1);
  831.     TextDrawSetShadow(gTD[count], 1);
  832.     TextDrawUseBox(gTD[count], 1);
  833.     TextDrawBoxColor(gTD[count], 255);
  834.     TextDrawTextSize(gTD[count], 30.000000, -1.000000);
  835.     TextDrawSetSelectable(gTD[count], 0);
  836.  
  837.     count++;
  838.  
  839.     gTD[count] = TextDrawCreate(421.000000, 107.000000, "~n~");   // Outline Left
  840.     TextDrawAlignment(gTD[count], 2);
  841.     TextDrawBackgroundColor(gTD[count], 255);
  842.     TextDrawFont(gTD[count], 1);
  843.     TextDrawLetterSize(gTD[count], 0.500000, 27.799999);
  844.     TextDrawColor(gTD[count], -1);
  845.     TextDrawSetOutline(gTD[count], 0);
  846.     TextDrawSetProportional(gTD[count], 1);
  847.     TextDrawSetShadow(gTD[count], 1);
  848.     TextDrawUseBox(gTD[count], 1);
  849.     TextDrawBoxColor(gTD[count], 255);
  850.     TextDrawTextSize(gTD[count], 30.000000, -1.000000);
  851.     TextDrawSetSelectable(gTD[count], 0);
  852.  
  853.     count++;
  854.    
  855.     gTD[count] = TextDrawCreate(339.000000, 104.000000, "~n~");  //Outline Top
  856.     TextDrawAlignment(gTD[count], 2);
  857.     TextDrawBackgroundColor(gTD[count], 255);
  858.     TextDrawFont(gTD[count], 1);
  859.     TextDrawLetterSize(gTD[count], 0.500000, -0.000000);
  860.     TextDrawColor(gTD[count], -1);
  861.     TextDrawSetOutline(gTD[count], 0);
  862.     TextDrawSetProportional(gTD[count], 1);
  863.     TextDrawSetShadow(gTD[count], 1);
  864.     TextDrawUseBox(gTD[count], 1);
  865.     TextDrawBoxColor(gTD[count], 255);
  866.     TextDrawTextSize(gTD[count], 40.000000, -170.000000);
  867.     TextDrawSetSelectable(gTD[count], 0);
  868.  
  869.     count++;
  870.    
  871.     gTD[count] = TextDrawCreate(339.000000, 359.000000, "~n~");  //Outline Onder
  872.     TextDrawAlignment(gTD[count], 2);
  873.     TextDrawBackgroundColor(gTD[count], 255);
  874.     TextDrawFont(gTD[count], 1);
  875.     TextDrawLetterSize(gTD[count], 0.500000, -0.000000);
  876.     TextDrawColor(gTD[count], -1);
  877.     TextDrawSetOutline(gTD[count], 0);
  878.     TextDrawSetProportional(gTD[count], 1);
  879.     TextDrawSetShadow(gTD[count], 1);
  880.     TextDrawUseBox(gTD[count], 1);
  881.     TextDrawBoxColor(gTD[count], 255);
  882.     TextDrawTextSize(gTD[count], 40.000000, -170.000000);
  883.     TextDrawSetSelectable(gTD[count], 0);
  884.  
  885.     count++;
  886.    
  887.     gTD[count] = TextDrawCreate(313.500000, 150.000000, "ld_beat:chit");   //Circle Outline
  888.     TextDrawLetterSize(gTD[count], 0.000000, 0.000000);
  889.     TextDrawTextSize(gTD[count], 53.0, 58.0);
  890.     TextDrawAlignment(gTD[count], 2);
  891.     TextDrawColor(gTD[count], 255);
  892.     TextDrawSetShadow(gTD[count], 2);
  893.     TextDrawSetOutline(gTD[count], 2);
  894.     TextDrawBackgroundColor(gTD[count], 0x00000000);
  895.     TextDrawFont(gTD[count], 4);
  896.  
  897.     count++;
  898.  
  899.     gTD[count] = TextDrawCreate(317.500000, 154.000000, "ld_beat:chit");   //Circle
  900.     TextDrawLetterSize(gTD[count], 0.000000, 0.000000);
  901.     TextDrawTextSize(gTD[count], 45.0, 50.0);
  902.     TextDrawAlignment(gTD[count], 2);
  903.     TextDrawColor(gTD[count], 0xB1FAC0FF);
  904.     TextDrawSetShadow(gTD[count], 2);
  905.     TextDrawSetOutline(gTD[count], 2);
  906.     TextDrawBackgroundColor(gTD[count], 0x00000000);
  907.     TextDrawFont(gTD[count], 4);
  908.  
  909.     count++;
  910.    
  911.     gTD[count] = TextDrawCreate(259.000000, 143.000000, "Matches / Prize:");    //Matches / Prize text
  912.     TextDrawBackgroundColor(gTD[count], 255);
  913.     TextDrawFont(gTD[count], 1);
  914.     TextDrawLetterSize(gTD[count], 0.139999, 0.699999);
  915.     TextDrawColor(gTD[count], 0xB1FAC0FF);
  916.     TextDrawSetOutline(gTD[count], 0);
  917.     TextDrawSetProportional(gTD[count], 1);
  918.     TextDrawSetShadow(gTD[count], 1);
  919.     TextDrawSetSelectable(gTD[count], 0);
  920.  
  921.     count++;
  922.  
  923.     gTD[count] = TextDrawCreate(340.000000, 139.000000, "BET");       // Bet Text
  924.     TextDrawAlignment(gTD[count], 2);
  925.     TextDrawBackgroundColor(gTD[count], 255);
  926.     TextDrawFont(gTD[count], 1);
  927.     TextDrawLetterSize(gTD[count], 0.290000, 1.000000);
  928.     TextDrawColor(gTD[count], 0xB1FAC0FF);
  929.     TextDrawSetOutline(gTD[count], 0);
  930.     TextDrawSetProportional(gTD[count], 1);
  931.     TextDrawSetShadow(gTD[count], 1);
  932.     TextDrawSetSelectable(gTD[count], 0);
  933.  
  934.     count++;
  935.  
  936.     gTD[count] = TextDrawCreate(268.000000, 129.000000, "Reset");
  937.     TextDrawAlignment(gTD[count], 2);
  938.     TextDrawBackgroundColor(gTD[count], 255);
  939.     TextDrawFont(gTD[count], 1);
  940.     TextDrawLetterSize(gTD[count], 0.170000, 0.899999);
  941.     TextDrawColor(gTD[count], -16776961);
  942.     TextDrawSetOutline(gTD[count], 1);
  943.     TextDrawSetProportional(gTD[count], 1);
  944.     TextDrawUseBox(gTD[count], 1);
  945.     TextDrawBoxColor(gTD[count], 0);
  946.     TextDrawTextSize(gTD[count], 10.000000, 30.000000);
  947.     TextDrawSetSelectable(gTD[count], 1);
  948.    
  949.     count++;
  950.  
  951.     gTD[count] = TextDrawCreate(411.000000, 129.000000, "Help");
  952.     TextDrawAlignment(gTD[count], 2);
  953.     TextDrawBackgroundColor(gTD[count], 255);
  954.     TextDrawFont(gTD[count], 1);
  955.     TextDrawLetterSize(gTD[count], 0.170000, 0.899999);
  956.     TextDrawColor(gTD[count], 16777215);
  957.     TextDrawSetOutline(gTD[count], 1);
  958.     TextDrawSetProportional(gTD[count], 1);
  959.     TextDrawUseBox(gTD[count], 1);
  960.     TextDrawBoxColor(gTD[count], 0);
  961.     TextDrawTextSize(gTD[count], 10.000000, 30.000000);
  962.     TextDrawSetSelectable(gTD[count], 1);
  963.  
  964.     count++;
  965.  
  966.     for(new i=0; i<11; i++)  // Create Vertical Lines
  967.     {
  968.         if(i == 10)
  969.         {
  970.             gTD[count] = TextDrawCreate((X+1), 199.000000, "~n~");
  971.         }
  972.         else
  973.         {
  974.             gTD[count] = TextDrawCreate(X, 199.000000, "~n~");
  975.         }
  976.         TextDrawAlignment(gTD[count], 2);
  977.         TextDrawBackgroundColor(gTD[count], 255);
  978.         TextDrawFont(gTD[count], 1);
  979.         TextDrawLetterSize(gTD[count], 0.500000, 17.399993);
  980.         TextDrawColor(gTD[count], -1);
  981.         TextDrawSetOutline(gTD[count], 0);
  982.         TextDrawSetProportional(gTD[count], 1);
  983.         TextDrawSetShadow(gTD[count], 1);
  984.         TextDrawUseBox(gTD[count], 1);
  985.         TextDrawBoxColor(gTD[count], 255);
  986.         TextDrawTextSize(gTD[count], 1.000000, -2.000000);
  987.         X = floatadd(X, 16.0);
  988.         count++;
  989.     }
  990.     for(new i=0; i<11; i++)  // Create Horizontal Lines
  991.     {
  992.         gTD[count] = TextDrawCreate(340.000000, Y, "~n~");
  993.         TextDrawAlignment(gTD[count], 2);
  994.         TextDrawBackgroundColor(gTD[count], 255);
  995.         TextDrawFont(gTD[count], 1);
  996.         TextDrawLetterSize(gTD[count], 0.500000, -0.300006);
  997.         TextDrawColor(gTD[count], -1);
  998.         TextDrawSetOutline(gTD[count], 0);
  999.         TextDrawSetProportional(gTD[count], 1);
  1000.         TextDrawSetShadow(gTD[count], 1);
  1001.         TextDrawUseBox(gTD[count], 1);
  1002.         TextDrawBoxColor(gTD[count], 255);
  1003.         TextDrawTextSize(gTD[count], 61.000000, 158.000000);
  1004.         TextDrawSetSelectable(gTD[count], 0);
  1005.         Y = floatadd(Y, 16.0);
  1006.         count++;
  1007.     }
  1008.     TDLowerBet = TextDrawCreate(326.000000, 136.000000, "<");      // Lower Bet Button
  1009.     TextDrawAlignment(TDLowerBet, 2);
  1010.     TextDrawBackgroundColor(TDLowerBet, 255);
  1011.     TextDrawFont(TDLowerBet, 1);
  1012.     TextDrawLetterSize(TDLowerBet, 0.329999, 1.600000);
  1013.     TextDrawColor(TDLowerBet, -1);
  1014.     TextDrawSetOutline(TDLowerBet, 1);
  1015.     TextDrawSetProportional(TDLowerBet, 1);
  1016.     TextDrawUseBox(TDLowerBet, 1);
  1017.     TextDrawBoxColor(TDLowerBet, 0);
  1018.     TextDrawTextSize(TDLowerBet, 15.000000, 20.000000);
  1019.     TextDrawSetSelectable(TDLowerBet, 1);
  1020.  
  1021.     TDRaiseBet = TextDrawCreate(354.000000, 136.000000, ">");    //  Raise Bet Button
  1022.     TextDrawAlignment(TDRaiseBet, 2);
  1023.     TextDrawBackgroundColor(TDRaiseBet, 255);
  1024.     TextDrawFont(TDRaiseBet, 1);
  1025.     TextDrawLetterSize(TDRaiseBet, 0.329999, 1.600000);
  1026.     TextDrawColor(TDRaiseBet, -1);
  1027.     TextDrawSetOutline(TDRaiseBet, 1);
  1028.     TextDrawSetProportional(TDRaiseBet, 1);
  1029.     TextDrawUseBox(TDRaiseBet, 1);
  1030.     TextDrawBoxColor(TDRaiseBet, 0);
  1031.     TextDrawTextSize(TDRaiseBet, 15.000000, 20.000000);
  1032.     TextDrawSetSelectable(TDRaiseBet, 1);
  1033.  
  1034.     TDStart = TextDrawCreate(292.000000, 365.000000, "PLAY");    // Play Button
  1035.     TextDrawAlignment(TDStart, 2);
  1036.     TextDrawBackgroundColor(TDStart, 255);
  1037.     TextDrawFont(TDStart, 1);
  1038.     TextDrawLetterSize(TDStart, 0.509999, 2.100000);
  1039.     TextDrawColor(TDStart, 0xB1FAC0FF);
  1040.     TextDrawSetOutline(TDStart, 1);
  1041.     TextDrawSetProportional(TDStart, 1);
  1042.     TextDrawUseBox(TDStart, 1);
  1043.     TextDrawBoxColor(TDStart, 0);
  1044.     TextDrawTextSize(TDStart, 53.000000, 50.000000);
  1045.     TextDrawSetSelectable(TDStart, 1);
  1046.  
  1047.     TDClose = TextDrawCreate(381.000000, 365.000000, "CLOSE");   // Close Button
  1048.     TextDrawAlignment(TDClose, 2);
  1049.     TextDrawBackgroundColor(TDClose, 255);
  1050.     TextDrawFont(TDClose, 1);
  1051.     TextDrawLetterSize(TDClose, 0.509999, 2.100000);
  1052.     TextDrawColor(TDClose, 0xFF9696FF);
  1053.     TextDrawSetOutline(TDClose, 1);
  1054.     TextDrawSetProportional(TDClose, 1);
  1055.     TextDrawUseBox(TDClose, 1);
  1056.     TextDrawBoxColor(TDClose, 0);
  1057.     TextDrawTextSize(TDClose, 53.000000, 50.000000);
  1058.     TextDrawSetSelectable(TDClose, 1);
  1059.     print("CLose Button Created");
  1060. }
  1061.  
  1062. HideTDForPlayer(playerid)
  1063. {
  1064.     for(new i; i<sizeof(gTD); i++)
  1065.     {
  1066.         TextDrawHideForPlayer(playerid, gTD[i]);
  1067.     }
  1068.     for(new i; i<100; i++)
  1069.     {
  1070.         PlayerTextDrawHide(playerid, TD[playerid][i]);
  1071.     }
  1072.     if(AreDotsCreated[playerid] == true)
  1073.     {
  1074.         for(new i; i<10; i++)
  1075.         {
  1076.             PlayerTextDrawDestroy(playerid, TDDots[playerid][i]);
  1077.         }
  1078.         AreDotsCreated[playerid] = false;
  1079.     }
  1080.     PlayerTextDrawHide(playerid, TDPrize[playerid][0]);
  1081.     PlayerTextDrawHide(playerid, TDPrize[playerid][1]);
  1082.     new b = Bet[playerid];
  1083.     format(PrizeString[playerid][0], 128, "01: $%d~n~02: $%d~n~03: $%d~n~04: $%d~n~05: $%d", floatround(b*RM[1]), floatround(b*RM[2]), floatround(b*RM[3]), floatround(b*RM[4]), floatround(b*RM[5]));
  1084.     format(PrizeString[playerid][1], 128, "$%d :06 ~n~$%d :07 ~n~$%d :08 ~n~$%d :09 ~n~$%d :10", floatround(b*RM[6]), floatround(b*RM[7]), floatround(b*RM[8]), floatround(b*RM[9]), Jackpot);
  1085.     PlayerTextDrawSetString(playerid, TDPrize[playerid][0], PrizeString[playerid][0]);
  1086.     PlayerTextDrawSetString(playerid, TDPrize[playerid][1], PrizeString[playerid][1]);
  1087.  
  1088.     PlayerTextDrawHide(playerid, TDNumber[playerid]);
  1089.     PlayerTextDrawSetString(playerid, TDNumber[playerid], "  ");
  1090.  
  1091.     PlayerTextDrawHide(playerid, TDBet[playerid]);
  1092.     PlayerTextDrawHide(playerid, TDHeader[playerid]);
  1093.  
  1094.     TextDrawHideForPlayer(playerid, TDLowerBet);
  1095.     TextDrawHideForPlayer(playerid, TDRaiseBet);
  1096.     TextDrawHideForPlayer(playerid, TDStart);
  1097.     TextDrawHideForPlayer(playerid, TDClose);
  1098.     LotteryStage[playerid] = -1;
  1099.     PlayerPlaySound(playerid, 1184, 0.0, 0.0, 0.0);
  1100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement