bgtracker

Bank Robbery System

May 11th, 2013
4,544
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. This script/application is created by UnlimitedDeveloper from SAMP forums
  3. and it's supposed to be shared only at SAMP forums, nowhere else!
  4. If any copy of this script is found on another forum, it will be taken down.
  5. */
  6. #include <a_samp>
  7. #include <zcmd>
  8.  
  9. #define COLOR_WHITE 0xFFFFFFAA
  10.  
  11. //Function forwarding
  12. /*
  13. Firstly we have to forward the functions that we are going
  14. to use later in our sript.
  15. */
  16. forward robtimer(playerid);
  17. forward waittimer();
  18.  
  19. //Variables
  20. /*
  21. We are adding a NEW Variable so we can determine wether the bank
  22. can or cannot be robber at a certain time.
  23. */
  24. new robpossible;
  25.  
  26. public OnFilterScriptInit()
  27. {
  28.     /*
  29.     When the filterscript executes itself it's setting the 'robpossible'
  30.     variable to 1 which means that we can rob the bank right after we login.
  31.     */
  32.     robpossible = 1;
  33.     return 1;
  34. }
  35.  
  36. //Command(s)
  37. CMD:robbank(playerid, params[])
  38. {
  39.     if(robpossible == 1) //If the bank can be robbed we continue below
  40.     {
  41.         if(IsPlayerInRangeOfPoint(playerid, 3.0, 2309.1899,-8.4444,26.7422))
  42.         {//Next thing we do is, we check if we are at the bank interior ^^
  43.             robpossible = 0; //Then we set the bank so it cannot be robbed
  44.             SetTimer("waittimer", 300000, false); //Normal Mode 5 minutes
  45.             /*We run the timer(5 minutes) for the function that is going to make the
  46.             bank available for robbing again
  47.             */
  48.             //SetTimer("waittimer", 65000, false); //Test Mode 65 seconds
  49.             SetTimer("robtimer", 60000, false);
  50.             /* We also run another timer(1 minute) for the function that is
  51.             actually going to give us the money and a user friendly message.
  52.             */
  53.             /*
  54.             Add a function that would notify the police.
  55.             */
  56.             SendClientMessage(playerid, COLOR_WHITE, "You are robbing the bank, the police has been notified!");
  57.             SendClientMessage(playerid, COLOR_WHITE, "You gotta stay 30 seconds in the bank in order to rob it!");
  58.          }
  59.     } else {
  60.         SendClientMessage(playerid, COLOR_WHITE, "You can't rob the bank right now!");
  61.     }
  62.     return 1;
  63. }
  64.  
  65. //Functions
  66. public robtimer(playerid)
  67. {
  68.     new string[128];//We are defining a new string for the formatted message that we are displaying later on.
  69.     new cash = random(200000);
  70.     GivePlayerMoney(playerid, cash);
  71.     /*
  72.     With the fuction above 'new cash = random(200000);
  73.     GivePlayerMoney(playerid, cash);' we give the player
  74.     a random amount of money from $0 - $200,000
  75.     */
  76.     //Here below we use the string we defined above to format the message itself and display it to the player.
  77.     format(string, sizeof(string), "You have successfully robbed $%d from the bank!", cash);
  78.     SendClientMessage(playerid, COLOR_WHITE, string);
  79. }
  80.  
  81. public waittimer()
  82. {
  83.     robpossible = 1; //With this we make the bank available for robbery again, and we display a friendly message to all players.
  84.     SendClientMessageToAll(COLOR_WHITE, "The bank is now available for robbery!");
  85. }
RAW Paste Data