Advertisement
Lenny

Car bombs

Dec 1st, 2011
744
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 20.27 KB | None | 0 0
  1. //
  2. //              CAR BOMBS v1.0
  3. //                  by Lenny
  4. //
  5.  
  6. // CONFIGURATION
  7. //
  8.  
  9. #define FILTERSCRIPT
  10.  
  11. #define CB_COLOR_GREY                   0xAFAFAF00
  12. #define CB_COLOR_WHITE                  0xFFFFFFAA
  13. #define CB_COLOR_FADE1                  0xE6E6E6E6
  14. #define CB_COLOR_FADE3                  0xAAAAAAAA
  15. #define CB_COLOR_GREEN                  0x33AA33AA
  16. #define CB_COLOR_RED                    0xAA3333AA
  17. #define CB_COLOR_LIGHTRED               0xFF6347AA
  18.  
  19. #define BOMB_ARMTIME                    15      // Amount of seconds it takes to arm a bomb
  20. #define BOMB_CHECKTIME                  10      // Amount of seconds it takes to check for bombs in a vehicle
  21. #define BOMB_DISARMTIME                 5       // Amount of seconds it takes to attempt to disarm a bomb
  22. #define BOMB_USE_DISTANCE               3.0     // FLOAT, how far away the player has to be from the vehicle to use any bombs
  23.  
  24. stock PlayerHasCarBomb(playerid)
  25. {
  26.                                                 // Write your code to check if the player has a bomb
  27.     #pragma unused playerid                     // Don't forget to remove this line
  28.     return 1;
  29. }
  30.  
  31. stock CanPlayerDisarmBomb(playerid)
  32. {
  33.                                                 // Write your code to check if the player can disarm a bomb (Like if he is a police or something)
  34.     #pragma unused playerid                     // Don't forget to remove this line
  35.     return 1;
  36. }
  37.  
  38. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  39. {
  40.     #pragma unused playerid, ispassenger
  41.     CarBomb_OnVehicleStart(vehicleid);          // Move this some place else if you have a different technique of starting vehicles
  42. }
  43.  
  44. //
  45. // CONFIGURATION END
  46.  
  47. #include <a_samp>
  48. #include <zcmd>
  49. #include <strtok>
  50.  
  51. main() {}
  52.  
  53. stock Float:GetVehicleSpeed(vehicleid)
  54. {
  55.     new
  56.     Float:  speed_x,
  57.     Float:  speed_y,
  58.     Float:  speed_z,
  59.     Float:  temp_speed;
  60.  
  61.     GetVehicleVelocity(vehicleid, speed_x, speed_y, speed_z);
  62.  
  63.     temp_speed = floatsqroot( ( (speed_x * speed_x ) + ( speed_y * speed_y ) ) + ( speed_z * speed_z ) ) * 136.666667;
  64.    
  65.     return temp_speed;
  66. }
  67.  
  68. // Bomb types
  69. #define VEHICLE_BOMB_TYPE_UNARMED       0
  70. #define VEHICLE_BOMB_TYPE_IGNITION      1
  71. #define VEHICLE_BOMB_TYPE_TIMER         2
  72. #define VEHICLE_BOMB_TYPE_SPEED         3
  73. #define VEHICLE_BOMB_TYPE_REMOTE        4
  74.  
  75. // Timers
  76. forward PlayerPutBombInVehicle(seconds, playerid, vehicleid, bomb_type, bomb_timer);
  77. forward BombActivated(vehicleid);
  78. forward ArmSpeedBomb(vehicleid);
  79. forward CheckForBombs(playerid, vehicleid);
  80. forward DisarmBomb(playerid, vehicleid);
  81.  
  82. enum e_Bomb_Vehicles
  83. {
  84.             bv_i_ArmedType,
  85.             bv_i_ExplosionTimer,
  86.             bv_i_BombOwner,
  87.     bool:   bv_b_BombActivated,
  88.     bool:   bv_b_BombDisarmed
  89. };
  90.  
  91. new
  92.     g_Bomb_Vehicles[MAX_VEHICLES][e_Bomb_Vehicles];
  93.    
  94. stock ResetBombInfo(vehicleid)
  95. {                                  
  96.     g_Bomb_Vehicles[vehicleid][bv_i_ArmedType] = 0;            
  97.     g_Bomb_Vehicles[vehicleid][bv_i_ExplosionTimer] = 0;               
  98.     g_Bomb_Vehicles[vehicleid][bv_i_BombOwner] = 0;                
  99.     g_Bomb_Vehicles[vehicleid][bv_b_BombActivated] = false;
  100.     g_Bomb_Vehicles[vehicleid][bv_b_BombDisarmed] = false;
  101. }
  102.    
  103. public DisarmBomb(playerid, vehicleid)
  104. {
  105.     DeletePVar(playerid, "DisarmingBomb");
  106.    
  107.     new
  108.         Float: f_vPos[3];
  109.        
  110.     GetVehiclePos(vehicleid, f_vPos[0], f_vPos[1], f_vPos[2]);
  111.    
  112.     if(!IsPlayerInRangeOfPoint(playerid, BOMB_USE_DISTANCE, f_vPos[0], f_vPos[1], f_vPos[2]))
  113.     {
  114.         SendClientMessage(playerid, CB_COLOR_GREY, "You are not close enough to the vehicle anymore.");
  115.         return 1;
  116.     }
  117.    
  118.     ResetBombInfo(vehicleid);
  119.    
  120.     g_Bomb_Vehicles[vehicleid][bv_b_BombDisarmed] = true;
  121.        
  122.     SendClientMessage(playerid, CB_COLOR_GREEN, "You have disarmed the bomb.");
  123.    
  124.     return 1;
  125. }
  126.    
  127. public CheckForBombs(playerid, vehicleid)
  128. {
  129.     DeletePVar(playerid, "CheckingForBombs");
  130.     SetPVarInt(playerid, "CheckedCarForBombs", vehicleid);
  131.    
  132.     new
  133.         Float: f_vPos[3];
  134.        
  135.     GetVehiclePos(vehicleid, f_vPos[0], f_vPos[1], f_vPos[2]);
  136.    
  137.     if(!IsPlayerInRangeOfPoint(playerid, BOMB_USE_DISTANCE, f_vPos[0], f_vPos[1], f_vPos[2]))
  138.     {
  139.         SendClientMessage(playerid, CB_COLOR_GREY, "You are not close enough to the vehicle anymore.");
  140.         return 1;
  141.     }
  142.    
  143.     if(g_Bomb_Vehicles[vehicleid][bv_i_ArmedType])
  144.     {
  145.         SendClientMessage(playerid, CB_COLOR_RED, "You have found an armed bomb inside the vehicle!");
  146.         if(g_Bomb_Vehicles[vehicleid][bv_b_BombActivated])
  147.         {
  148.             SendClientMessage(playerid, CB_COLOR_LIGHTRED, "WARNING! THE BOMB IS ACTIVE AND ABOUT TO BLOW!");
  149.         }
  150.         SetPVarInt(playerid, "FoundBombInCar", vehicleid);
  151.     }
  152.    
  153.     else if(g_Bomb_Vehicles[vehicleid][bv_b_BombDisarmed])
  154.     {
  155.         SendClientMessage(playerid, CB_COLOR_GREEN, "You have found a disarmed bomb.");
  156.     }
  157.    
  158.     else
  159.     {
  160.         SendClientMessage(playerid, CB_COLOR_GREEN, "You didn't find any bombs.");
  161.     }
  162.    
  163.     return 1;
  164. }
  165.    
  166. stock CarBomb_OnVehicleStart(vehicleid)
  167. {
  168.     if(g_Bomb_Vehicles[vehicleid][bv_i_ArmedType] != VEHICLE_BOMB_TYPE_UNARMED && g_Bomb_Vehicles[vehicleid][bv_b_BombActivated] == false)
  169.     {
  170.         switch(g_Bomb_Vehicles[vehicleid][bv_i_ArmedType])
  171.         {
  172.             case VEHICLE_BOMB_TYPE_IGNITION:
  173.             {
  174.                 BombActivated(vehicleid);
  175.                 return 1;
  176.             }
  177.            
  178.             case VEHICLE_BOMB_TYPE_SPEED:
  179.             {
  180.                 SetTimerEx("ArmSpeedBomb", g_Bomb_Vehicles[vehicleid][bv_i_ExplosionTimer] * 1000, false, "d", vehicleid);
  181.                 return 1;
  182.             }
  183.         }
  184.     }
  185.    
  186.     return 1;
  187. }
  188.  
  189. public ArmSpeedBomb(vehicleid)
  190. {
  191.     if(GetVehicleSpeed(vehicleid) < 40.0)
  192.     {
  193.         g_Bomb_Vehicles[vehicleid][bv_i_ExplosionTimer] = 2;
  194.         BombActivated(vehicleid);
  195.         return 1;
  196.     }
  197.    
  198.     SetTimerEx("ArmSpeedBomb", 400, 0, "d", vehicleid);
  199.    
  200.     return 1;
  201. }
  202.    
  203. public BombActivated(vehicleid)
  204. {
  205.     if(g_Bomb_Vehicles[vehicleid][bv_b_BombDisarmed])
  206.     {
  207.         return 1;
  208.     }
  209.    
  210.     if(!g_Bomb_Vehicles[vehicleid][bv_i_ExplosionTimer])
  211.     {
  212.         ExplodeVehicleBomb(vehicleid);
  213.         g_Bomb_Vehicles[vehicleid][bv_i_ExplosionTimer]--;
  214.         SetTimerEx("BombActivated", 400, 0, "d", vehicleid);
  215.         return 1;
  216.     }
  217.    
  218.     new
  219.         Float:  f_Pos[3];
  220.        
  221.     GetVehiclePos(vehicleid, f_Pos[0], f_Pos[1], f_Pos[2]);
  222.    
  223.     if(g_Bomb_Vehicles[vehicleid][bv_i_ExplosionTimer] < 0)
  224.     {
  225.         CreateExplosion(f_Pos[0], f_Pos[1], f_Pos[2], 4, 2.0); // Extra effects
  226.         CreateExplosion(f_Pos[0], f_Pos[1], f_Pos[2], 5, 2.0); // Extra effects
  227.        
  228.         if(g_Bomb_Vehicles[vehicleid][bv_i_ExplosionTimer] == -2)
  229.         {
  230.             CreateExplosion(f_Pos[0], f_Pos[1], f_Pos[2], 1, 2.0); // Small explosion
  231.         }
  232.        
  233.         if(g_Bomb_Vehicles[vehicleid][bv_i_ExplosionTimer] < -3)
  234.         {
  235.             return 1;
  236.         }
  237.        
  238.         g_Bomb_Vehicles[vehicleid][bv_i_ExplosionTimer]--;
  239.         SetTimerEx("BombActivated", 400, 0, "d", vehicleid);
  240.         return 1;
  241.     }
  242.    
  243.     g_Bomb_Vehicles[vehicleid][bv_b_BombActivated] = true;
  244.    
  245.     if(g_Bomb_Vehicles[vehicleid][bv_i_ExplosionTimer] == 1)
  246.     {
  247.         PlayVehicleBombSound(vehicleid, 17803); // Clicking sound
  248.     }
  249.    
  250.     if(g_Bomb_Vehicles[vehicleid][bv_i_ExplosionTimer] == 2)
  251.     {
  252.         PlayVehicleBombSound(vehicleid, 6400); // Digital sound
  253.     }
  254.    
  255.     g_Bomb_Vehicles[vehicleid][bv_i_ExplosionTimer]--;
  256.    
  257.     SetTimerEx("BombActivated", 1000, 0, "d", vehicleid);
  258.    
  259.     return 1;
  260. }
  261.    
  262. public PlayerPutBombInVehicle(seconds, playerid, vehicleid, bomb_type, bomb_timer)
  263. {
  264.     if(!seconds)
  265.     {
  266.         TogglePlayerControllable(playerid, 1);
  267.         new
  268.             Float:  f_Pos[3];
  269.            
  270.         GetVehiclePos(vehicleid, f_Pos[0], f_Pos[1], f_Pos[2]);
  271.        
  272.         if(!IsPlayerInRangeOfPoint(playerid, BOMB_USE_DISTANCE, f_Pos[0], f_Pos[1], f_Pos[2]))
  273.         {
  274.             SendClientMessage(playerid, CB_COLOR_GREY, "ERROR: You are not close enough to this vehicle anymore.");
  275.             return 1;
  276.         }
  277.        
  278.         g_Bomb_Vehicles[vehicleid][bv_i_ArmedType] = bomb_type;
  279.         g_Bomb_Vehicles[vehicleid][bv_i_ExplosionTimer] = bomb_timer;
  280.         g_Bomb_Vehicles[vehicleid][bv_i_BombOwner] = playerid;
  281.        
  282.        
  283.         if(bomb_type == VEHICLE_BOMB_TYPE_TIMER)
  284.         {
  285.             //SetTimerEx("BombActivated", 1000, 0, "d", vehicleid);
  286.             BombActivated(vehicleid);
  287.         }
  288.        
  289.         DeletePVar(playerid, "PuttingBomb");
  290.        
  291.         SendClientMessage(playerid, CB_COLOR_GREEN, "You have planted and armed the bomb.");
  292.        
  293.         GameTextForPlayer(playerid, "~r~Bomb armed", 2000, 3);
  294.        
  295.         TogglePlayerControllable(playerid, 1);
  296.        
  297.         return 1;
  298.     }  
  299.    
  300.     new
  301.         szString[69];
  302.        
  303.     format(szString, sizeof(szString), "~g~Arming bomb...~n~~r~%d ~n~ ~y~Type ~r~/bomb put~y~ again to stop", seconds);
  304.     GameTextForPlayer(playerid, szString, 2000, 3);
  305.    
  306.     SetPVarInt(playerid, "PuttingBomb", SetTimerEx("PlayerPutBombInVehicle", 1000, 0, "ddddd", seconds - 1, playerid, vehicleid, bomb_type, bomb_timer));
  307.    
  308.     return 1;
  309. }
  310.  
  311. stock ExplodeVehicleBomb(vehicleid)
  312. {
  313.     SetVehicleHealth(vehicleid, 50.0);
  314.    
  315.     new
  316.         Float: f_vPos[3];
  317.        
  318.     GetVehiclePos(vehicleid, f_vPos[0], f_vPos[1], f_vPos[2]);
  319.    
  320.     CreateExplosion(f_vPos[0], f_vPos[1], f_vPos[2], 4, 5.0); // Extra effects
  321.     CreateExplosion(f_vPos[0], f_vPos[1], f_vPos[2], 5, 5.0); // Extra effects
  322.    
  323.     CreateExplosion(f_vPos[0], f_vPos[1], f_vPos[2], 6, 5.0); // Big one
  324.    
  325.     ResetBombInfo(vehicleid);
  326. }
  327.  
  328. CMD:bomb(playerid, params[])
  329. {
  330.     new
  331.         idx,
  332.         szParameters[2][128 - 6];
  333.        
  334.     szParameters[0] = strtok(params, idx);
  335.    
  336.     if(isnull(szParameters[0]))
  337.     {
  338.         SendClientMessage(playerid, CB_COLOR_GREY, "USAGE: /bomb [Parameter]");
  339.         SendClientMessage(playerid, CB_COLOR_GREY, "Available parameters: {E6E6E6}put{AFAFAF}, {E6E6E6}activate{AFAFAF}");
  340.        
  341.         if(CanPlayerDisarmBomb(playerid))
  342.         {
  343.             SendClientMessage(playerid, CB_COLOR_GREY, "{33CCFF}Disarming parameters{AFAFAF}: {E6E6E6}check{AFAFAF}, {E6E6E6}disarm{AFAFAF}");
  344.         }
  345.        
  346.         return 1;
  347.     }
  348.    
  349.     szParameters[1] = strtok(params, idx);
  350.    
  351.     if(!strcmp(szParameters[0], "put", true, 4))
  352.     {
  353.         new
  354.             BombTimerID = GetPVarInt(playerid, "PuttingBomb"),
  355.             szSetting[20],
  356.             iTimer;
  357.            
  358.         if(BombTimerID)
  359.         {
  360.             KillTimer(BombTimerID);
  361.             DeletePVar(playerid, "PuttingBomb");
  362.             GameTextForPlayer(playerid, "~r~Stopped arming bomb", 2000, 3);
  363.             TogglePlayerControllable(playerid, 1);
  364.             return 1;
  365.         }
  366.    
  367.         if(!PlayerHasCarBomb(playerid))
  368.         {
  369.             SendClientMessage(playerid, CB_COLOR_GREY, "ERROR: You don't have a bomb.");
  370.             return 1;
  371.         }
  372.        
  373.         szSetting = strtok(params, idx);
  374.         iTimer = strval(strtok(params, idx));
  375.    
  376.         if(isnull(szParameters[1]))
  377.         {
  378.             SendClientMessage(playerid, CB_COLOR_GREY, "USAGE: /bomb put [{E6E6E6}Vehicle ID{AFAFAF}] [{E6E6E6}Setting{AFAFAF}] [{E6E6E6}Timer (Seconds){AFAFAF}]");
  379.             SendClientMessage(playerid, CB_COLOR_FADE3, "Available settings: {E6E6E6}Ignition, timer, speed, remote"),
  380.             SendClientMessage(playerid, CB_COLOR_GREY, "NOTE: Use \"{E6E6E6}/bomb put help{AFAFAF}\" for explinations of use.");
  381.             return 1;
  382.         }
  383.        
  384.         if(!strcmp(szParameters[1], "help", true, 5))
  385.         {
  386.             SendClientMessage(playerid, CB_COLOR_WHITE, "[ BOMB PUT MANUAL ]");
  387.             SendClientMessage(playerid, CB_COLOR_WHITE, "Setting 1: IGNITION {AAAAAA}- Activates the bomb timer after the {E6E6E6}vehicle's ignition{AAAAAA} is activated.");
  388.             SendClientMessage(playerid, CB_COLOR_WHITE, "Setting 2: TIMER {AAAAAA}- {E6E6E6}Immediately{AAAAAA} activates the bomb timer.");
  389.             SendClientMessage(playerid, CB_COLOR_WHITE, "Setting 3: SPEED {AAAAAA}- The bomb will explode as soon as the {E6E6E6}vehicle speed{AAAAAA}");
  390.             SendClientMessage(playerid, CB_COLOR_FADE3, "drops under {E6E6E6}40{AAAAAA} km/h. It is activated {E6E6E6}as soon as the vehicle is started{AAAAAA}.");
  391.             SendClientMessage(playerid, CB_COLOR_WHITE, "Setting 4: REMOTE {AAAAAA}- Bomb is activated with \"{E6E6E6}/bomb activate{AAAAAA}\". Note that the {E6E6E6}remote range is limited{AAAAAA}.");
  392.             SendClientMessage(playerid, CB_COLOR_WHITE, "The timer: {AAAAAA}- Decides how long it takes for the bomb to {E6E6E6}detonate{AAAAAA} from the moment it is activated.");
  393.             SendClientMessage(playerid, CB_COLOR_FADE3, "You can get the {E6E6E6}ID{AAAAAA} of the vehicle by using the \"{E6E6E6}/dl{AAAAAA}\" command.");
  394.             SendClientMessage(playerid, CB_COLOR_WHITE, "[ END OF BOMB PUT MANUAL ]");
  395.             return 1;
  396.         }
  397.        
  398.         if( !GetVehicleModel( strval( szParameters[1] ) ) ) // The car isn't spawned
  399.         {
  400.             SendClientMessage(playerid, CB_COLOR_GREY, "ERROR: Invalid vehicle ID.");
  401.             SendClientMessage(playerid, CB_COLOR_GREY, "TIP: You can use \"{E6E6E6}/dl{AFAFAF}\" to see the IDs of nearby vehicles.");
  402.             return 1;
  403.         }
  404.        
  405.         if(IsPlayerInAnyVehicle(playerid))
  406.         {
  407.             SendClientMessage(playerid, CB_COLOR_GREY, "ERROR: You need to stand close to the vehicle, not in it.");
  408.             return 1;
  409.         }
  410.        
  411.         new
  412.                     iVehicleID = strval(szParameters[1]),
  413.             Float:  f_Pos[3];
  414.            
  415.         GetVehiclePos(iVehicleID, f_Pos[0], f_Pos[1], f_Pos[2]);
  416.        
  417.         if(!IsPlayerInRangeOfPoint(playerid, BOMB_USE_DISTANCE, f_Pos[0], f_Pos[1], f_Pos[2]))
  418.         {
  419.             SendClientMessage(playerid, CB_COLOR_GREY, "ERROR: You are not close enough to this vehicle.");
  420.             return 1;
  421.         }
  422.        
  423.         new
  424.             iSetting;
  425.        
  426.         if(!strcmp(szSetting, "ignition", true, 9))
  427.         {
  428.             if(iTimer < 1 || iTimer > 60)
  429.             {
  430.                 SendClientMessage(playerid, CB_COLOR_GREY, "ERROR: Invalid timer input. Must be between {E6E6E6}1{AFAFAF} and {E6E6E6}60{AFAFAF} seconds.");
  431.                 return 1;
  432.             }
  433.             iSetting = VEHICLE_BOMB_TYPE_IGNITION;
  434.         }
  435.        
  436.         else if(!strcmp(szSetting, "timer", true, 6))
  437.         {
  438.             if(iTimer < 10 || iTimer > 120)
  439.             {
  440.                 SendClientMessage(playerid, CB_COLOR_GREY, "ERROR: Invalid timer input. Must be between {E6E6E6}10{AFAFAF} and {E6E6E6}120{AFAFAF} seconds.");
  441.                 return 1;
  442.             }
  443.             iSetting = VEHICLE_BOMB_TYPE_TIMER;
  444.         }
  445.        
  446.         else if(!strcmp(szSetting, "speed", true, 6))
  447.         {
  448.             if(iTimer < 15 || iTimer > 60)
  449.             {
  450.                 SendClientMessage(playerid, CB_COLOR_GREY, "ERROR: Invalid timer input. Must be between {E6E6E6}15{AFAFAF} and {E6E6E6}60{AFAFAF} seconds.");
  451.                 return 1;
  452.             }
  453.             iSetting = VEHICLE_BOMB_TYPE_SPEED;
  454.         }
  455.        
  456.         else if(!strcmp(szSetting, "remote", true, 6))
  457.         {
  458.             if(iTimer < 1 || iTimer > 60)
  459.             {
  460.                 SendClientMessage(playerid, CB_COLOR_GREY, "ERROR: Invalid timer input. Must be between {E6E6E6}1{AFAFAF} and {E6E6E6}60{AFAFAF} seconds.");
  461.                 return 1;
  462.             }
  463.             iSetting = VEHICLE_BOMB_TYPE_REMOTE;
  464.         }
  465.            
  466.         else
  467.         {
  468.             SendClientMessage(playerid, CB_COLOR_GREY, "ERROR: Invalid setting. Please refer to manual: \"{E6E6E6}/bomb put help{AFAFAF}\".");
  469.             return 1;
  470.         }
  471.        
  472.         ResetBombInfo(iVehicleID);
  473.        
  474.         ApplyAnimation(playerid, "BOMBER", "BOM_Plant_Loop", 2.0, 0, 0, 0, 0, BOMB_ARMTIME * 1100, 0);
  475.        
  476.         SetPVarInt(playerid, "PuttingBomb", SetTimerEx("PlayerPutBombInVehicle", 0, 0, "ddddd", BOMB_ARMTIME, playerid, iVehicleID, iSetting, iTimer));
  477.    
  478.         return 1;
  479.        
  480.     }
  481.    
  482.     if(!strcmp(szParameters[0], "activate", true, 4))
  483.     {
  484.         new
  485.             Float:  f_vPos[3],
  486.                     iHasAnyRemoteBombs;
  487.            
  488.         for(new i; i < MAX_VEHICLES; i++)
  489.         {
  490.             if(g_Bomb_Vehicles[i][bv_i_ArmedType] == VEHICLE_BOMB_TYPE_REMOTE && g_Bomb_Vehicles[i][bv_i_BombOwner] == playerid)
  491.             {
  492.                 iHasAnyRemoteBombs = 1;
  493.                 GetVehiclePos(i, f_vPos[0], f_vPos[1], f_vPos[2]);
  494.                 if(IsPlayerInRangeOfPoint(playerid, 100.0, f_vPos[0], f_vPos[1], f_vPos[2]))
  495.                 {
  496.                     g_Bomb_Vehicles[i][bv_i_BombOwner] = INVALID_PLAYER_ID;
  497.                     BombActivated(i);
  498.                 }
  499.             }
  500.         }
  501.        
  502.         if(!iHasAnyRemoteBombs)
  503.         {
  504.             SendClientMessage(playerid, CB_COLOR_GREY, "ERROR: You haven't planted any bombs.");
  505.             return 1;
  506.         }
  507.        
  508.         new
  509.             Float:  f_Pos[3];
  510.            
  511.         GetPlayerPos(playerid, f_Pos[0], f_Pos[1], f_Pos[2]);
  512.        
  513.         PlayerPlaySound(playerid, 6400, f_Pos[0], f_Pos[1], f_Pos[2]);
  514.        
  515.         SendClientMessage(playerid, CB_COLOR_GREEN, "You pressed the trigger on your remote to active your bomb(s).");
  516.         SendClientMessage(playerid, CB_COLOR_GREY, "NOTE: The distance for the remote is limited.");
  517.        
  518.         return 1;
  519.     }
  520.    
  521.     if(CanPlayerDisarmBomb(playerid))
  522.     {
  523.         if(!strcmp(szParameters[0], "check", true, 4))
  524.         {
  525.             new
  526.                 BombCheckingTimerID = GetPVarInt(playerid, "CheckingForBombs");
  527.                
  528.             if(BombCheckingTimerID)
  529.             {
  530.                 KillTimer(BombCheckingTimerID);
  531.                 DeletePVar(playerid, "CheckingForBombs");
  532.                 GameTextForPlayer(playerid, "~r~Stopped looking for bombs", 2000, 3);
  533.                 return 1;
  534.             }
  535.            
  536.             if(GetPVarInt(playerid, "DisarmingBomb"))
  537.             {
  538.                 SendClientMessage(playerid, CB_COLOR_GREY, "You are busy disarming the bomb.");
  539.                 return 1;
  540.             }
  541.            
  542.             if(isnull(szParameters[1]))
  543.             {
  544.                 SendClientMessage(playerid, CB_COLOR_GREY, "USAGE: /bomb check [Vehicle ID]");
  545.                 return 1;
  546.             }
  547.            
  548.             new
  549.                 iVehicleID = strval(szParameters[1]);
  550.            
  551.             if(!GetVehicleModel(iVehicleID))
  552.             {
  553.                 SendClientMessage(playerid, CB_COLOR_GREY, "ERROR: Invalid vehicle ID.");
  554.                 SendClientMessage(playerid, CB_COLOR_GREY, "TIP: You can use \"{E6E6E6}/dl{AFAFAF}\" to see the IDs of nearby vehicles.");
  555.                 return 1;
  556.             }
  557.            
  558.             if(IsPlayerInAnyVehicle(playerid))
  559.             {
  560.                 SendClientMessage(playerid, CB_COLOR_GREY, "ERROR: You need to stand close to the vehicle, not in it.");
  561.                 return 1;
  562.             }
  563.            
  564.             new
  565.                 Float: f_vPos[3];
  566.                
  567.             GetVehiclePos(iVehicleID, f_vPos[0], f_vPos[1], f_vPos[2]);
  568.            
  569.             if(!IsPlayerInRangeOfPoint(playerid, BOMB_USE_DISTANCE, f_vPos[0], f_vPos[1], f_vPos[2]))
  570.             {
  571.                 SendClientMessage(playerid, CB_COLOR_GREY, "You are not close enough to the vehicle.");
  572.                 return 1;
  573.             }
  574.            
  575.             GameTextForPlayer(playerid, "~g~Checking for bombs... ~n~ ~y~Type ~r~/bomb check~y~ again to stop.", BOMB_CHECKTIME * 1100, 3);
  576.            
  577.             ApplyAnimation(playerid, "BOMBER", "BOM_Plant_Loop", 2.0, 0, 0, 0, 0, BOMB_CHECKTIME * 1100, 0);
  578.            
  579.             SetPVarInt(playerid, "CheckingForBombs", SetTimerEx("CheckForBombs", BOMB_CHECKTIME * 1000, 0, "dd", playerid, iVehicleID));
  580.            
  581.             return 1;
  582.         }
  583.        
  584.         if(!strcmp(szParameters[0], "disarm", true, 4))
  585.         {
  586.             new
  587.                 DisarmingBombTimerID = GetPVarInt(playerid, "DisarmingBomb");
  588.                
  589.             if(DisarmingBombTimerID)
  590.             {
  591.                 KillTimer(DisarmingBombTimerID);
  592.                 DeletePVar(playerid, "DisarmingBomb");
  593.                 GameTextForPlayer(playerid, "~r~Stopped disarming the bomb", 2000, 3);
  594.                 return 1;
  595.             }
  596.            
  597.             if(GetPVarInt(playerid, "CheckingForBombs"))
  598.             {
  599.                 SendClientMessage(playerid, CB_COLOR_GREY, "You are busy checking for bombs.");
  600.                 return 1;
  601.             }
  602.            
  603.             if(isnull(szParameters[1]))
  604.             {
  605.                 SendClientMessage(playerid, CB_COLOR_GREY, "USAGE: /bomb disarm [Vehicle ID]");
  606.                 SendClientMessage(playerid, CB_COLOR_GREY, "TIP: You can use \"{E6E6E6}/dl{AFAFAF}\" to see the IDs of nearby vehicles.");
  607.                 return 1;
  608.             }
  609.            
  610.             new
  611.                 iVehicleID = strval(szParameters[1]);
  612.            
  613.             if(!GetVehicleModel(iVehicleID))
  614.             {
  615.                 SendClientMessage(playerid, CB_COLOR_GREY, "ERROR: Invalid vehicle ID.");
  616.                 SendClientMessage(playerid, CB_COLOR_GREY, "TIP: You can use \"{E6E6E6}/dl{AFAFAF}\" to see the IDs of nearby vehicles.");
  617.                 return 1;
  618.             }
  619.            
  620.             if(IsPlayerInAnyVehicle(playerid))
  621.             {
  622.                 SendClientMessage(playerid, CB_COLOR_GREY, "ERROR: You need to stand close to the vehicle, not in it.");
  623.                 return 1;
  624.             }
  625.            
  626.             new
  627.                 Float: f_vPos[3];
  628.                
  629.             GetVehiclePos(iVehicleID, f_vPos[0], f_vPos[1], f_vPos[2]);
  630.            
  631.             if(!IsPlayerInRangeOfPoint(playerid, BOMB_USE_DISTANCE, f_vPos[0], f_vPos[1], f_vPos[2]))
  632.             {
  633.                 SendClientMessage(playerid, CB_COLOR_GREY, "You are not close enough to the vehicle.");
  634.                 return 1;
  635.             }
  636.            
  637.             if(GetPVarInt(playerid, "CheckedCarForBombs") != iVehicleID)
  638.             {
  639.                 SendClientMessage(playerid, CB_COLOR_GREY, "ERROR: You haven't checked this car for bombs yet, you need to see where it is first.");
  640.                 return 1;
  641.             }
  642.            
  643.             if(GetPVarInt(playerid, "FoundBombInCar") != iVehicleID)
  644.             {
  645.                 SendClientMessage(playerid, CB_COLOR_GREY, "ERROR: You haven't found any bombs on this vehicle.");
  646.                 return 1;
  647.             }
  648.            
  649.             GameTextForPlayer(playerid, "~g~Disarming bomb...~n~ ~y~Type ~r~/bomb disarm~y~ again to stop.", BOMB_DISARMTIME * 1000, 3);
  650.            
  651.             ApplyAnimation(playerid, "BOMBER", "BOM_Plant_Loop", 2.0, 0, 0, 0, 0, BOMB_DISARMTIME * 1100, 0);
  652.            
  653.             SetPVarInt(playerid, "DisarmingBomb", SetTimerEx("DisarmBomb", BOMB_DISARMTIME * 1000, 0, "dd", playerid, iVehicleID));
  654.            
  655.             return 1;
  656.         }
  657.     }
  658.    
  659.     SendClientMessage(playerid, CB_COLOR_GREY, "ERROR: Invalid parameter. For a full list of available parameters, type \"/bomb\".");
  660.     return 1;
  661. }
  662.  
  663. stock PlayVehicleBombSound(vehicleid, sound)
  664. {
  665.     new
  666.         Float:  v_Pos[3];
  667.        
  668.     GetVehiclePos(vehicleid, v_Pos[0], v_Pos[1], v_Pos[2]);
  669.    
  670.     for(new i; i < MAX_PLAYERS; i++)
  671.     {
  672.         if(IsPlayerInVehicle(i, vehicleid))
  673.         {
  674.             PlayerPlaySound(i, sound, v_Pos[0], v_Pos[1],v_Pos[2]);
  675.         }
  676.         else
  677.         {
  678.             if(IsPlayerInRangeOfPoint(i, 10.0, v_Pos[0], v_Pos[1], v_Pos[2]))
  679.             {
  680.                 PlayerPlaySound(i, sound, v_Pos[0], v_Pos[1],v_Pos[2]);
  681.             }
  682.         }
  683.     }
  684. }
  685.  
  686. public OnPlayerDisconnect(playerid, reason)
  687. {
  688.     for(new i; i < MAX_VEHICLES; i++)
  689.     {
  690.         if(g_Bomb_Vehicles[i][bv_i_BombOwner] == playerid)
  691.         {
  692.             g_Bomb_Vehicles[i][bv_i_BombOwner] = INVALID_PLAYER_ID;
  693.         }
  694.     }
  695. }
  696.  
  697. #if defined FILTERSCRIPT
  698.     public OnFilterScriptInit()
  699.     {
  700.         printf("    Loaded Car Bombs v1.0 by Lenny");
  701.     }
  702. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement