Next time post in requests section.
Code:
#include < amxmodx >
#include < engine >
#include < fakemeta >
new const SOUND[ ] = "buttons/blip1.wav";
enum _:BeaconTypes {
Beacon_Dropped,
Beacon_Planted
};
new g_pCvar, g_pSound;
new g_iSprite;
public plugin_init( ) {
register_plugin( "Bomb Beacon", "1.0", "xPaw" );
g_pCvar = register_cvar( "bb_enabled", "3" ); // 0 - Dropped | 1 - Planted | 2 - Both
g_pSound = register_cvar( "bb_sound", "0" );
if( !find_ent_by_class( FM_NULLENT, "func_bomb_target" )
&& !find_ent_by_class( FM_NULLENT, "info_bomb_target" ) )
pause( "a" );
register_logevent( "BombDropped", 3, "2=Dropped_The_Bomb" );
register_logevent( "BombPlanted", 3, "2=Planted_The_Bomb" );
}
public plugin_precache( ) {
g_iSprite = precache_model( "sprites/laserbeam.spr" );
precache_sound( SOUND );
}
public BombDropped( )
if( IsEnabled( Beacon_Dropped ) )
set_task( 1.0, "FindBomb" );
public FindBomb( )
ShowBeacon( find_ent_by_model( FM_NULLENT, "weaponbox", "models/w_backpack.mdl" ) );
public BombPlanted( ) {
if( IsEnabled( Beacon_Planted ) ) {
new iBomb = find_ent_by_model( FM_NULLENT, "grenade", "models/w_c4.mdl" );
if( iBomb )
set_task( 1.0, "ShowBeacon", iBomb );
}
}
public ShowBeacon( const iEntity ) {
if( !is_valid_ent( iEntity ) )
return;
set_task( 2.0, "ShowBeacon", iEntity );
if( get_pcvar_num( g_pSound ) )
emit_sound( iEntity, CHAN_ITEM, SOUND, 1.0, ATTN_NORM, 0, PITCH_NORM );
new Float:vOrigin[ 3 ];
entity_get_vector( iEntity, EV_VEC_origin, vOrigin );
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_BEAMCYLINDER );
engfunc( EngFunc_WriteCoord, vOrigin[ 0 ] );
engfunc( EngFunc_WriteCoord, vOrigin[ 1 ] );
engfunc( EngFunc_WriteCoord, vOrigin[ 2 ] );
engfunc( EngFunc_WriteCoord, vOrigin[ 0 ] );
engfunc( EngFunc_WriteCoord, vOrigin[ 1 ] );
engfunc( EngFunc_WriteCoord, vOrigin[ 2 ] + 100 );
write_short( g_iSprite );
write_byte( 0 );
write_byte( 1 );
write_byte( 6 );
write_byte( 2 );
write_byte( 1 );
write_byte( 255 );
write_byte( 0 );
write_byte( 0 );
write_byte( 200 );
write_byte( 6 );
message_end( );
}
bool:IsEnabled( const iType ) {
new iCvar = get_pcvar_num( g_pCvar );
return bool:( iCvar & iType );
}