Szerző Téma: Parancs helymeghatározás!  (Megtekintve 923 alkalommal)

Parancs helymeghatározás!
« Dátum: 2015. október 16. - 17:54:16 »
0 Show voters
Sziasztok, van egy sccript amit korlátozni szeretnék egy bizonyos helyre! Méghozzá egy Interiorhoz szeretném, tehát ha nem tartózkodunk az interiorban akkor a folyamat nem megy végbe. Illetve ha nem az interiorban írjuk be a parancsot akkor a szerver reagál egy üzenettel.: Pl.: Rossz helyen vagy!
Előre is köszönöm a segítséget! :))
 
 #include <a_samp>
#include <zcmd>
#define MIN_BET 100
#define MAX_BET 50000
#define TIME_BETWEEN_NUMBERS 2000     //(1000 = 1 second)
#define DEFAULT_JACKPOT 1000000     // In case a player wins the Jackpot, it will get reset to this amount.
#define JACKPOT_MULTIPLIER 3    // Players bet will be multiplied by this amount and added to the jackpot.
                  //For example: if JACKPOT_MULTIPLIER is set to \'3\' and a player bets $1200,  $3600 will be added to the jackpot.
#define FILE_PATH \"LotteryJackpot.ini\"
#define HELP_DIALOG 28503
new Float:RM[11] =   // Reward Multiplier
{
0.0,    // 0 matches
0.5,     // 1 match
1.0,   // 2 matches
2.0,    // 3 matches
4.0,    // 4 matches
8.0,      // 5 matches
16.0,    // 6 matches
32.0,     // 7 matches
64.0,     // 8 matches
128.0,  // 9 matches
      // 10 matches will get the jackpot, defined somewhere else.
};
 
//PlayerTextdraws
new PlayerText:TD[MAX_PLAYERS][100];         // 100x PlayerTextDraws for the numbers (0-99)
new PlayerText:TDHeader[MAX_PLAYERS];        // PlayerTextDraw for Header  (Either \"Lottery\", \"Winner\" or \"Loser\");
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)
new PrizeString[MAX_PLAYERS][2][128];       // These strings will hold the info for above Reward-Textdraws.
new PlayerText:TDBet[MAX_PLAYERS];          // PlayerTextDraw that shows the players current bet
new PlayerText:TDNumber[MAX_PLAYERS];       // PlayerTextDraw that shows the current random drawn number
new PlayerText:TDDots[MAX_PLAYERS][10];     // 10x PlayerTextDraws for the circles, encircling the drawn numbers
new PlayerText:TDError[MAX_PLAYERS];        // PlayerTextDraw that will show different Error-Messages.
//Global Textdraws
new Text:gTD[34];                           // 33 TextDraws for the main design (Main background, out-/inner-lines, header-background, reset- & help-button.
//Buttons
new Text:TDLowerBet;                        // TextDraw for the Lower-bet button
new Text:TDRaiseBet;                        // TextDraw for the Raise-bet button
new Text:TDStart;                           // TextDraw for the PLAY-button
new Text:TDClose;                           // TextDraw for the CLOSE-button
//Booleans
new bool:TDSelected[MAX_PLAYERS][100];      // 100x Boolean to check if player has selected/deselected a certain number on his lottery-card.
new bool:AreTDCreated[MAX_PLAYERS];         // Boolean to check if the TextDraws are created for the player.
new bool:AreDotsCreated[MAX_PLAYERS];       // Boolean to check if all 10 Circle-TextDraws are created.
//Variables
new Jackpot;                                // This variable will hold the current Jackpot.
//Timers
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.
new LotteryTimer[MAX_PLAYERS];              // Timer that will trigger the process to pick the next random number.
//Other Arrays:
new Bet[MAX_PLAYERS];                       // This array will hold each players current bet.
new LotteryStage[MAX_PLAYERS];              // This array will hold the progress for each player during the whole Lottery-process.
new SelectedNumbers[MAX_PLAYERS];           // This array will count how many numbers each player has selected on his lottery-card.
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).
new LotteryNumbers[MAX_PLAYERS][10];        // This array will store the final numbers generated by the server for each player.
new LotteryNumbersPicked[MAX_PLAYERS];      // This array will count how many numbers have been picked by the server.
new Lot[MAX_PLAYERS][10];                   // This array will store the numbers selected by each player.
new Matches[MAX_PLAYERS];                   // This array will count how many matches the player got during the drawing.
 
