Advertisement
Johurt

[FNC] PlusMinusHealthArmour

Mar 8th, 2019
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.84 KB | None | 0 0
  1. stock PlusMinusHealthArmour(playerid, Float:amount, Float:playerHealth, Float:playerArmour, Float:healthLimit = 100.0, Float:armourLimit = 100.0)
  2. {
  3.     if(amount < 0)
  4.     {
  5.         amount *= -1;
  6.         playerArmour    -=  amount;
  7.         amount          =   0.0;
  8.         if(playerArmour < 0.0)
  9.         {
  10.             amount = floatsub(0.0, playerArmour);
  11.             playerArmour = 0.0;
  12.         }
  13.         playerHealth    -= amount;
  14.         if(playerHealth < 0) playerHealth = 0;
  15.     }
  16.     else
  17.     {
  18.         playerHealth    +=  amount;
  19.         amount          =   0.0;
  20.         if(playerHealth > healthLimit)
  21.         {
  22.             amount = floatsub(playerHealth, healthLimit);
  23.             playerHealth = healthLimit;
  24.         }
  25.         playerArmour    += amount;
  26.         if(playerArmour > armourLimit) playerArmour = armourLimit;
  27.     }
  28.     SetPlayerHealth(playerid, playerHealth);
  29.     SetPlayerArmour(playerid, playerArmour);
  30.     return 1;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement