I wrote this using my mobile phone.
I have not tested it, but it should work.
Code:
#include < amxmodx >
#include < amxmisc >
#include < fakemeta >
public plugin_init( ) {
register_plugin( "Use Entity like Button", "1.0", "Milutinke (ByM)" );
register_forward( FM_EmitSound, "fw_EmitSound" );
}
public fw_EmitSound( id, iChannel, szSound[ ], Float: fVol, Float: fAttn, iFlags, iPitch ) {
if( !is_user_alive( id ) )
return FMRES_IGNORED;
if( equal( szSound, "common/wpn_denyselect.wav" ) ) {
if( IsAimingAtEnt( id, "Entity Name Here" ) ) {
//Your code here.
}
return FMRES_SUPERCEDE;
}
return FMRES_IGNORED;
}
stock bool: IsAimingAtEnt( id, const szEntityClassName[ ] ) {
if( !strlen( szEntityClassName ) || !is_user_alive( id ) )
return false;
static iTarget, iBody, szClassName[ 32 ];
get_user_aiming( id, iTarget, iBody );
pev( iTarget, pev_classname, szClassName, charsmax( szClassName ) );
if( equal( szEntityClassName, szClassName ) )
return true;
return true;
}