// Main Callbacks
public OnFilterScriptInit()
{
CreateGlobalTextDraws();                // Create Global Textdraws
for(new i; i<MAX_PLAYERS; i++)          // Loop through the online players
{
LotteryStage = -1;               // Reset info
    if(IsPlayerConnected(i))
    {
        for(new j; j<10; j++)
        {
           LotteryNumbers[j] = -1;   // Reset info
           Lot[j] = -1;             // Reset info
   }
        Bet = MIN_BET;               // Set players bet to minimal bet
        CreatePlayerTextDraws(i);       // Create the PlayerTextDraw
   LotteryNumbersPicked = 0;    // Reset info
}
}
new File:file;
    if (!fexist(FILE_PATH))                 // Check if Jackpot-file not exists
    {
       file = fopen(FILE_PATH,io_write);   // Create new file
       new str[12];
       format(str, 12, \"%d\", DEFAULT_JACKPOT);
       fwrite(file, str);                  // Write default jackpot value to file
       fclose(file);                       // Close file
       Jackpot = DEFAULT_JACKPOT;          // Set Jackpot-variable to default value
}
else                                    // ..if the file already exists..
{
    file=fopen(FILE_PATH, io_read);     // Open the file
new str[12];
    while(fread(file, str))             // Read the value from the file
    {
   Jackpot = strval(str);          // Assign the value from the file to the Jackpot-variable
}
fclose(file);                       // Close the file
}
print(\"\\n--------------------------------------\");
print(\" Lottery Filterscript by Schneider\");
print(\"--------------------------------------\\n\");
return 1;
}
public OnFilterScriptExit()
{
for(new i; i<MAX_PLAYERS; i++)                   // Loop through the online players (in case this filterscript gets unloaded before server is shut down)
{
    if(AreTDCreated == true)                  // Check if PlayerTextDraws are created
    {
        for(new j; j<100; j++)
   {
      PlayerTextDrawDestroy(i, TD[j]);     // Destroy all 100 numbers
   }
   PlayerTextDrawDestroy(i, TDPrize[0]);    // Destroy PlayerTextDraw
   PlayerTextDrawDestroy(i, TDPrize[1]);    // Destroy PlayerTextDraw
   PlayerTextDrawDestroy(i, TDBet);         // Destroy PlayerTextDraw
   PlayerTextDrawDestroy(i, TDNumber);      // Destroy PlayerTextDraw
   PlayerTextDrawDestroy(i, TDHeader);      // Destroy PlayerTextDraw
   PlayerTextDrawDestroy(i, TDError);       // Destroy PlayerTextDraw
   for(new j; j<10; j++)
   {
       PlayerTextDrawDestroy(i, TDDots[j]); // Destroy the 10 circles
   }
}
}
for(new i=0; i<sizeof(gTD); i++)
{
    TextDrawDestroy(gTD);                        // Destroy global Textdraws
}
TextDrawDestroy(TDLowerBet);                        // Destroy Button Textdraw
TextDrawDestroy(TDRaiseBet);                        // Destroy Button Textdraw
TextDrawDestroy(TDStart);                           // Destroy Button Textdraw
TextDrawDestroy(TDClose);                           // Destroy Button Textdraw
return 1;
}
public OnPlayerConnect(playerid)
{
    LotteryStage[playerid] = -1;         // Reset playerinfo
Bet[playerid] = MIN_BET;                // Reset playerinfo
SelectedNumbers[playerid] = 0;          // Reset playerinfo
RandomNumbersCount[playerid] = 0;       // Reset playerinfo
LotteryNumbersPicked[playerid] = 0;     // Reset playerinfo
for(new j; j<10; j++)
    {
         LotteryNumbers[playerid][j] = -1;   // Reset playerinfo
         Lot[playerid][j] = -1;              // Reset playerinfo
}
CreatePlayerTextDraws(playerid);        // Create PlayerTextDraws
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(AreTDCreated[playerid] == true)                        // Delete PlayerTextDraws if they are created
{
    for(new i; i<100; i++)
{
   PlayerTextDrawDestroy(playerid, TD[playerid]);      // Destroy PlayerTextDraw
}
for(new j; j<10; j++)
{
    PlayerTextDrawDestroy(playerid, TDDots[playerid][j]);   // Destroy PlayerTextDraw
}
PlayerTextDrawDestroy(playerid, TDPrize[playerid][0]);      // Destroy PlayerTextDraw
PlayerTextDrawDestroy(playerid, TDPrize[playerid][1]);      // Destroy PlayerTextDraw
PlayerTextDrawDestroy(playerid, TDBet[playerid]);          // Destroy PlayerTextDraw
PlayerTextDrawDestroy(playerid, TDNumber[playerid]);        // Destroy PlayerTextDraw
PlayerTextDrawDestroy(playerid, TDHeader[playerid]);        // Destroy PlayerTextDraw
PlayerTextDrawDestroy(playerid, TDError[playerid]);        // Destroy PlayerTextDraw
AreTDCreated[playerid] = false;                             // Reset playerinfo
}
return 1;
}
 
public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
{
if((LotteryStage[playerid] == 0))                                           // Check if player is in first stage (Stage 0 = Player is able to select numbers)
{
    if(AreDotsCreated[playerid] == true)                                    // Check if the player has already played a game, so we can reset screen
{                                 
   for(new i; i<10; i++)
         {
      PlayerTextDrawDestroy(playerid, TDDots[playerid]);           // Destroy the circles around the numbers from previous drawing.
   }
   AreDotsCreated[playerid] = false;                                   // Reset player info
   PlayerTextDrawHide(playerid, TDHeader[playerid]);                   // Hide Header-TextDraw
   PlayerTextDrawSetString(playerid, TDHeader[playerid], \"~w~Lottery\");// Change the Header-Text to \"Lottery\";
   PlayerTextDrawShow(playerid, TDHeader[playerid]);                   // Show the Header-TextDraw
   PlayerTextDrawHide(playerid, TDPrize[playerid][0]);                 // Hide left reward-textdraw
   PlayerTextDrawHide(playerid, TDPrize[playerid][1]);                 // Hide right reward-textdraw
   new b = Bet[playerid];                                              // Just for shorter writing, store the players bet in a new variable
   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.
   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.
   PlayerTextDrawSetString(playerid, TDPrize[playerid][0], PrizeString[playerid][0]);  // Set string
   PlayerTextDrawSetString(playerid, TDPrize[playerid][1], PrizeString[playerid][1]);  // Set string
   PlayerTextDrawShow(playerid, TDPrize[playerid][0]);                 // Show updated rewards-textdraw
   PlayerTextDrawShow(playerid, TDPrize[playerid][1]);                 // Show updated rewards-textdraw
   PlayerTextDrawHide(playerid, TDNumber[playerid]);                   // Hide the TextDraw that showed the last drawn number
   PlayerTextDrawSetString(playerid, TDNumber[playerid], \"  \");        // Change the text to an empty string
   PlayerTextDrawShow(playerid, TDNumber[playerid]);                   // Show the  Textdraw
   PlayerPlaySound(playerid, 1184, 0.0, 0.0, 0.0);                     // Stop the music that is started when player wins the jackpot
}
new td;                                                                 // This variable will hold the number the player clicks
    for(new j; j<100; j++)                                                  // Loop through all 100 Number-textdraw
{
       if(playertextid == TD[playerid][j])                                 // Check on which number the player clicked
       {
           td = j;                                                         // Store the number in td-variable.
           break;                                                          // Stop the loop
   }
}
PlayerTextDrawHide(playerid, TD[playerid][td]);                         // Hide the clicked number
if(TDSelected[playerid][td] == false)                                   // Check if the number was NOT selected yet
{
    if(SelectedNumbers[playerid] == 10)                                 // Check if the player has already selected 10 numbers (so we can give him an error).
    {
        PlayerTextDrawHide(playerid, TDHeader[playerid]);               // Temporarily hide the header (showing \"Lottery\")
      PlayerTextDrawHide(playerid, TDError[playerid]);                // Hide Error Message (in case an error was already showing)
      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
      PlayerTextDrawShow(playerid, TDError[playerid]);                // Show the error message
      SetTimerEx(\"HideError\", 3500, 0, \"u\", playerid);                // Start timer to hide the Error-message and show the Lottery-header
   }
   else                                                                // ...if player has not selected 10 numbers yet.
   {
      PlayerTextDrawColor(playerid,TD[playerid][td], 0x46F255FF);     // Change the number-color to green
      TDSelected[playerid][td] = true;                                // Switch the boolean to true.   (= selected)
      new slot = GetFreeSlot(playerid);                               // Get a free slot in the Lots[playerid]-array.
      if(slot != -1)                                                  // Check if no invalid slot has been returned
      {
         Lot[playerid][slot] = td;                                   // Store the selected number in the free slot in the players\' Lot-array
      }
      SelectedNumbers[playerid]++;                                    // Increae the number of selected numbers by 1
   }
}
else                                                                    // ... else if the number was already selected by the player
{
    PlayerTextDrawColor(playerid,TD[playerid][td], 0xD1D1D1FF);         // Change the number-color to grey
    TDSelected[playerid][td] = false;                                   // Switch the boolean to false  (= not selected)
   new slot = FindSlot(playerid, td);                                  // Find in which slot the number was stored in the players Lot-array
   if(slot != -1)
   {
       Lot[playerid][slot] = -1;                                       // Free up the slot
   }
    SelectedNumbers[playerid]--;                                        // Decrease the number of selected numbers by 1
}
PlayerTextDrawShow(playerid, TD[playerid][td]);                         // Show the updated number-textdraw
}
    return 1;
}
public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
if((_:clickedid != INVALID_TEXT_DRAW) && (LotteryStage[playerid] == 0))     // Check if player is in Stage 0 and if the player has not pressed ESC
{
    if(AreDotsCreated[playerid] == true)                                    // Same as above... if the player has already finished a game, the screen will be reset for a new game
    {
    for(new i; i<10; i++)
         {
      PlayerTextDrawDestroy(playerid, TDDots[playerid]);           // Destroy the circles from previous game
   }
   AreDotsCreated[playerid] = false;                                   // Reset player info
   PlayerTextDrawHide(playerid, TDHeader[playerid]);                   // Hide the header
   PlayerTextDrawSetString(playerid, TDHeader[playerid], \"~w~Lottery\");// Change header text back to \"Lottery\"
   PlayerTextDrawShow(playerid, TDHeader[playerid]);                   // Show updated header
   PlayerTextDrawHide(playerid, TDPrize[playerid][0]);                 // Hide left reward-textdraw
   PlayerTextDrawHide(playerid, TDPrize[playerid][1]);                 // Hide right reward-textdraw
   new b = Bet[playerid];                                              // Just for shorter writing, store the players bet in a new variable
   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.
   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.
   PlayerTextDrawSetString(playerid, TDPrize[playerid][0], PrizeString[playerid][0]);  // Set string
   PlayerTextDrawSetString(playerid, TDPrize[playerid][1], PrizeString[playerid][1]);  // Set string
   PlayerTextDrawShow(playerid, TDPrize[playerid][0]);                 // Show updated rewards-textdraw
   PlayerTextDrawShow(playerid, TDPrize[playerid][1]);                 // Show updated rewards-textdraw
   PlayerTextDrawHide(playerid, TDNumber[playerid]);                   // Hide last drawn number-textdraw
   PlayerTextDrawSetString(playerid, TDNumber[playerid], \"  \");        // Empty the string
   PlayerTextDrawShow(playerid, TDNumber[playerid]);                   // Show updated textdraw
      PlayerPlaySound(playerid, 1184, 0.0, 0.0, 0.0);                     // Stop the music that is started when player wins the jackpot
}
if(clickedid == TDLowerBet)                                             // If player clicked the Lower-bet button
{
    if(Bet[playerid] > MIN_BET)                                         // Check if the players bet is still higher than MIN_BET
   {
       new str[8];
       Bet[playerid] -= 100;                                           // Subtract $100 from the players\' bet
       format(str, sizeof(str), \"$%d\", Bet[playerid]);
      PlayerTextDrawHide(playerid, TDBet[playerid]);                  // Hide the bet-textdraw
      PlayerTextDrawSetString(playerid, TDBet[playerid], str);        // Update the textdraw string
      PlayerTextDrawShow(playerid, TDBet[playerid]);                  // Show the updated bet-textdraw
      new b = Bet[playerid];                                          // For shorter writing, store players\' current bet in new variable
      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.
      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.
      PlayerTextDrawSetString(playerid, TDPrize[playerid][0], PrizeString[playerid][0]);      // Update reward-textdraw
      PlayerTextDrawSetString(playerid, TDPrize[playerid][1], PrizeString[playerid][1]);      // Update reward-textdraw
      PlayerTextDrawShow(playerid, TDPrize[playerid][0]);
         PlayerTextDrawShow(playerid, TDPrize[playerid][1]);
   }
}
if(clickedid == TDRaiseBet)                                             // Same as above... but raise the bet by $100 instead of decrease.
{
    if(Bet[playerid] < MAX_BET)
   {
       new str[8];
       Bet[playerid] += 100;                                           // Add $100 to the players\' bet
       format(str, sizeof(str), \"$%d\", Bet[playerid]);
      PlayerTextDrawHide(playerid, TDBet[playerid]);
      PlayerTextDrawSetString(playerid, TDBet[playerid], str);
      PlayerTextDrawShow(playerid, TDBet[playerid]);
      new b = Bet[playerid];
      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(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);
      PlayerTextDrawSetString(playerid, TDPrize[playerid][0], PrizeString[playerid][0]);
      PlayerTextDrawSetString(playerid, TDPrize[playerid][1], PrizeString[playerid][1]);
      PlayerTextDrawShow(playerid, TDPrize[playerid][0]);
              PlayerTextDrawShow(playerid, TDPrize[playerid][1]);
   }
}
if(clickedid == TDStart)                                                // If the player clicked the PLAY-button
{
    if(SelectedNumbers[playerid] != 10)                                 // Check if player has NOT selected 10 numbers yet. Give him error in that case.
   {
       PlayerTextDrawHide(playerid, TDHeader[playerid]);
        PlayerTextDrawHide(playerid, TDError[playerid]);
      PlayerTextDrawSetString(playerid, TDError[playerid], \"~r~[Error] ~n~~w~You first have to select ~r~10 ~w~numbers!\");
      PlayerTextDrawShow(playerid, TDError[playerid]);
      SetTimerEx(\"HideError\", 3500, 0, \"u\", playerid);
   }
   else if(GetPlayerMoney(playerid) < Bet[playerid])                   // Check if player has NOT enough money. Give him error in that case.
   {
      PlayerTextDrawHide(playerid, TDHeader[playerid]);
        PlayerTextDrawHide(playerid, TDError[playerid]);
      PlayerTextDrawSetString(playerid, TDError[playerid], \"~r~[Error] ~n~~w~You do not have enough money.\");
      PlayerTextDrawShow(playerid, TDError[playerid]);
      SetTimerEx(\"HideError\", 3500, 0, \"u\", playerid);
   }
   else                                                                // If the player has selected 10 numbers and has enough money:
   {
               GivePlayerMoney(playerid, -Bet[playerid]);                      // Remove the bet from the players\' money
       Jackpot += (Bet[playerid]*JACKPOT_MULTIPLIER);                  // Increase the jackpot by the players bet, multiplied with the defined multiplier (at top of script)
       new File:file;
       if (fexist(FILE_PATH))
       {
          file = fopen(FILE_PATH,io_write);
          new str[12];
          format(str, 12, \"%d\", Jackpot);
          fwrite(file, str);                                          // Update the Jackpot-value in the file
          fclose(file);
      }
       LotteryStage[playerid] = 1;                                     // Set the players stage to \'1\' (= show fast random numbers)
       LotteryTimer[playerid] = SetTimerEx(\"Lottery\", 50, 0, \"u\", playerid);   // Start timer to start the lottery.
       CancelSelectTextDraw(playerid);                                 // Remove the cursor
       TogglePlayerControllable(playerid, 0);                          // Freeze the player
       RandomNumbersCount[playerid] = 0;                               // Reset player info
   }
}
if(clickedid == TDClose)                                                // If player clicked the CLOSE-button
{
        HideTDForPlayer(playerid);                                          // Hide all textdraws
        TogglePlayerControllable(playerid, 1);                              // Unfreeze the player
        CancelSelectTextDraw(playerid);                                     // Remove the cursor
}
if(clickedid == gTD[10])                                      // If player clicked the Reset-Button
{
    Bet[playerid] = MIN_BET;                                            // Reset players\' bet to default min-value
    new b = Bet[playerid];                                              // For short writing, store players bet in new variable
    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
   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
   PlayerTextDrawSetString(playerid, TDPrize[playerid][0], PrizeString[playerid][0]);
   PlayerTextDrawSetString(playerid, TDPrize[playerid][1], PrizeString[playerid][1]);
   PlayerTextDrawShow(playerid, TDPrize[playerid][0]);                 // Show updated rewards-textdraw
    PlayerTextDrawShow(playerid, TDPrize[playerid][1]);                 // Show updated rewards-textdraw
   
    new str[8];
    format(str, sizeof(str), \"$%d\", Bet[playerid]);                     // Update bet-textdraw
    PlayerTextDrawHide(playerid, TDBet[playerid]);
   PlayerTextDrawSetString(playerid, TDBet[playerid], str);
   PlayerTextDrawShow(playerid, TDBet[playerid]);
   
    SelectedNumbers[playerid] = 0;                                      // Reset player info
   
    for(new i; i<10; i++)
    {
        Lot[playerid] = -1;                                          // Reset players lot
   }
   for(new i; i<100; i++)
   {
       PlayerTextDrawHide(playerid, TD[playerid]);
       PlayerTextDrawColor(playerid,TD[playerid], 0xD1D1D1FF);      // Change the color of all numbers back to grey
       PlayerTextDrawShow(playerid, TD[playerid]);
       TDSelected[playerid] = false;                                // Reset info
   }
}
if(clickedid == gTD[11])   // Clicked Help-Button                       // If player clicked the Help-button
{
    new string[800];
    new string2[300];
            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);
    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);
    ShowPlayerDialog(playerid, HELP_DIALOG, DIALOG_STYLE_MSGBOX, \"Lottery Help\", string, \"OK\", \"\"); // Show Help-dialog
}
}
if((_:clickedid == INVALID_TEXT_DRAW) && (LotteryStage[playerid] == 0))     // If player pressed ESC while in the number-selecting-stage
{
HideTDForPlayer(playerid);                                              // Hide all textdraws
TogglePlayerControllable(playerid, 1);                                  // Unfreeze player
}
return 1;
}
 
COMMAND:lottery(playerid, params[])                                              //Command: /lottery  to start.
{
if(LotteryStage[playerid] != -1) return SendClientMessage(playerid, 0xF25D46FF, \"{F4C670}[Lottery]: {FFFFFF}You are already playing!\");  // Check if player has already opened the Lottery
LotteryStage[playerid] = 0;                                                 // Set players stage to 0  ( = select numbers)
new b = Bet[playerid];                                                      // For shorter writing, store players\' bet in new variable
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(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);
PlayerTextDrawSetString(playerid, TDPrize[playerid][0], PrizeString[playerid][0]);  // Update rewards-textdraw string
PlayerTextDrawSetString(playerid, TDPrize[playerid][1], PrizeString[playerid][1]);  // Update rewards-textdraw string
    for(new i; i<sizeof(gTD); i++)
{
    TextDrawShowForPlayer(playerid, gTD);                                // Show global textdraws
}
for(new i; i<100; i++)
{
PlayerTextDrawShow(playerid, TD[playerid]);                          // Show the numbers
}
PlayerTextDrawShow(playerid, TDPrize[playerid][0]);                         // Show rewards (left)
    PlayerTextDrawShow(playerid, TDPrize[playerid][1]);                         // Show rewards (right)
    PlayerTextDrawShow(playerid, TDNumber[playerid]);
    PlayerTextDrawShow(playerid, TDHeader[playerid]);
    TextDrawShowForPlayer(playerid, TDLowerBet);                                // Show lower-bet button
    TextDrawShowForPlayer(playerid, TDRaiseBet);                                // Show raise-bet button
    TextDrawShowForPlayer(playerid, TDStart);                                   // Show PLAY-button
    TextDrawShowForPlayer(playerid, TDClose);                                   // Show CLOSE-button
    new str[8];
    format(str, sizeof(str), \"$%d\", Bet[playerid]);                             // Format the bet-textdraw
PlayerTextDrawSetString(playerid, TDBet[playerid], str);
PlayerTextDrawShow(playerid, TDBet[playerid]);                              // Show the bet-textdraw
    SelectTextDraw(playerid, 0xFF4040AA);                                       // Show the cursor
return 1;
}
forward Lottery(playerid);
public Lottery(playerid)                                                        // Main timer
{
switch(LotteryStage[playerid])                                              // Switch the players stage
{
    case 1:                                                   // Stage 1: Intro showing random nummbers 20x/second
{
            RandomNumbersTimer[playerid] = SetTimerEx(\"ShowRandomNumbers\", 50, 1, \"u\", playerid); // Start 50ms repeating timer to show fast random numbers before revealing real number.
}
case 2:                                                  // Stage 2: Draw a Number
{
    new Draw = LotteryNumbersPicked[playerid];                          // For shorter writing, store the amount of picked numbers in new variable
             new bool:found, bool:taken, number;                                 // Create few new variables
    while (found == false)                                              // Loop until a unique number has been found
    {
        taken = false;                                                  // Reset boolean to false
        number = random(100);                                           // Generate a random number from 0 to 99
        for(new i; i<10; i++)                                           // Loop through the already drawn numbers
        {
            if(number == LotteryNumbers[playerid])                   // Check if generated number has already been picked
         {
            taken = true;                                           // ..if yes, set \'taken\'  to true
         }
      }
      if(taken == false)                                              // if loop is finished an \'taken\' is still \'false\' it means we found a unique number
      {
          LotteryNumbers[playerid][Draw] = number;                    // Store the new number in the array
         found = true;                                               // Set \'found\' to true to stop the loop
      }
   }
   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
   format(str, 5, \"%02d\", number);                                     // Format string to show the generated number
   PlayerTextDrawHide(playerid, TDNumber[playerid]);
   PlayerTextDrawSetString(playerid, TDNumber[playerid], str);
   PlayerTextDrawShow(playerid, TDNumber[playerid]);
   new bool:match;                                                     // Create new boolean that will check if a match has been found
   for(new i; i<10; i++)                                               // Loop through all numbers selected by the player
   {
       if(Lot[playerid] == number)                                  // If the new generated number matches a number in the players array...
       {
         Matches[playerid]++;                                        // Increase the number of matches by 1
         match = true;                                               // Set match-boolean to true
      }
   }
   new horizontal;                                                     // Create new variable to keep track of the horizontal collumns
   for(new c; c<(number); c++)                                         // Now we have to calculate the coordinates for the circle around the generated number.
   {
       X = floatadd(X, 16.0);                                          // Increase the X-coordinate by 16.0
       horizontal++;                                                   // Increase the horizontal variable by 1
       if(horizontal == 10)                                            // If we have moved 10 collumns
       {
          horizontal = 0;                                             // Set horizontal variable back to 0
          X = 258.0;                                                  // Set the X-coordinate back to 258.0   (go to first collumn)
                    Y = floatadd(Y, 16.0);                                      // Increase the Y-coordinate by 16.0    (go to next row)
      }
           }                                                                   // When the loop is finished, we will have the right X- and Y-coordinates for the circle around the number
           
   new Float:x, Float:y, Float:z;
   GetPlayerPos(playerid, x, y, z);
           if(match == true) PlayerPlaySound(playerid, 1057, x, y, z);         // If a match was found, play high beep-sound
   else PlayerPlaySound(playerid, 1085, x, y, z);                      // else if no match was found, play low beep-sound
       TDDots[playerid][Draw] = CreatePlayerTextDraw(playerid, X, Y, \"O\"); // Create Circle-textdraw at the calculated coordinates
   PlayerTextDrawBackgroundColor(playerid,TDDots[playerid][Draw], 255);
   PlayerTextDrawFont(playerid,TDDots[playerid][Draw], 2);
   PlayerTextDrawLetterSize(playerid,TDDots[playerid][Draw], 0.650000, 3.400000);
   if(match == true) PlayerTextDrawColor(playerid,TDDots[playerid][Draw], 0x7DFA2AFF);     // If number matched, make circle bright green
   else PlayerTextDrawColor(playerid,TDDots[playerid][Draw], 0xB3D69CFF);                  // If no match, make circle pale-green
   PlayerTextDrawSetOutline(playerid,TDDots[playerid][Draw], 0);
   PlayerTextDrawSetProportional(playerid,TDDots[playerid][Draw], 1);
   PlayerTextDrawSetShadow(playerid,TDDots[playerid][Draw], 1);
   PlayerTextDrawSetSelectable(playerid,TDDots[playerid][Draw], 0);
   PlayerTextDrawShow(playerid, TDDots[playerid][Draw]);
            new b = Bet[playerid];
   switch(Matches[playerid])   // Switch through the current amount of matches. Giving the current amount a red color while the rest is white.
   {
       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]));
       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]));
       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]));
       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]));
       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]));
       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]));
      
       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);
       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);
       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);
       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);
       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);
   }
            switch(Matches[playerid])
   {
       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);
       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]));
   }
   PlayerTextDrawHide(playerid, TDPrize[playerid][0]);
          PlayerTextDrawHide(playerid, TDPrize[playerid][1]);
   PlayerTextDrawSetString(playerid, TDPrize[playerid][0], PrizeString[playerid][0]);
   PlayerTextDrawSetString(playerid, TDPrize[playerid][1], PrizeString[playerid][1]);
        PlayerTextDrawShow(playerid, TDPrize[playerid][0]);               // Show the updates rewards-textdraws
          PlayerTextDrawShow(playerid, TDPrize[playerid][1]);                 // Show the updates rewards-textdraws
   Draw++;                                                             // Increase the count of drawn numbers by 1
            if(Draw == 10)                                                      // If 10 numbers have been drawn then finish the game
   {
       AreDotsCreated[playerid] = true;                                // Set boolian to check if all cicles have been created to \'true\'
       LotteryStage[playerid] = 3;                                     // Set stage to 3  ( = finish game)
       LotteryTimer[playerid] = SetTimerEx(\"Lottery\", 400, 0, \"u\", playerid);  // Start timer to finish the game
           }
   else                                                                // If less than 10 numbers have been draws
   {
       LotteryNumbersPicked[playerid]++;                               // Increase the global amount of drawn numbers by 1
       LotteryStage[playerid] = 1;                                     // Set stage to \'1\'  ( = show fast random numbers)
      LotteryTimer[playerid] = SetTimerEx(\"Lottery\", TIME_BETWEEN_NUMBERS, 0, \"u\", playerid);     //Start timer to pick next number
   }
        }
        case 3:                                                   // End of the Game
        {
            new str[128];
            switch (Matches[playerid])                                          // Switch through the amount of matches
            {
                case 0:                                                         // If no matches at all...
         {
         format(str, sizeof(str), \"{F4C670}[Lottery]: {FFFFFF}Sorry, you do not have any matches.. Better luck next time!\"),  // Player = loser
         SendClientMessage(playerid, 0xF2B346FF, str);
         PlayerTextDrawHide(playerid, TDHeader[playerid]);
         PlayerTextDrawSetString(playerid, TDHeader[playerid], \"~r~Loser!\");
         PlayerTextDrawShow(playerid, TDHeader[playerid]);
      }
      case 1..9:                                                      // If 1 to 9 numbers match with the players selection...
      {
                    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]]));
                    SendClientMessage(playerid, 0x00FF00FF, str);
                    GivePlayerMoney(playerid, floatround(Bet[playerid]*RM[Matches[playerid]])); // Give player his prize
                    PlayerTextDrawHide(playerid, TDHeader[playerid]);
         PlayerTextDrawSetString(playerid, TDHeader[playerid], \"~w~Winner!\");
         PlayerTextDrawShow(playerid, TDHeader[playerid]);
      }
      case 10:                                                        // If all 10 selected numbers match, the player wins the Jackpot
      {
          PlayerTextDrawHide(playerid, TDHeader[playerid]);
         PlayerTextDrawSetString(playerid, TDHeader[playerid], \"~w~Jackpot!!\");
         PlayerTextDrawShow(playerid, TDHeader[playerid]);
         new pName[MAX_PLAYER_NAME];
         GetPlayerName(playerid, pName, sizeof(pName));
         format(str, sizeof(str), \"{F4C670}[Lottery]: {55CF5F}%s {FFFFFF}has won the {FF0000}JACKPOT {FFFFFF}of {55CF5F}$%d! {FFFFFF}Congratulations!!\", pName, Jackpot);
         SendClientMessageToAll(-1, str);
          format(str, sizeof(str), \" {FFFFFF}Congratulations! You\'ve got {55CF5F}10 {FFFFFF}matches and won the {FF0000}JACKPOT {FFFFFF}of {55CF5F}$%d!!!\", Jackpot);
                    SendClientMessage(playerid, -1, str);
         GivePlayerMoney(playerid, Jackpot);                         // Give player the Jackpot
                   
                    new Float:x, Float:y, Float:z;
         GetPlayerPos(playerid, x, y, z);
         PlayerPlaySound(playerid, 1183, x, y, z);                   // Play music
          new File:file, string[12];                                  // Reset the jackpot to its default in the file
                    file = fopen(FILE_PATH,io_write);
          format(string, 12, \"%d\", DEFAULT_JACKPOT);
          fwrite(file, string);
          fclose(file);
          Jackpot = DEFAULT_JACKPOT;
      }
   }
            LotteryNumbersPicked[playerid] = 0;                                 // Reset player info
    LotteryStage[playerid] = 0;                                         // Reset player info (Let player select new numbers)
    Matches[playerid] = 0;                                  &n
« Utoljára szerkesztve: 2015. október 16. - 18:09:44 írta JamesRamsey »

ᗩωєѕσмє

  • Vendég
Parancs helymeghatározás!
« Válasz #1 Dátum: 2015. október 16. - 18:03:06 »
0 Show voters
Jézus uram atyám! Kérlek tedd be a kódot [*code=pawn] [*/code] tagek közé, mert így olyan, mintha egy regény olvasó témában lennék.

Parancs helymeghatározás!
« Válasz #2 Dátum: 2015. október 16. - 18:10:32 »
0 Show voters
[.code] [./code] -val raktam be, előnézetbe rendesen megjelenítette. Nemértem..
Mindegy, javítottam. Köszönöm, hogy szóltál.
Esetleg beleírnád a scriptbe? Eddig én is eljutottam de valahogy nem jött össze :D Sokat segítenél vele. :)
A lottózó interiorra szeretném ha segítesz. :)
« Utoljára szerkesztve: 2015. október 16. - 18:17:35 írta JamesRamsey »

Parancs helymeghatározás!
« Válasz #3 Dátum: 2015. október 18. - 12:33:55 »
0 Show voters

COMMAND:lottery(playerid, params[])                                                     //Command: /lottery  to start.
{
if(GetPlayerInterior(playerid) == TEINTERIORODAMIKELL && IsPlayerInRangeOfPoint(playerid,3,POZICIOX,POZICIOY,POZICIOZ))
{
        if(LotteryStage[playerid] != -1) return SendClientMessage(playerid, 0xF25D46FF, \"{F4C670}[Lottery]: {FFFFFF}You are already playing!\");  // Check if player has already opened the Lottery
        LotteryStage[playerid] = 0;                                                 // Set players stage to 0  ( = select numbers)
        new b = Bet[playerid];                                                      // For shorter writing, store players\' bet in new variable
        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(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);
        PlayerTextDrawSetString(playerid, TDPrize[playerid][0], PrizeString[playerid][0]);  // Update rewards-textdraw string
        PlayerTextDrawSetString(playerid, TDPrize[playerid][1], PrizeString[playerid][1]);  // Update rewards-textdraw string
for(new i; i<sizeof(gTD); i++)
        {
            TextDrawShowForPlayer(playerid, gTD);                                // Show global textdraws
        }
        for(new i; i<100; i++)
        {
                PlayerTextDrawShow(playerid, TD[playerid]);                          // Show the numbers
        }
        PlayerTextDrawShow(playerid, TDPrize[playerid][0]);                         // Show rewards (left)
PlayerTextDrawShow(playerid, TDPrize[playerid][1]);                         // Show rewards (right)
PlayerTextDrawShow(playerid, TDNumber[playerid]);
PlayerTextDrawShow(playerid, TDHeader[playerid]);
   TextDrawShowForPlayer(playerid, TDLowerBet);                                // Show lower-bet button
TextDrawShowForPlayer(playerid, TDRaiseBet);                                // Show raise-bet button
TextDrawShowForPlayer(playerid, TDStart);                                   // Show PLAY-button
TextDrawShowForPlayer(playerid, TDClose);                                   // Show CLOSE-button
new str[8];
format(str, sizeof(str), \"$%d\", Bet[playerid]);                             // Format the bet-textdraw
        PlayerTextDrawSetString(playerid, TDBet[playerid], str);
        PlayerTextDrawShow(playerid, TDBet[playerid]);                              // Show the bet-textdraw
SelectTextDraw(playerid, 0xFF4040AA);                                       // Show the cursor
}
return 1;
}

 
ez  a rész a fontos:
 
if(GetPlayerInterior(playerid) == TEINTERIORODAMIKELL && IsPlayerInRangeOfPoint(playerid,3,POZICIOX,POZICIOY,POZICIOZ))

 
ezt neked kell tudnod.

Parancs helymeghatározás!
« Válasz #4 Dátum: 2015. október 18. - 20:07:34 »
0 Show voters
Köszönöm szépen. :)

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal