13.02.2013, 08:01
pawn Код:
stock DeductPlayerDamage(playerid, Float:damage, Float:multiplier=1.0)
{
//WeaponDamage[playerid] = damage * multiplier; You may want to add this if you have a SetPlayerArmourEx anticheat, it's highly recommended and add offsets for the damage.
new
Float:health,
Float:armour;
GetPlayerHealth(playerid, health);
GetPlayerArmour(playerid, armour);
if (armour > 0)
{
if (armour - (damage * multiplier) <= 0) {
SetPlayerArmourEx(playerid, 0);
if (health - floatabs(armour - (damage * multiplier)) <= 0)
{
SetPlayerHealth(playerid, 0);
return true;
}
else
{
SetPlayerHealth(playerid, health - floatabs(armour - (damage * multiplier)));
}
} else {
SetPlayerArmourEx(playerid, armour - (damage * multiplier));
}
}
else
{
if (health - (damage * multiplier) <= 0) {
SetPlayerHealth(playerid, 0);
return true;
} else {
SetPlayerHealth(playerid, health - (damage * multiplier));
}
}
return false;//the result doesnt make the target die
}