Nice bugfix, though only one problem.
This damage can come also from a gun at a big distance so you need to check the damage type in order to be 100% sure that the damage is because of a fall.
The only problem that I see here is the situation where the damage comes from something else and can be multiplied. For example if someone shoots you with a glock pistol at a big distance and does
1 damage to you and hits your head the damage that you will receive will be
4. So you need to watch out for the hitgroup damage multiplication constants.
Check this out:
PHP Code:
#define OFFSET_LAST_HIT_GROUP 75
#define EXTRAOFFSET_PL_LINUX 5
new const Float:hitgroup_multi[] =
{
1.0, // HIT_GENERIC
4.0, // HIT_HEAD
1.0, // HIT_CHEST
1.25, // HIT_STOMACH
1.0, // HIT_LEFTARM
1.0, // HIT_RIGHTARM
0.75, // HIT_LEFTLEG
0.75 // HIT_RIGHTLEG
0.0 // HIT_SHIELD
}
#include <amxmodx>
#include <hamsandwich>
public plugin_init( )
{
register_plugin( "Dmg sound bug fix", "1.0", "Simo123" );
RegisterHam( Ham_TakeDamage, "player", "Forward_HamClientTakeDamage" );
}
public Forward_HamClientTakeDamage( iClient, iInflictor, iAttacker, Float:fDamage, iDamagebits )
{
new hitgroup = get_pdata_int(victim, OFFSET_LAST_HIT_GROUP, EXTRAOFFSET_PL_LINUX) // Get the hitgroup so that we know if the damage is multiplied or not.
fDamage *= hitgroup_multi[hitgroup]; // This is how you obtain the real damage
if ( fDamage < 1.0 )
{
return HAM_SUPERCEDE;
}
return HAM_IGNORED;
}
__________________