Advertisement
EnzoMetlc

[Include] PlayerDamageUnoccupiedVehicle (v0.2).

Jan 16th, 2014
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. #include <a_samp>
  2. #include <YSI\y_iterate>
  3. #include <YSI\y_hooks>
  4.  
  5.  
  6. hook: OnVehicleSpawn(vehicleid)
  7. {
  8. SetVehicleHealth(vehicleid, 1000.0);
  9. return 1;
  10. }
  11.  
  12. new Timer[MAX_VEHICLES];
  13. new bool:TimerUsed[MAX_VEHICLES];
  14.  
  15. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  16. {
  17. if(hittype == BULLET_HIT_TYPE_VEHICLE)
  18. {
  19. if(!VehicleUnoccupied(hitid))
  20. {
  21. new Float:Health;
  22. GetVehicleHealth(hitid, Health);
  23. if(Health > 249.0)
  24. {
  25. switch(weaponid)
  26. {
  27. case 1 .. 4: SetVehicleHealth(hitid, (Health = Health-25.0));
  28. case 5 .. 8: SetVehicleHealth(hitid, (Health = Health-50.0));
  29. case 9: SetVehicleHealth(hitid, (Health = Health-50.0));
  30. case 10 .. 15: SetVehicleHealth(hitid, (Health = Health-75.0));
  31. case 22, 23: SetVehicleHealth(hitid, (Health = Health-75.0));
  32. case 24: SetVehicleHealth(hitid, (Health = Health-100.0));
  33. case 25: SetVehicleHealth(hitid, (Health = Health-120.0));
  34. case 26, 27: SetVehicleHealth(hitid, (Health = Health-125.0));
  35. case 28, 32: SetVehicleHealth(hitid, (Health = Health-35.0));
  36. case 29: SetVehicleHealth(hitid, (Health = Health-100.0));
  37. case 30, 31: SetVehicleHealth(hitid, (Health = Health-75.0));
  38. case 33: SetVehicleHealth(hitid, (Health = Health-150.0));
  39. case 34: SetVehicleHealth(hitid, (Health = Health-200.0));
  40. case 38: SetVehicleHealth(hitid, (Health = Health-50.0));
  41. }
  42. CallLocalFunction("PlayerDamageUnoccupiedVehicle", "ddi", playerid, hitid, weaponid);
  43. }
  44. else if(Health < 250.0)
  45. {
  46. if(TimerUsed[hitid] == false)
  47. {
  48. Timer[hitid] = SetTimerEx("OnVehicleExplode", 5000, false, "d", hitid);
  49. TimerUsed[hitid] = true;
  50. }
  51. }
  52. }
  53. }
  54. return 1;
  55. }
  56.  
  57.  
  58. // native VehicleUnoccupied(vehicleid);
  59. stock VehicleUnoccupied(vehicleid)
  60. {
  61. foreach(new i: Player)
  62. {
  63. if(GetPlayerVehicleID(i) == vehicleid && GetPlayerVehicleSeat(i) == 0) return 1;
  64. }
  65. return 0;
  66. }
  67.  
  68.  
  69. forward PlayerDamageUnoccupiedVehicle(playerid, vehicleid, weaponid);
  70. forward OnVehicleExplode(vehicleid);
  71.  
  72. // END.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement