Advertisement
SalvatorCodes

Vehicle Damage Enabler [Alpha v2.1]

Mar 6th, 2016
846
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.14 KB | None | 0 0
  1. /*************************************
  2. **************************************
  3. ******* Vehicle Damage Enabler *******
  4. *******[Alpha v2.1] by Salvator ******
  5. **************************************
  6. **************************************/
  7.  
  8. //Credits and thanks
  9. //==================
  10. //AmigaBlizzard for showing me IsAirModel function
  11. //Gammix's vehicleplus.inc helped me with defining wheels position.
  12. //Abagail for improved IsDriverAvalable call and player loop.
  13.  
  14. #include <a_samp>
  15.  
  16. public OnFilterScriptInit()
  17. {
  18.     print("Vehicle Damage Enabler [Alpha v2.1] by Salvator");
  19.     return 1;
  20. }
  21.  
  22. new AirDamage[] =
  23. {
  24.     0,  // 0
  25.     0,  // 1
  26.     0,  // 2
  27.     0,  // 3
  28.     0,  // 4
  29.     0,  // 5
  30.     0,  // 6
  31.     0,  // 7
  32.     0,  // 8
  33.     0,  // 9
  34.     0,  // 10
  35.     0,  // 11
  36.     0,  // 12
  37.     0,  // 13
  38.     0,  // 14
  39.     0,  // 15
  40.     0,  // 16
  41.     0,  // 17
  42.     0,  // 18
  43.     0,  // 19
  44.     0,  // 20
  45.     0,  // 21
  46.     10, // 22
  47.     16, // 23
  48.     56, // 24
  49.     60, // 25
  50.     60, // 26
  51.     48, // 27
  52.     8,  // 28
  53.     10, // 29
  54.     12, // 30
  55.     12, // 31
  56.     8,  // 32
  57.     30, // 33
  58.     50, // 34
  59.     0,  // 35
  60.     0,  // 36
  61.     0,  // 37
  62.     56, // 38
  63.     0,  // 39
  64. };
  65.  
  66. new VehDamage[] =
  67. {
  68.     0,   // 0
  69.     0,   // 1
  70.     0,   // 2
  71.     0,   // 3
  72.     0,   // 4
  73.     0,   // 5
  74.     0,   // 6
  75.     0,   // 7
  76.     0,   // 8
  77.     0,   // 9
  78.     0,   // 10
  79.     0,   // 11
  80.     0,   // 12
  81.     0,   // 13
  82.     0,   // 14
  83.     0,   // 15
  84.     0,   // 16
  85.     0,   // 17
  86.     0,   // 18
  87.     0,   // 19
  88.     0,   // 20
  89.     0,   // 21
  90.     25,  // 22
  91.     40,  // 23
  92.     140, // 24
  93.     150, // 25
  94.     150, // 26
  95.     120, // 27
  96.     20,  // 28
  97.     25,  // 29
  98.     30,  // 30
  99.     30,  // 31
  100.     20,  // 32
  101.     75,  // 33
  102.     125, // 34
  103.     0,   // 35
  104.     0,   // 36
  105.     0,   // 37
  106.     140, // 38
  107.     0,   // 39
  108. };
  109.  
  110. new
  111.      vehicleDriver[MAX_VEHICLES] = INVALID_PLAYER_ID,
  112.      playerCurVeh[MAX_PLAYERS] = INVALID_VEHICLE_ID;
  113.  
  114. public OnPlayerStateChange(playerid, newstate, oldstate)
  115. {
  116.     if(newstate == PLAYER_STATE_DRIVER)
  117.     {
  118.         if(GetPlayerVehicleID(playerid) != INVALID_VEHICLE_ID)
  119.         {
  120.             vehicleDriver[GetPlayerVehicleID(playerid)] = playerid;
  121.             playerCurVeh[playerid] = GetPlayerVehicleID(playerid);
  122.         }
  123.     }
  124.     else if(oldstate == PLAYER_STATE_DRIVER)
  125.         {
  126.             if(playerCurVeh[playerid] != INVALID_VEHICLE_ID)
  127.             {
  128.                 if(vehicleDriver[playerCurVeh[playerid]] == playerid) vehicleDriver[playerCurVeh[playerid]] = INVALID_PLAYER_ID;
  129.                 playerCurVeh[playerid] = INVALID_VEHICLE_ID;
  130.             }
  131.         }
  132.     return 1;
  133. }
  134.  
  135. public OnPlayerDisconnect(playerid, reason) {
  136.       if(playerCurVeh[playerid] != INVALID_PLAYER_ID)
  137.               if(vehicleDriver[playerCurVeh[playerid]] == playerid) vehicleDriver[playerCurVeh[playerid]] = INVALID_PLAYER_ID;
  138.  
  139.       return 1;
  140. }
  141.  
  142. IsDriverAvailable(vehicleid)
  143. {
  144.     return (vehicleDriver[vehicleid] != INVALID_PLAYER_ID) ? (false) : (true);
  145. }
  146.  
  147. IsAirModel(modelid)
  148. {
  149.     switch(modelid)
  150.     {
  151.         case 460, 476, 511, 512, 513, 519, 520, 553, 577, 592, 593, 417, 425, 447, 469, 487, 488, 497, 548, 563:
  152.         return 1;
  153.     }
  154.     return 0;
  155. }
  156.  
  157. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  158. {
  159.     new wID = weaponid;
  160.     new Float:vHealth; GetVehicleHealth(hitid, vHealth);
  161.    
  162.     if(hittype == 2 && !IsDriverAvailable(hitid) && vHealth > 249)
  163.     {
  164.         if(IsAirModel(GetVehicleModel(hitid)) == 1)
  165.         {
  166.             switch(wID)
  167.             {
  168.                 case 22, 29: SetVehicleHealth(hitid, vHealth - AirDamage[wID]);
  169.                 case 23: SetVehicleHealth(hitid, vHealth - AirDamage[wID]);
  170.                 case 24, 38: SetVehicleHealth(hitid, vHealth - AirDamage[wID]);
  171.                 case 25, 26: SetVehicleHealth(hitid, vHealth - AirDamage[wID]);
  172.                 case 27: SetVehicleHealth(hitid, vHealth - AirDamage[wID]);
  173.                 case 28, 32: SetVehicleHealth(hitid, vHealth - AirDamage[wID]);
  174.                 case 30, 31: SetVehicleHealth(hitid, vHealth - AirDamage[wID]);
  175.                 case 33: SetVehicleHealth(hitid, vHealth - AirDamage[wID]);
  176.                 case 34: SetVehicleHealth(hitid, vHealth - AirDamage[wID]);
  177.             }
  178.         }
  179.         else
  180.         {
  181.             switch(wID)
  182.             {
  183.                 case 22, 29: SetVehicleHealth(hitid, vHealth - VehDamage[wID]);
  184.                 case 23: SetVehicleHealth(hitid, vHealth - VehDamage[wID]);
  185.                 case 24, 38: SetVehicleHealth(hitid, vHealth - VehDamage[wID]);
  186.                 case 25, 26: SetVehicleHealth(hitid, vHealth - VehDamage[wID]);
  187.                 case 27: SetVehicleHealth(hitid, vHealth - VehDamage[wID]);
  188.                 case 28, 32: SetVehicleHealth(hitid, vHealth - VehDamage[wID]);
  189.                 case 30, 31: SetVehicleHealth(hitid, vHealth - VehDamage[wID]);
  190.                 case 33: SetVehicleHealth(hitid, vHealth - VehDamage[wID]);
  191.                 case 34: SetVehicleHealth(hitid, vHealth - VehDamage[wID]);
  192.             }
  193.         }
  194.         new vModel = GetVehicleModel(hitid);
  195.         new Float:hX, Float:hY, Float:hZ, Float:rX, Float:rY, Float:rZ;
  196.         GetVehicleModelInfo(vModel, VEHICLE_MODEL_INFO_WHEELSFRONT, hX, hY, hZ);
  197.         GetVehicleModelInfo(vModel, VEHICLE_MODEL_INFO_WHEELSREAR, rX, rY, rZ);
  198.         new panels, doors, lights, tires;
  199.        
  200.         //Left front wheel
  201.         if( fX >= hX - 3.0 && fX <= hX + 0.0 &&
  202.             fY >= hY - 0.5 && fY <= hY + 0.5 &&
  203.             fZ >= hZ - 0.5 && fZ <= hZ + 0.5 )
  204.         {
  205.             GetVehicleDamageStatus(hitid, panels, doors, lights, tires);
  206.             UpdateVehicleDamageStatus(hitid, panels, doors, lights,(tires | 0b1000));
  207.         }
  208.         //Right front wheel
  209.         if( fX >= hX - 0.5 && fX <= hX + 0.5 &&
  210.             fY >= hY - 0.5 && fY <= hY + 0.5 &&
  211.             fZ >= hZ - 0.5 && fZ <= hZ + 0.5 )
  212.         {
  213.             GetVehicleDamageStatus(hitid, panels, doors, lights, tires);
  214.             UpdateVehicleDamageStatus(hitid, panels, doors, lights, (tires | 0b0010));
  215.         }
  216.         //Left rear wheel
  217.         if( fX >= rX - 3.0 && fX <= rX + 0.0 &&
  218.             fY >= rY - 0.5 && fY <= rY + 0.5 &&
  219.             fZ >= rZ - 0.5 && fZ <= rZ + 0.5 )
  220.         {
  221.             GetVehicleDamageStatus(hitid, panels, doors, lights, tires);
  222.             UpdateVehicleDamageStatus(hitid, panels, doors, lights, (tires | 0b0100));
  223.         }
  224.         //Right rear wheel
  225.         if( fX >= rX - 0.5 && fX <= rX + 0.5 &&
  226.             fY >= rY - 0.5 && fY <= rY + 0.5 &&
  227.             fZ >= rZ - 0.5 && fZ <= rZ + 0.5 )
  228.         {
  229.             GetVehicleDamageStatus(hitid, panels, doors, lights, tires);
  230.             UpdateVehicleDamageStatus(hitid, panels, doors, lights, (tires | 0b0001));
  231.         }
  232.     }
  233.     return 1;
  234. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement