Advertisement
Guest User

Solution(?)

a guest
Aug 14th, 2014
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.14 KB | None | 0 0
  1. #include <a_samp>
  2. #include <streamer>
  3. #include <zcmd>
  4.  
  5. #define COLOR_RED 0xFF0000AA
  6. #define COLOR_BLUE 0x0000FFAA
  7. #define COLOR_WHITE 0xFFFFFFAA
  8. #define COLOR_YELLOW 0xFFFF00AA
  9. #define COLOR_GREEN 0x33AA33AA
  10. #define COL_WHITE "{FFFFFF}"
  11. #define COL_RED "{F81414}"
  12. #define COL_GREEN "{00FF22}"
  13. #define COL_LIGHTBLUE "{00CED1}"
  14. #define COLOR_ORANGE 0xFFA500AA
  15.  
  16. new CP_pizza; // The name of the checkpoint add whatever you want :)
  17. new ROBBING_PIZZA[MAX_PLAYERS]; //used when you rob
  18. new pizzarobbedrecently =0; // to make the players wait before robbing more
  19.  
  20. stock GivePlayerScore( playerid, score ) SetPlayerScore( playerid, GetPlayerScore( playerid ) + score );
  21.  
  22. forward ServerRobbery();
  23.  
  24. public OnFilterScriptInit()
  25. {
  26.     SetTimer("ServerRobbery",1000,1);// Ticks every 1 second
  27.     return 1;
  28. }
  29.  
  30. public OnFilterScriptExit()
  31. {
  32.     return 1;
  33. }
  34.  
  35. public OnPlayerRequestClass(playerid, classid)
  36. {
  37.     return 1;
  38. }
  39.  
  40. public OnPlayerConnect(playerid)
  41. {
  42.     CP_pizza = CreateDynamicCP( 378.2259, -114.4946, 1001.4922, 2.0, -1, -1, -1, 40.0);
  43.     return 1;
  44. }
  45.  
  46. public OnPlayerEnterDynamicCP(playerid, checkpointid) //Add this anywhere
  47. {
  48.    if(checkpointid == CP_pizza) //Checking if player is in the checkpoint "Tatoo"
  49.    {
  50.     SendClientMessage(playerid, COLOR_RED, "Start robbery by typing /robpizza"); //Sending message so that player knows that to rob. he must type this command
  51.    }
  52.    return 1;
  53. }
  54.  
  55. CMD:robpizza(playerid, params[])
  56. {
  57.     if(!IsPlayerInDynamicCP(playerid, CP_pizza)) return SendClientMessage(playerid, COLOR_RED,"You are not in ....");
  58.     {
  59.         if(pizzarobbedrecently >=1) //checking if tatoo shop has been robbed recently
  60.         {
  61.             SendClientMessage(playerid, COLOR_RED, "Well Stacked Pizza has been robbed recently"); // sending error message
  62.         }
  63.         ROBBING_PIZZA[playerid] = 60; // setting the robbery timer
  64.         pizzarobbedrecently =180; // Time the players needs to wait for starting an another robbery in the same place
  65.     format(time,sizeof(time),"Robbery Time: %d",ROBBING_PIZZA[i]);
  66.         GameTextForPlayer(i,time,1000,5);
  67.     }
  68.     return 1;
  69. }
  70.  
  71. public ServerRobbery()
  72. {
  73.         for(new i=0; i<MAX_PLAYERS; i++)
  74.         {
  75.             if(IsPlayerConnected(i)) // checking if player connected
  76.             {
  77.                 //ROBBERIES
  78.                 if(ROBBING_PIZZA[i] > 1) // Checking if robbery time is above 1
  79.                 {
  80.                     ROBBING_PIZZA[i] --; // Decreasing time
  81.                     new time[30]; //adding time variable
  82.                     format(time,sizeof(time),"Robbery Time: %d",ROBBING_PIZZA[i]);
  83.                     GameTextForPlayer(i,time,1000,5); //shows gametext showing the time remaining for the robbery
  84.                 }
  85.                 if(ROBBING_PIZZA[i] == 1) // IF the timer reached 1
  86.                 {
  87.                     new string[64], pName[MAX_PLAYER_NAME];// getting player name
  88.                     GetPlayerName(i,pName,MAX_PLAYER_NAME);
  89.                     SendClientMessage(i, COLOR_GREEN, "Robbery Complete"); //sending message to the player that robbery was complete
  90.                     SetPlayerWantedLevel(i, GetPlayerWantedLevel(i) + 1); //giving player 1 wanted level
  91.                     ROBBING_PIZZA[i] =0; // RESET timer
  92.                     new mrand =random(50000);
  93.                     GivePlayerScore(i,1);
  94.                     format(string,sizeof(string),"[ROBBERY] %s(%d) has robbed a total of $%d from Well Stacked Pizza!",pName,i,mrand);
  95.                     SendClientMessageToAll(COLOR_RED,string);
  96.                     GivePlayerMoney(i, mrand);
  97.                 }
  98.             }
  99.         }
  100.         return 1;
  101. }
  102.  
  103. public OnPlayerLeaveDynamicCP(playerid, checkpointid)
  104. {
  105.     if(checkpointid == CP_pizza) // checking if the player is leaving the CP tatoo
  106.     {
  107.         if(ROBBING_PIZZA[playerid] >= 1) //checking if the person was robbing and his robbery timer was above 1
  108.         {
  109.             SendClientMessage(playerid, COLOR_RED, "[ERROR]Robbery Failed"); //Error message that he failed
  110.             ROBBING_PIZZA[playerid] =0; // Setting Robbing_pizza to 0. to stop the counter
  111.         }
  112.     }
  113.     return 1;
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement