is_user_connected
не понравился? Если не проверять жертву мне невалидные игроки прилеталиRegisterHookChain( RG_CSGameRules_PlayerKilled, "hook_CSGameRulesPlayerKilled", .post = true );
public hook_CSGameRulesPlayerKilled( const iVictim, const iKiller )
{
if( !is_user_connected( iKiller ) && iVictim == iKiller )
{
return HC_CONTINUE;
}
#if defined SOUNDS
if( get_member( iVictim, m_bKilledByGrenade ) )
{
rg_send_audio( 0, SOUND_HE );
}
else
{
new iActiveItem = get_member( iKiller, m_pActiveItem );
if( iActiveItem && WeaponIdType: rg_get_iteminfo( iActiveItem, ItemInfo_iId ) == WEAPON_KNIFE )
{
rg_send_audio( 0, SOUND_KNIFE );
}
}
#endif
return HC_CONTINUE;
}
а почему именно m_iId ?получить m_iId (не айтеминфо).
#include <amxmodx>
#include <reapi>
public plugin_init() {
RegisterHookChain(RG_CSGameRules_PlayerKilled, "CSGameRules_PlayerKilled_Post", true);
}
public CSGameRules_PlayerKilled_Post(const victim, const killer, const inflictor) {
if(victim == killer) {
return HC_CONTINUE;
}
if(get_member(victim, m_bKilledByGrenade)) {
log_amx("killed by grenade")
} else {
if(!is_nullent(inflictor)) {
new activeItem = get_member(inflictor, m_pActiveItem);
if(get_member(activeItem, m_iId) == WEAPON_KNIFE) {
log_amx("killed by knife")
}
}
}
return HC_CONTINUE;
}
enum
{
WORLD = 0,
BULLET,
KNIFE,
GRENADE
}
#define IsValidPev(%0) (pev_valid(%0) == 2)
stock get_death_reason(const id, const pevAttacker, &iType)
{
if(!is_user_connected(id) || !IsValidPev(id)) return PLUGIN_CONTINUE;
if(!is_user_connected(pevAttacker) || !IsValidPev(pevAttacker))
return PLUGIN_CONTINUE;
new iInflictor = get_entvar(id, var_dmg_inflictor);
if(iInflictor == pevAttacker)
{
new iEnt = get_member(pevAttacker, m_pActiveItem);
if(!IsValidPev(iEnt)) return PLUGIN_CONTINUE;
if(get_member(iEnt, m_iId) == CSW_KNIFE) iType = KNIFE;
else iType = BULLET;
}
else
{
if(get_member(id, m_bKilledByGrenade)) iType = GRENADE;
else iType = WORLD;
}
return PLUGIN_HANDLED;
}