PHP Code:
#include <amxmodx>
#include <csx>
#include <fun>
public plugin_init()
{
register_plugin("Deplete armor before health", "1.0", "Jelle")
}
public client_damage(attacker, victim, damage)
{
//if damage is bigger than armor
new armor = get_user_armor(victim)
if ( damage > armor )
{
//first calculate how much life to deplete
new depleteHealth = damage - armor
//set armor to 0
set_user_armor(victim, 0)
//then deplete the life
set_user_health(victim, get_user_health(victim) - depleteHealth)
}
//if armor is bigger than damage
else if ( armor > damage )
{
//deplete armor with the damage taken
set_user_armor(victim, armor - damage)
//remember to give the health back
set_user_health(victim, damage)
}
//any other case
else
{
//do nothing
return
}
}
untested.
__________________