Advertisement
Guest User

Roadblock It

a guest
Jun 3rd, 2010
2,394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.61 KB | None | 0 0
  1. // Top of your script
  2. #define MAX_ROADBLOCKS 85 // Can be anything you want, but don't go over the top.
  3.  
  4. // Search enum in your script and add this:
  5.  
  6. enum rInfo
  7. {
  8.     sCreated,
  9.     Float:sX,
  10.     Float:sY,
  11.     Float:sZ,
  12.     sObject,
  13. };
  14. new Roadblocks[MAX_ROADBLOCKS][rInfo];
  15.  
  16. // Place this under OnPlayerCommandText
  17.  
  18. if(strcmp(cmd, "/crb", true) == 0)
  19.     {
  20.         if(IsPlayerConnected(playerid) && IsACop(playerid) || IsPlayerAdmin(playerid))
  21.         {
  22.             tmp = strtok(cmdtext, idx);
  23.             if(!strlen(tmp))
  24.             {
  25.                 SendClientMessage(playerid, COLOR_WHITE, "USAGE: /crb [Roadblock ID]");
  26.                 SendClientMessage(playerid, COLOR_LIGHTBLUE, "Available Roadblocks:");
  27.                 SendClientMessage(playerid, COLOR_GRAD1, "| 1: Small Roadblock");
  28.                 SendClientMessage(playerid, COLOR_GRAD1, "| 2: Medium Roadblock");
  29.                 SendClientMessage(playerid, COLOR_GRAD1, "| 3: Big Roadblock");
  30.                 SendClientMessage(playerid, COLOR_GRAD1, "| 3: Cone");
  31.                 return 1;
  32.             }
  33.             new rb = strval(tmp);
  34.             if (rb == 1)
  35.             {
  36.                 PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
  37.                 new Float:plocx,Float:plocy,Float:plocz,Float:ploca;
  38.                 GetPlayerPos(playerid, plocx, plocy, plocz);
  39.                 GetPlayerFacingAngle(playerid,ploca);
  40.                 CreateRoadblock(1459,plocx,plocy,plocz,ploca);
  41.                 format(string,sizeof(string),"[HQ]: Officer %s has placed a Roadblock(1) at his position, over.",GPN(playerid));
  42.                 SendRadioMessage(1,COLOR_BLUE,string);
  43.                 GameTextForPlayer(playerid,"~w~Roadblock ~b~Placed!",3000,1);
  44.                 return 1;
  45.             }
  46.             else if (rb == 2)
  47.             {
  48.                 PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
  49.                 new Float:plocx,Float:plocy,Float:plocz,Float:ploca;
  50.                 GetPlayerPos(playerid, plocx, plocy, plocz);
  51.                 GetPlayerFacingAngle(playerid,ploca);
  52.                 CreateRoadblock(978,plocx,plocy,plocz+0.6,ploca);
  53.                 format(string,sizeof(string),"[HQ]: Officer %s has placed a Roadblock(2) at his position, over.",GPN(playerid));
  54.                 SendRadioMessage(1,COLOR_BLUE,string);
  55.                 GameTextForPlayer(playerid,"~w~Roadblock ~b~Placed!",3000,1);
  56.                 return 1;
  57.             }
  58.             else if (rb == 3)
  59.             {
  60.                 PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
  61.                 new Float:plocx,Float:plocy,Float:plocz,Float:ploca;
  62.                 GetPlayerPos(playerid, plocx, plocy, plocz);
  63.                 GetPlayerFacingAngle(playerid,ploca);
  64.                 CreateRoadblock(981,plocx,plocy,plocz+0.9,ploca+180);
  65.                 format(string,sizeof(string),"[HQ]: Officer %s has placed a Roadblock(3) at his position, over.",GPN(playerid));
  66.                 SendRadioMessage(1,COLOR_BLUE,string);
  67.                 GameTextForPlayer(playerid,"~w~Roadblock ~g~Placed!",3000,1);
  68.                 SetPlayerPos(playerid, plocx, plocy+1.3, plocz);
  69.                 return 1;
  70.             }
  71.             else if (rb == 4)
  72.             {
  73.                 PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
  74.                 new Float:plocx,Float:plocy,Float:plocz,Float:ploca;
  75.                 GetPlayerPos(playerid, plocx, plocy, plocz);
  76.                 GetPlayerFacingAngle(playerid,ploca);
  77.                 CreateRoadblock(1238,plocx,plocy,plocz+0.2,ploca);
  78.                 format(string,sizeof(string),"[HQ]: Officer %s has placed a Traffic Cone(1) at his position, over.",GPN(playerid));
  79.                 SendRadioMessage(1,COLOR_BLUE,string);
  80.                 GameTextForPlayer(playerid,"~w~Cone ~g~Placed!",3000,1);
  81.                 return 1;
  82.             }
  83.             /*else if (rb == 4)
  84.             {
  85.                 PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
  86.                 new Float:plocx,Float:plocy,Float:plocz,Float:ploca;
  87.                 GetPlayerPos(playerid, plocx, plocy, plocz);
  88.                 GetPlayerFacingAngle(playerid,ploca);
  89.                 CreateRoadblock(1425,plocx,plocy,plocz+0.6,ploca);
  90.                 format(string,sizeof(string),"[HQ]: Officer %s has placed a Detour Sign(4) at his position, over.",GPN(playerid));
  91.                 SendRadioMessage(1,COLOR_BLUE,string);
  92.                 GameTextForPlayer(playerid,"~w~Sign ~g~Placed!",3000,1);
  93.                 return 1;
  94.             }
  95.             else if (rb == 5)
  96.             {
  97.                 PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
  98.                 new Float:plocx,Float:plocy,Float:plocz,Float:ploca;
  99.                 GetPlayerPos(playerid, plocx, plocy, plocz);
  100.                 GetPlayerFacingAngle(playerid,ploca);
  101.                 CreateRoadblock(3265,plocx,plocy,plocz-0.5,ploca);
  102.                 format(string,sizeof(string),"[HQ]: Officer %s has placed a Will Be Sign(5) at his position, over.",GPN(playerid));
  103.                 SendRadioMessage(1,COLOR_BLUE,string);
  104.                 GameTextForPlayer(playerid,"~w~Sign ~g~Placed!",3000,1);
  105.                 return 1;
  106.             }
  107.             else if (rb == 6)
  108.             {
  109.                 PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
  110.                 new Float:plocx,Float:plocy,Float:plocz,Float:ploca;
  111.                 GetPlayerPos(playerid, plocx, plocy, plocz);
  112.                 GetPlayerFacingAngle(playerid,ploca);
  113.                 CreateRoadblock(3091,plocx,plocy,plocz+0.5,ploca+180);
  114.                 format(string,sizeof(string),"[HQ]: Officer %s has placed a Line Closed Sign(6) at his position, over.",GPN(playerid));
  115.                 SendRadioMessage(1,COLOR_BLUE,string);
  116.                 GameTextForPlayer(playerid,"~w~Sign ~g~Placed!",3000,1);
  117.                 return 1;
  118.             }*/
  119.         }
  120.         return 1;
  121.     }
  122.     else if (strcmp(cmd,"/rrb",true) == 0)
  123.     {
  124.         if(IsPlayerConnected(playerid) && IsACop(playerid) || IsPlayerAdmin(playerid))
  125.         {
  126.             DeleteClosestRoadblock(playerid);
  127.             format(string,sizeof(string),"[HQ]: Officer %s has removed a Roadblock, over.",GPN(playerid));
  128.             SendRadioMessage(1,COLOR_BLUE,string);
  129.             GameTextForPlayer(playerid,"~w~Roadblock ~r~Removed!",3000,1);
  130.         }
  131.         return 1;
  132.     }
  133.     else if (strcmp(cmd,"/rrball",true) == 0)
  134.     {
  135.         if(IsPlayerConnected(playerid) && IsACop(playerid) || IsPlayerAdmin(playerid))
  136.         {
  137.             if(PlayerInfo[playerid][pRank] >= 6 || IsPlayerAdmin(playerid)) // This being the default Chief rank in LA-RP change if neccesary.
  138.             {
  139.                 DeleteAllRoadblocks(playerid);
  140.                 format(string,sizeof(string),"[HQ]: Officer %s has removed all Roadblocks in the area, over.",GPN(playerid));
  141.                 SendRadioMessage(1,COLOR_BLUE,string);
  142.                 GameTextForPlayer(playerid,"~b~All ~w~Roadblocks ~r~Removed!",3000,1);
  143.             }
  144.         }
  145.         return 1;
  146.     }
  147.  
  148. // Place this under your script
  149.  
  150. stock CreateRoadblock(Object,Float:x,Float:y,Float:z,Float:Angle)
  151. {
  152.     for(new i = 0; i < sizeof(Roadblocks); i++)
  153.     {
  154.         if(Roadblocks[i][sCreated] == 0)
  155.         {
  156.             Roadblocks[i][sCreated] = 1;
  157.             Roadblocks[i][sX] = x;
  158.             Roadblocks[i][sY] = y;
  159.             Roadblocks[i][sZ] = z-0.7;
  160.             Roadblocks[i][sObject] = CreateDynamicObject(Object, x, y, z-0.9, 0, 0, Angle);
  161.             return 1;
  162.         }
  163.     }
  164.     return 0;
  165. }
  166.  
  167. stock DeleteAllRoadblocks(playerid)
  168. {
  169.     for(new i = 0; i < sizeof(Roadblocks); i++)
  170.     {
  171.         if(IsPlayerInRangeOfPoint(playerid, 100, Roadblocks[i][sX], Roadblocks[i][sY], Roadblocks[i][sZ]))
  172.         {
  173.             if(Roadblocks[i][sCreated] == 1)
  174.             {
  175.                 Roadblocks[i][sCreated] = 0;
  176.                 Roadblocks[i][sX] = 0.0;
  177.                 Roadblocks[i][sY] = 0.0;
  178.                 Roadblocks[i][sZ] = 0.0;
  179.                 DestroyDynamicObject(Roadblocks[i][sObject]);
  180.             }
  181.         }
  182.     }
  183.     return 0;
  184. }
  185.  
  186. stock DeleteClosestRoadblock(playerid)
  187. {
  188.     for(new i = 0; i < sizeof(Roadblocks); i++)
  189.     {
  190.         if(IsPlayerInRangeOfPoint(playerid, 5.0, Roadblocks[i][sX], Roadblocks[i][sY], Roadblocks[i][sZ]))
  191.         {
  192.             if(Roadblocks[i][sCreated] == 1)
  193.             {
  194.                 Roadblocks[i][sCreated] = 0;
  195.                 Roadblocks[i][sX] = 0.0;
  196.                 Roadblocks[i][sY] = 0.0;
  197.                 Roadblocks[i][sZ] = 0.0;
  198.                 DestroyDynamicObject(Roadblocks[i][sObject]);
  199.                 return 1;
  200.             }
  201.         }
  202.     }
  203.     return 0;
  204. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement