Advertisement
Guest User

Untitled

a guest
Nov 12th, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.15 KB | None | 0 0
  1. public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
  2. {
  3.     new
  4.     Float:hp,
  5.     Float:ap;
  6.     GetPlayerHealth(damagedid, hp);
  7.     GetPlayerArmour(damagedid, ap);
  8.     new
  9.     Float: ap_hp = floatabs(ap - amount);
  10.     if(hp - ap_hp < 0)
  11.     SetPlayerHealth(damagedid, hp = 0.0);
  12.     else
  13.     SetPlayerHealth(damagedid, hp = hp - ap_hp);
  14.  
  15.     if(ap - amount < 0)
  16.     SetPlayerArmour(damagedid, ap = 0.0);
  17.     else
  18.     SetPlayerArmour(damagedid, ap = ap - amount);
  19.     return 1;
  20. }
  21. public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
  22. {
  23.     new
  24.     Float:hp,
  25.     Float:ap;
  26.     GetPlayerHealth(playerid, hp);
  27.     GetPlayerArmour(playerid, ap);
  28.     new
  29.     Float: ap_hp = floatabs(ap - amount);
  30.     if(hp - ap_hp < 0)
  31.     SetPlayerHealth(playerid, hp = 0.0);
  32.     else
  33.     SetPlayerHealth(playerid, hp = hp - ap_hp);
  34.  
  35.     if(ap - amount < 0)
  36.     SetPlayerArmour(playerid, ap = 0.0);
  37.     else
  38.     SetPlayerArmour(playerid, ap = ap - amount);
  39.  
  40.     if(issuerid != INVALID_PLAYER_ID) {
  41.         if(weaponid >= 0 && weaponid <= 46) {
  42.             new
  43.                 str[128],
  44.                 weaponname[32];
  45.             GetWeaponName(weaponid,weaponname,sizeof(weaponname));
  46.  
  47.             format(str, sizeof(str), "+%.0f %s", amount, weaponname);
  48.             PlayerTextDrawSetString(issuerid, da_td[issuerid][0], str);
  49.  
  50.             format(str, sizeof(str), "%s[%d]", player[playerid][name], playerid);
  51.             PlayerTextDrawSetString(issuerid, da_td[issuerid][1], str);
  52.  
  53.             format(str, sizeof(str), "Health: %.0f", hp);
  54.             PlayerTextDrawSetString(issuerid, da_td[issuerid][2], str);
  55.  
  56.             format(str, sizeof(str), "Armour: %.0f", ap);
  57.             PlayerTextDrawSetString(issuerid, da_td[issuerid][3], str);
  58.  
  59.             if(timershot[issuerid] != -1) {
  60.                 KillTimer(timershot[issuerid]);
  61.                 for(new i = 0; i < 4; i++)
  62.                     PlayerTextDrawHide(playerid, da_td[playerid][i]);
  63.             }
  64.             for(new i = 0; i < 4; i++)
  65.                 PlayerTextDrawShow(issuerid, da_td[issuerid][i]);
  66.  
  67.             timershot[issuerid] = SetTimerEx("TakeDamageTextDrawHide", 1000*5, false, "i", issuerid);
  68.  
  69.         }
  70.     }
  71.     return 1;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement