Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. #include <foreach>
  2.  
  3. static ac_hp_timer = 0;
  4.  
  5. public OnPlayerConnect(playerid)
  6. {
  7. SetPVarFloat(playerid, "ac_hp", 100.0);
  8. SetPVarFloat(playerid, "ac_armour", 0.0);
  9.  
  10. #if defined achp_OnPlayerConnect
  11. achp_OnPlayerConnect(playerid);
  12. #endif
  13. return 1;
  14. }
  15. #if defined _ALS_OnPlayerConnect
  16. #undef OnPlayerConnect
  17. #else
  18. #define _ALS_OnPlayerConnect
  19. #endif
  20. #define OnPlayerConnect achp_OnPlayerConnect
  21. #if defined achp_OnPlayerConnect
  22. forward achp_OnPlayerConnect(playerid);
  23. #endif
  24.  
  25. public OnPlayerSpawn(playerid)
  26. {
  27. SetPVarFloat(playerid, "ac_hp", 100.0);
  28. SetPVarFloat(playerid, "ac_armour", 0.0);
  29.  
  30. #if defined achp_OnPlayerSpawn
  31. achp_OnPlayerSpawn(playerid);
  32. #endif
  33. return 1;
  34. }
  35. #if defined _ALS_OnPlayerSpawn
  36. #undef OnPlayerSpawn
  37. #else
  38. #define _ALS_OnPlayerSpawn
  39. #endif
  40. #define OnPlayerSpawn achp_OnPlayerSpawn
  41. #if defined achp_OnPlayerSpawn
  42. forward achp_OnPlayerSpawn(playerid);
  43. #endif
  44.  
  45. public OnPlayerDeath(playerid, killerid, reason)
  46. {
  47. SetPVarFloat(playerid, "ac_hp", 100.0);
  48. SetPVarFloat(playerid, "ac_armour", 0.0);
  49.  
  50. #if defined achp_OnPlayerDeath
  51. achp_OnPlayerDeath(playerid, killerid, reason);
  52. #endif
  53. return 1;
  54. }
  55. #if defined _ALS_OnPlayerDeath
  56. #undef OnPlayerDeath
  57. #else
  58. #define _ALS_OnPlayerDeath
  59. #endif
  60. #define OnPlayerDeath achp_OnPlayerDeath
  61. #if defined achp_OnPlayerDeath
  62. forward achp_OnPlayerDeath(playerid, killerid, reason);
  63. #endif
  64.  
  65. #if defined FILTERSCRIPT
  66.  
  67. public OnFilterScriptInit()
  68. {
  69. new Float:hp, Float:armour;
  70. ac_hp_timer = SetTimer("AC_HP", 100, true);
  71. foreach(new i : Player)
  72. {
  73. GetPlayerHealth(i, hp);
  74. GetPlayerArmour(i, armour);
  75. SetPVarFloat(i, "ac_hp", hp);
  76. SetPVarFloat(i, "ac_armour", armour);
  77. }
  78.  
  79. #if defined achp_OnFilterScriptInit
  80. achp_OnFilterScriptInit();
  81. #endif
  82. return 1;
  83. }
  84. #if defined _ALS_OnFilterScriptInit
  85. #undef OnFilterScriptInit
  86. #else
  87. #define _ALS_OnFilterScriptInit
  88. #endif
  89. #define OnFilterScriptInit achp_OnFilterScriptInit
  90. #if defined achp_OnFilterScriptInit
  91. forward achp_OnFilterScriptInit();
  92. #endif
  93.  
  94. public OnFilterScriptExit()
  95. {
  96. KillTimer(ac_hp_timer);
  97.  
  98. #if defined achp_OnFilterScriptExit
  99. achp_OnFilterScriptExit();
  100. #endif
  101. return 1;
  102. }
  103. #if defined _ALS_OnFilterScriptExit
  104. #undef OnFilterScriptExit
  105. #else
  106. #define _ALS_OnFilterScriptExit
  107. #endif
  108. #define OnFilterScriptExit achp_OnFilterScriptExit
  109. #if defined achp_OnFilterScriptExit
  110. forward achp_OnFilterScriptExit();
  111. #endif
  112.  
  113. #else
  114.  
  115. public OnGameModeInit()
  116. {
  117. new Float:hp, Float:armour;
  118. ac_hp_timer = SetTimer("AC_HP", 100, true);
  119. foreach(new i : Player)
  120. {
  121. GetPlayerHealth(i, hp);
  122. GetPlayerArmour(i, armour);
  123. SetPVarFloat(i, "ac_hp", hp);
  124. SetPVarFloat(i, "ac_armour", armour);
  125. }
  126.  
  127. #if defined achp_OnGameModeInit
  128. achp_OnGameModeInit();
  129. #endif
  130. return 1;
  131. }
  132. #if defined _ALS_OnGameModeInit
  133. #undef OnGameModeInit
  134. #else
  135. #define _ALS_OnGameModeInit
  136. #endif
  137. #define OnGameModeInit achp_OnGameModeInit
  138. #if defined achp_OnGameModeInit
  139. forward achp_OnGameModeInit();
  140. #endif
  141.  
  142. public OnGameModeExit()
  143. {
  144. KillTimer(ac_hp_timer);
  145.  
  146. #if defined achp_OnGameModeExit
  147. achp_OnGameModeExit();
  148. #endif
  149. return 1;
  150. }
  151. #if defined _ALS_OnGameModeExit
  152. #undef OnGameModeExit
  153. #else
  154. #define _ALS_OnGameModeExit
  155. #endif
  156. #define OnGameModeExit achp_OnGameModeExit
  157. #if defined achp_OnGameModeExit
  158. forward achp_OnGameModeExit();
  159. #endif
  160.  
  161. #endif
  162.  
  163. stock SetPlayerHealthEx(playerid, Float:health)
  164. {
  165. SetPVarFloat(playerid, "ac_hp", health);
  166. SetPlayerHealth(playerid, health);
  167. return 1;
  168. }
  169.  
  170. stock SetPlayerArmourEx(playerid, Float:armour)
  171. {
  172. SetPVarFloat(playerid, "ac_armour", armour);
  173. SetPlayerArmour(playerid, armour);
  174. return 1;
  175. }
  176.  
  177. stock GetPlayerHealthEx(playerid, &Float:health)
  178. {
  179. health = GetPVarFloat(playerid, "ac_hp");
  180. return 1;
  181. }
  182.  
  183. stock GetPlayerArmourEx(playerid, &Float:armour)
  184. {
  185. armour = GetPVarFloat(playerid, "ac_armour");
  186. return 1;
  187. }
  188.  
  189. forward AC_HP();
  190.  
  191. public AC_HP()
  192. {
  193. new Float:hp, Float:armour;
  194. foreach(new i : Player)
  195. {
  196. GetPlayerHealth(i, hp);
  197. GetPlayerArmour(i, armour);
  198. if(hp != GetPVarFloat(i, "ac_hp"))
  199. {
  200. SetPlayerHealth(i, GetPVarFloat(i, "ac_hp"));
  201. }
  202. if(armour != GetPVarFloat(i, "ac_armour"))
  203. {
  204. SetPlayerArmour(i, GetPVarFloat(i, "ac_armour"));
  205. }
  206. }
  207. return 1;
  208. }
  209.  
  210. #if defined AC_HPAR_OPTD
  211.  
  212. public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
  213. {
  214. new Float:hp, Float:armour;
  215. GetPlayerArmour(playerid, armour);
  216. GetPlayerHealth(playerid, hp);
  217. if(weaponid > 51)
  218. {
  219. SetPVarFloat(playerid, "ac_hp", GetPVarFloat(playerid, "ac_hp")-amount);
  220. }
  221. else
  222. {
  223. if(armour > 0.0)
  224. {
  225. if(armour >= amount)
  226. {
  227. SetPVarFloat(playerid, "ac_armour", GetPVarFloat(playerid, "ac_armour")-floatabs(amount));
  228. }
  229. else
  230. {
  231. amount = amount-GetPVarFloat(playerid, "ac_armour");
  232. SetPVarFloat(playerid, "ac_hp", GetPVarFloat(playerid, "ac_hp")-floatabs(amount));
  233. }
  234. }
  235. else
  236. {
  237. SetPVarFloat(playerid, "ac_hp", GetPVarFloat(playerid, "ac_hp")-floatabs(amount));
  238. }
  239. }
  240.  
  241. #if defined achp_OnPlayerTakeDamage
  242. achp_OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart);
  243. #endif
  244. return 0;
  245. }
  246. #if defined _ALS_OnPlayerTakeDamage
  247. #undef OnPlayerTakeDamage
  248. #else
  249. #define _ALS_OnPlayerTakeDamage
  250. #endif
  251. #define OnPlayerTakeDamage achp_OnPlayerTakeDamage
  252. #if defined achp_OnPlayerTakeDamage
  253. forward achp_OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart);
  254. #endif
  255.  
  256. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement