Advertisement
SalvatorCodes

Vehicle Damage Enabler [Alpha v2.0]

Mar 5th, 2016
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.15 KB | None | 0 0
  1. /*************************************
  2. **************************************
  3. ******* Vehicle Damage Enabler *******
  4. *******[Alpha v2.0] by Salvator ******
  5. **************************************
  6. **************************************/
  7.  
  8. #include <a_samp>
  9.  
  10. public OnFilterScriptInit()
  11. {
  12.     print("Vehicle Damage Enabler [Alpha v2.0] by Salvator");
  13.     return 1;
  14. }
  15.  
  16. forward DriverAvailable(vehicleid); //Not sure who originally made this function, but this is with my edits
  17. public DriverAvailable(vehicleid)
  18. {
  19.     for(new i=0; i<= MAX_PLAYERS; i++)
  20.     {
  21.         if(IsPlayerInAnyVehicle(i))
  22.         {
  23.             if(GetPlayerVehicleID(i) == vehicleid)
  24.             {
  25.                 if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
  26.                 {
  27.                     return 1;
  28.                 }
  29.             }
  30.         }
  31.     }
  32.     return 0;
  33. }
  34.  
  35. IsAirModel(modelid) //Thanks and credits goes to AmigaBlizzard for showing me this function
  36. {
  37.     switch(modelid)
  38.     {
  39.         case 460, 476, 511, 512, 513, 519, 520, 553, 577, 592, 593, 417, 425, 447, 469, 487, 488, 497, 548, 563:
  40.         return 1;
  41.     }
  42.     return 0;
  43. }
  44.  
  45. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  46. {
  47.     new wID = weaponid;
  48.     new Float:vHealth; GetVehicleHealth(hitid, vHealth);
  49.    
  50.     if(hittype == 2 && !DriverAvailable(hitid) && vHealth > 249)
  51.     {
  52.         if(IsAirModel(GetVehicleModel(hitid)) == 1)
  53.         {
  54.             if(wID == 28 || wID == 32) SetVehicleHealth(hitid, vHealth - 8);
  55.             if(wID == 22 || wID == 29) SetVehicleHealth(hitid, vHealth - 10);
  56.             if(wID == 30 || wID == 31) SetVehicleHealth(hitid, vHealth - 12);
  57.             if(wID == 23) SetVehicleHealth(hitid, vHealth - 16);
  58.             if(wID == 33) SetVehicleHealth(hitid, vHealth - 30);
  59.             if(wID == 27) SetVehicleHealth(hitid, vHealth - 48);
  60.             if(wID == 34) SetVehicleHealth(hitid, vHealth - 50);
  61.             if(wID == 24 || wID == 38) SetVehicleHealth(hitid, vHealth - 56);
  62.             if(wID == 25 || wID == 26) SetVehicleHealth(hitid, vHealth - 60);
  63.         }
  64.         else
  65.         {
  66.             if(wID == 28 || wID == 32) SetVehicleHealth(hitid, vHealth - 20);
  67.             if(wID == 22 || wID == 29) SetVehicleHealth(hitid, vHealth - 25);
  68.             if(wID == 30 || wID == 31) SetVehicleHealth(hitid, vHealth - 30);
  69.             if(wID == 23) SetVehicleHealth(hitid, vHealth - 40);
  70.             if(wID == 33) SetVehicleHealth(hitid, vHealth - 75);
  71.             if(wID == 27) SetVehicleHealth(hitid, vHealth - 120);
  72.             if(wID == 34) SetVehicleHealth(hitid, vHealth - 125);
  73.             if(wID == 24 || wID == 38) SetVehicleHealth(hitid, vHealth - 140);
  74.             if(wID == 25 || wID == 26) SetVehicleHealth(hitid, vHealth - 150);
  75.         }
  76.         new vModel = GetVehicleModel(hitid);
  77.         new Float:hX, Float:hY, Float:hZ, Float:rX, Float:rY, Float:rZ;
  78.         GetVehicleModelInfo(vModel, VEHICLE_MODEL_INFO_WHEELSFRONT, hX, hY, hZ);
  79.         GetVehicleModelInfo(vModel, VEHICLE_MODEL_INFO_WHEELSREAR, rX, rY, rZ);
  80.         new panels, doors, lights, tires;
  81.        
  82.         //Gammix's vehicleplus.inc helped me realize how to define wheels position, so I'd like to thank him.
  83.  
  84.         //Left front wheel
  85.         if( fX >= hX - 3.0 && fX <= hX + 0.0 &&
  86.             fY >= hY - 0.5 && fY <= hY + 0.5 &&
  87.             fZ >= hZ - 0.5 && fZ <= hZ + 0.5 )
  88.         {
  89.             GetVehicleDamageStatus(hitid, panels, doors, lights, tires);
  90.             UpdateVehicleDamageStatus(hitid, panels, doors, lights,(tires | 0b1000));
  91.         }
  92.         //Right front wheel
  93.         if( fX >= hX - 0.5 && fX <= hX + 0.5 &&
  94.             fY >= hY - 0.5 && fY <= hY + 0.5 &&
  95.             fZ >= hZ - 0.5 && fZ <= hZ + 0.5 )
  96.         {
  97.             GetVehicleDamageStatus(hitid, panels, doors, lights, tires);
  98.             UpdateVehicleDamageStatus(hitid, panels, doors, lights, (tires | 0b0010));
  99.         }
  100.         //Left rear wheel
  101.         if( fX >= rX - 3.0 && fX <= rX + 0.0 &&
  102.             fY >= rY - 0.5 && fY <= rY + 0.5 &&
  103.             fZ >= rZ - 0.5 && fZ <= rZ + 0.5 )
  104.         {
  105.             GetVehicleDamageStatus(hitid, panels, doors, lights, tires);
  106.             UpdateVehicleDamageStatus(hitid, panels, doors, lights, (tires | 0b0100));
  107.         }
  108.         //Right rear wheel
  109.         if( fX >= rX - 0.5 && fX <= rX + 0.5 &&
  110.             fY >= rY - 0.5 && fY <= rY + 0.5 &&
  111.             fZ >= rZ - 0.5 && fZ <= rZ + 0.5 )
  112.         {
  113.             GetVehicleDamageStatus(hitid, panels, doors, lights, tires);
  114.             UpdateVehicleDamageStatus(hitid, panels, doors, lights, (tires | 0b0001));
  115.         }
  116.     }
  117.     return 1;
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement