Code:
#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >
const MAX_PLAYERS = 32;
new Float:g_flTakeDamage_Health[ MAX_PLAYERS + 1 ];
public plugin_init( )
{
RegisterHam( Ham_TakeDamage, "player", "FwdPlayerDamage" );
RegisterHam( Ham_TakeDamage, "player", "FwdPlayerDamagePost", 1 );
}
public FwdPlayerDamage( iVictim, iInflictor, iAttacker, Float:flDamage, iDamageType )
{
// save player's health before the damage is done
pev( iVictim, pev_health, g_flTakeDamage_Health[ iVictim ] );
}
public FwdPlayerDamagePost( iVictim, iInflictor, iAttacker, Float:flDamage, iDamageType )
{
// gets real damage that was affected by armor
// flDamage in the forward params does not have the armor-affected value
// you can only get this in POST hook (not PRE)
new Float:flRealDamage;
pev( iVictim, pev_dmg_take, flRealDamage );
// the amount of health taken from the player
new Float:flHealthTaken = floatmin( flRealDamage, g_flTakeDamage_Health[ iVictim ] );
}
__________________