You should use attacker here, not inflictor. Inflictor is not always the same as attacker, in the case of grenade damage, and possibly C4, it is the entity index of the grenade. I also fixed and improved other things that were done incorrectly.
Code:
if (is_user_connected(attacker
) &&
is_user_alive(attacker
) &&
get_user_flags(attacker
) &
ACCESS)
{
new iWeaponUsed = get_user_weapon(inflictor)
if(iWeapon == CSW_KNIFE || iWeapon == CSW_AWP || iWeapon == CSW_SCOUT || iWeaponUsed == CSW_HEGRENADE
)
return PLUGIN_CONTINUE
SetHamParamFloat
(4, damage * dmgRate
)
}
Untested
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#define VERSION "0.2"
#define MAX_PLAYERS 32
#define ACCESS ADMIN_CFG
new const DMG_GRENADE = ( 1 << 24 );
new const IGNORE_WEAPONS = ( 1 << CSW_KNIFE ) | ( 1 << CSW_AWP ) | ( 1 << CSW_SCOUT );
new pCVar_DamageRate;
public plugin_init()
{
register_plugin( "VIP Sebzes Bonusz" , VERSION , "RaZ" );
pCVar_DamageRate = register_cvar( "vipbonus_dmgrate" , "1.3" );
RegisterHam( Ham_TakeDamage , "player" , "fw_TakeDamage" );
}
public fw_TakeDamage( iVictim , iInflictor , iAttacker , Float:fDamage , DamageBits )
{
if( !( 1 <= iAttacker <= MAX_PLAYERS ) ||
( DamageBits & DMG_GRENADE ) ||
!( get_user_flags( iAttacker ) & ACCESS ) ||
( ( 1 << get_user_weapon( iAttacker ) ) & IGNORE_WEAPONS ) )
return HAM_IGNORED;
SetHamParamFloat( 4 , fDamage * get_pcvar_float( pCVar_DamageRate ) )
return HAM_HANDLED;
}
__________________