#include < amxmodx >
#include < reapi >
#pragma semicolon 1
const MAX_LENGTH__MESSAGE = 16;
enum _: EVENT_TYPE_ENUM
{
ET__KNIFE_KILL,
ET__GRENADE_KILL,
ET__BOMB_KILL,
ET__BOMB_PLANTED,
ET__BOMB_DEFUSED
}
new const SOUND_EVENT[ EVENT_TYPE_ENUM ][ ] =
{
"gmforce/sounds_events/knife_kill_1.wav",
"gmforce/sounds_events/grenade_kill_1.wav",
"gmforce/sounds_events/bomb_kill_1.wav",
"gmforce/sounds_events/bomb_planted_1.wav",
"gmforce/sounds_events/bomb_defused_1.wav"
};
public plugin_precache( )
{
for( new i; i < EVENT_TYPE_ENUM; i++ )
{
precache_sound( SOUND_EVENT[ i ] );
}
}
public plugin_init( )
{
register_plugin( "Sounds Events", "1.0.0", "Javekson" );
register_message( get_user_msgid( "SendAudio" ), "message_SendAudio" );
RegisterHookChain( RG_CBasePlayer_Killed, "hook_PlayerKilled_Post", .post = true );
}
public message_SendAudio( )
{
enum { ARG_MESSAGE = 2 }
new sMessage[ MAX_LENGTH__MESSAGE ];
get_msg_arg_string( ARG_MESSAGE, sMessage, charsmax( sMessage ) );
if( equal( sMessage[ 7 ], "BOMBPL" ) )
{
set_msg_arg_string( ARG_MESSAGE, SOUND_EVENT[ ET__BOMB_PLANTED ] );
}
else if( equal( sMessage[ 7 ], "BOMBDEF" ) )
{
set_msg_arg_string( ARG_MESSAGE, SOUND_EVENT[ ET__BOMB_DEFUSED ] );
}
}
public hook_PlayerKilled_Post( const iVictim, const iKiller )
{
if( iVictim == iKiller || !is_user_connected( iKiller ) )
{
return HC_CONTINUE;
}
new iInflictor = get_entvar( iVictim, var_dmg_inflictor );
if( iInflictor != iKiller )
{
if( get_member( iVictim, m_bKilledByGrenade ) )
{
rg_send_audio( 0, SOUND_EVENT[ ET__GRENADE_KILL ] );
}
else if( get_member( iVictim, m_bKilledByBomb ) )
{
rg_send_audio( 0, SOUND_EVENT[ ET__BOMB_KILL ] );
}
return HC_CONTINUE;
}
new iActiveItem = get_member( iKiller, m_pActiveItem );
if( !is_nullent( iActiveItem ) && get_member( iActiveItem, m_iId ) == WEAPON_KNIFE )
{
rg_send_audio( 0, SOUND_EVENT[ ET__KNIFE_KILL ] );
}
return HC_CONTINUE;
}