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
}
I created this function, you can enter 200 as the damage and it will damage the player starting from their armor (if they have any) to their health. This supports even health and armour above 100, it will not matter and you can use this for weapon damage boosting. I could not any function similar to this on the forum, thank god I had known of how to use the mathematical function absolute value.