#include <amxmodx>
#include <fakemeta>
#include <reapi>
#define XO_WEAPON 4
#define m_iGrenadeType 96
enum _:Sprites
{
SPRITE_EFEKT1,
SPRITE_EFEKT2
}
new g_iSprites[ Sprites ];
new _MsgTempEntity, _pfnEmitSound;
new const g_szSndExplosion[] = "explode.wav";
public plugin_init()
{
register_plugin( "CS:GO Grenade Effect", "0.2", "hornet / Edit:F.T.H" );
RegisterHookChain(RG_CBasePlayer_ThrowGrenade, "ThrowGrenade", true);
}
public plugin_precache()
{
precache_sound( g_szSndExplosion );
g_iSprites[ SPRITE_EFEKT1 ] = precache_model( "sprites/csgo_efekt/fexplo1.spr" );
g_iSprites[ SPRITE_EFEKT2 ] = precache_model( "sprites/csgo_efekt/fexplo.spr" );
}
public Message_TempEntity()
{
new iType = get_msg_arg_int( 1 );
if( iType == TE_EXPLOSION || iType == TE_SMOKE) return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
public pfnEmitSound( iEnt, iChannel, szSound[], Float:flVolume, Float:flAtt, Flags, iPitch )
{
if( equal( szSound, "weapons/debris1.wav" ) || equal( szSound, "weapons/debris2.wav" ) || equal( szSound, "weapons/debris3.wav" ) )
{
if(!pev_valid(iEnt))
return FMRES_IGNORED;
new Float:vOrigin[ 3 ];
pev( iEnt, pev_origin, vOrigin );
vOrigin[ 2 ] -= 35.0;
set_pev( iEnt, pev_origin, vOrigin );
UTIL_Explosion( iEnt, g_iSprites[ SPRITE_EFEKT1 ], 20, 20, 4 ); // KIVILCIM
UTIL_Explosion( iEnt, g_iSprites[ SPRITE_EFEKT2 ], 20, 16, 4 );
engfunc( EngFunc_EmitSound, iEnt, iChannel, g_szSndExplosion, flVolume, flAtt, Flags, iPitch );
remove_task(iEnt)
set_task(1.0,"UnregisterEffects",iEnt)
return FMRES_SUPERCEDE;
}
return FMRES_IGNORED;
}
public ThrowGrenade(const iOwner, const iEntity, Float:vecSrc[3], Float:vecThrow[3], Float:time, const usEvent)
{
new grenade = GetHookChainReturn(ATYPE_INTEGER);
if (is_nullent(grenade))
{
return HC_CONTINUE;
}
if( !_MsgTempEntity )
{
_MsgTempEntity = register_message( SVC_TEMPENTITY, "Message_TempEntity" );
_pfnEmitSound = register_forward( FM_EmitSound, "pfnEmitSound" );
}
return HC_CONTINUE;
}
UTIL_Explosion( iEnt, iSprite, iScale, iFramerate, Flags )
{
new Float:vOrigin[ 3 ];
pev( iEnt, pev_origin, vOrigin );
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_EXPLOSION );
engfunc( EngFunc_WriteCoord, vOrigin[ 0 ] );
engfunc( EngFunc_WriteCoord, vOrigin[ 1 ] );
engfunc( EngFunc_WriteCoord, vOrigin[ 2 ] );
write_short( iSprite );
write_byte( iScale );
write_byte( iFramerate );
write_byte( Flags );
message_end();
}
public UnregisterEffects( iIndex )
{
new iEnt = 0;
while( ( iEnt = rg_find_ent_by_class( iEnt, "grenade" ) ) )
{
if( !( get_pdata_int( iEnt, m_iGrenadeType, XO_WEAPON ) & ( 1 << 8 ) ) && iEnt != iIndex )
return;
}
unregister_message( SVC_TEMPENTITY, _MsgTempEntity );
unregister_forward( FM_EmitSound, _pfnEmitSound );
_MsgTempEntity = 0;
}