Advertisement
Guest User

playertakedamage

a guest
Jun 4th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart) {
  2. if(togalert[playerid] != 0) {
  3. PlayerTextDrawBoxColor(playerid, HPAlert, GetHudColor2(togalert[playerid]));
  4. PlayerTextDrawShow(playerid, HPAlert);
  5. SetTimerEx("HideHPAlert", 1000, false, "i", playerid);
  6. }
  7. new Float:HP, Float:AP, Float:remainHP;
  8. if(issuerid != INVALID_PLAYER_ID) {
  9. if(amount < 0) {
  10. new string[128],sendername[25];
  11. GetPlayerName(issuerid,sendername,sizeof(sendername));
  12. format(string, sizeof(string), "AdmWarning: %s (%d) este suspectat de global kill. (damage: %.2f)",sendername,issuerid,amount);
  13. if(GetPVarInt(playerid, "Cover") == 0) SendAdminMessage(COLOR_WARNING, string,1);
  14. KickEx(issuerid);
  15. return 1;
  16. }
  17. if(weaponid == 54 && GetPlayerState(issuerid) != PLAYER_STATE_DRIVER) {
  18. if(playerDeath[issuerid] == 0) {
  19.  
  20. GetPlayerHealthEx(issuerid,HP);
  21. GetPlayerArmourEx(issuerid,AP);
  22. if( AP >= amount ) {
  23. SetPlayerArmourEx( issuerid, AP - amount );
  24. SetPlayerHealthEx( issuerid, HP );
  25. }
  26. else if( AP <= 0 ) {
  27. remainHP = HP - amount;
  28. SetPlayerHealthEx( issuerid, remainHP );
  29. if( remainHP <= 0 && playerDeath[issuerid] == 0 ) {
  30. OnPlayerDeath( playerid, issuerid, weaponid );
  31. playerDeath[playerid] = 1;
  32. }
  33. }
  34. else {
  35. remainHP = HP + ( AP - amount );
  36. SetPlayerArmourEx( issuerid, 0.0 );
  37. SetPlayerHealthEx( issuerid, remainHP );
  38. if( remainHP <= 0 && playerDeath[issuerid] == 0 ) {
  39. OnPlayerDeath( playerid, INVALID_PLAYER_ID, weaponid );
  40. playerDeath[issuerid] = 1;
  41. }
  42. }
  43. }
  44. }
  45. if(weaponid == 49 || weaponid == 50 || weaponid == 51 || weaponid == 52 || weaponid == 53 || weaponid == 54 || GetPlayerState(issuerid) == PLAYER_STATE_DRIVER) {
  46. if(playerDeath[playerid] == 0) {
  47. GetPlayerHealthEx(playerid,HP);
  48. GetPlayerArmourEx(playerid,AP);
  49. if(AP >= amount ) {
  50. SetPlayerArmourEx(playerid, AP - amount);
  51. SetPlayerHealthEx(playerid, HP);
  52. }
  53. else if(AP <= 0) {
  54. remainHP = HP - amount;
  55. SetPlayerHealthEx(playerid, remainHP);
  56. if(remainHP <= 0 && playerDeath[playerid] == 0) {
  57. OnPlayerDeath(playerid, issuerid, weaponid);
  58. playerDeath[playerid] = 1;
  59. }
  60. }
  61. else {
  62. remainHP = HP + (AP - amount);
  63. SetPlayerArmourEx(playerid, 0.0);
  64. SetPlayerHealthEx(playerid, remainHP);
  65. if( remainHP <= 0 && playerDeath[playerid] == 0) {
  66. OnPlayerDeath(playerid, issuerid, weaponid );
  67. playerDeath[playerid] = 1;
  68. }
  69. }
  70. }
  71. }
  72. }
  73. else {
  74. if(playerDeath[playerid] == 0) {
  75. GetPlayerHealthEx(playerid,HP);
  76. GetPlayerArmourEx(playerid,AP);
  77. if(AP >= amount ) {
  78. SetPlayerArmourEx(playerid, AP - amount);
  79. SetPlayerHealthEx(playerid, HP);
  80. }
  81. else if(AP <= 0) {
  82. remainHP = HP - amount;
  83. SetPlayerHealthEx(playerid, remainHP);
  84. if(remainHP <= 0 && playerDeath[playerid] == 0) {
  85. OnPlayerDeath(playerid, INVALID_PLAYER_ID, weaponid);
  86. playerDeath[playerid] = 1;
  87. }
  88. }
  89. else {
  90. remainHP = HP + (AP - amount);
  91. SetPlayerArmourEx(playerid, 0.0);
  92. SetPlayerHealthEx(playerid, remainHP);
  93. if( remainHP <= 0 && playerDeath[playerid] == 0) {
  94. OnPlayerDeath(playerid, INVALID_PLAYER_ID, weaponid );
  95. playerDeath[playerid] = 1;
  96. }
  97. }
  98. }
  99. }
  100. return 1;
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement