Guest User

VDMG.inc

a guest
May 6th, 2018
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.63 KB | None | 0 0
  1. //Made by lokii.
  2.  
  3.  
  4. #if !defined _inc_a_samp
  5. #error VDMG.inc: Include a_samp on top!
  6. #endif
  7.  
  8. /*
  9. native ToggleVehicleDamageable(vehicleid, status);
  10. */
  11.  
  12. static Float:weapon_vdmg[] =
  13. {
  14. 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
  15. 1000.0, 0.0, 1000.0, 0.0, 0.0, 0.0, 15.0, 15.0, 25.0, 120.0, 120.0, 120.0,
  16. 35.0, 35.0, 100.0, 100.0, 35.0, 200.0, 200.0, 1000.0, 1000.0,
  17. 1000.0, 100.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
  18. };
  19.  
  20. static vdmg_prev[MAX_PLAYERS] = {0, ...};
  21. static vdmg_bps[MAX_VEHICLES] = {0, ...};
  22. static vdmg_bp[MAX_VEHICLES] = {0, ...};
  23.  
  24. stock ToggleVehicleDamageable(vehicleid, status)
  25. {
  26. if(vehicleid == INVALID_VEHICLE_ID) return 0;
  27. CallRemoteFunction("VDMG_CALL", "ii", vehicleid, status);
  28. return 1;
  29. }
  30.  
  31. forward VDMG_CALL(vehicleid, status);
  32.  
  33. public VDMG_CALL(vehicleid, status)
  34. {
  35. return vdmg_bp[vehicleid] = status;
  36. }
  37.  
  38. public OnPlayerStateChange(playerid, newstate, oldstate)
  39. {
  40. switch(newstate)
  41. {
  42. case PLAYER_STATE_DRIVER:
  43. {
  44. vdmg_prev[playerid] = GetPlayerVehicleID(playerid);
  45. vdmg_bps[GetPlayerVehicleID(playerid)] ++;
  46. }
  47. }
  48. if(oldstate == PLAYER_STATE_DRIVER && newstate != PLAYER_STATE_DRIVER)
  49. {
  50. vdmg_bps[vdmg_prev[playerid]] --;
  51. vdmg_prev[playerid] = INVALID_VEHICLE_ID;
  52. }
  53.  
  54. #if defined afk_OnPlayerConnect
  55. vdmg_OnPlayerStateChange(playerid, newstate, oldstate);
  56. #endif
  57. return 1;
  58. }
  59. #if defined _ALS_OnPlayerStateChange
  60. #undef OnPlayerStateChange
  61. #else
  62. #define _ALS_OnPlayerStateChange
  63. #endif
  64. #define OnPlayerStateChange vdmg_OnPlayerStateChange
  65. #if defined vdmg_OnPlayerStateChange
  66. forward vdmg_OnPlayerStateChange(playerid, newstate, oldstate);
  67. #endif
  68.  
  69. public OnPlayerConnect(playerid)
  70. {
  71. vdmg_prev[playerid] = INVALID_VEHICLE_ID;
  72.  
  73. #if defined afk_OnPlayerConnect
  74. vdmg_OnPlayerConnect(playerid);
  75. #endif
  76. return 1;
  77. }
  78. #if defined _ALS_OnPlayerConnect
  79. #undef OnPlayerConnect
  80. #else
  81. #define _ALS_OnPlayerConnect
  82. #endif
  83. #define OnPlayerConnect vdmg_OnPlayerConnect
  84. #if defined vdmg_OnPlayerConnect
  85. forward vdmg_OnPlayerConnect(playerid);
  86. #endif
  87.  
  88. public OnPlayerDisconnect(playerid, reason)
  89. {
  90. vdmg_bps[vdmg_prev[playerid]] --;
  91. vdmg_prev[playerid] = INVALID_VEHICLE_ID;
  92.  
  93. #if defined afk_OnPlayerConnect
  94. vdmg_OnPlayerDisconnect(playerid, reason);
  95. #endif
  96. return 1;
  97. }
  98. #if defined _ALS_OnPlayerDisconnect
  99. #undef OnPlayerDisconnect
  100. #else
  101. #define _ALS_OnPlayerDisconnect
  102. #endif
  103. #define OnPlayerDisconnect vdmg_OnPlayerDisconnect
  104. #if defined vdmg_OnPlayerDisconnect
  105. forward vdmg_OnPlayerDisconnect(playerid, reason);
  106. #endif
  107.  
  108. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  109. {
  110. new Float:vhp;
  111. switch(hittype)
  112. {
  113. case 2:
  114. {
  115. if(hitid == INVALID_VEHICLE_ID || vdmg_bps[hitid] > 0 || vdmg_bp[hitid] != 0) return 1;
  116. GetVehicleHealth(hitid, vhp);
  117. SetVehicleHealth(hitid, vhp - weapon_vdmg[weaponid]);
  118. }
  119. }
  120.  
  121. #if defined afk_OnPlayerConnect
  122. vdmg_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
  123. #endif
  124. return 1;
  125. }
  126. #if defined _ALS_OnPlayerWeaponShot
  127. #undef OnPlayerWeaponShot
  128. #else
  129. #define _ALS_OnPlayerWeaponShot
  130. #endif
  131. #define OnPlayerWeaponShot vdmg_OnPlayerWeaponShot
  132. #if defined vdmg_OnPlayerWeaponShot
  133. forward vdmg_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
  134. #endif
  135.  
  136.  
  137.  
  138. //EOF.
Add Comment
Please, Sign In to add comment