#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <reapi>
#include <revip>
#define VERSION "1.0.0"
#define SMOKE_SPRITE "sprites/thick_gray_gas_puff.spr"
#define VIP_SMOKE_SPRITE "sprites/gas_puff_black_opaque.spr"
new const g_szClassname[] = "custom_smoke";
new g_szSmokeSprite;
new g_szVipSmokeSprite;
new g_Clear = 0;
new Float:g_iSmokeDuration = 10.0;
new Float:g_iVipSmokeDuration = 15.0;
new g_iCountSprites = 50;
public plugin_init()
{
register_plugin( "ReVip Custom Smoke", VERSION, "zxchain" );
register_think( g_szClassname, "FwdThink_BlackSmoke" );
RegisterHookChain(RG_CGrenade_ExplodeSmokeGrenade, "CGrenade_ExplodeSmokeGrenade_Post", true);
register_logevent("FwdClear", 2, "1=Round_End");
register_logevent("FwdStart", 2, "1=Round_Start");
register_event("TextMsg", "FwdClear", "a", "2=#Game_will_restart_in","2=#Game_Commencing");
}
public FwdClear()
{
g_Clear = 1;
}
public FwdStart()
{
g_Clear = 0;
}
public plugin_precache()
{
g_szSmokeSprite = precache_model( SMOKE_SPRITE );
g_szVipSmokeSprite = precache_model( VIP_SMOKE_SPRITE );
force_unmodified(force_exactfile, {0,0,0},{0,0,0}, SMOKE_SPRITE);
force_unmodified(force_exactfile, {0,0,0},{0,0,0}, VIP_SMOKE_SPRITE);
}
public CGrenade_ExplodeSmokeGrenade_Post(const ent)
{
new iEnt = create_entity( "info_target" );
if( !iEnt ) {
return HC_CONTINUE;
}
new ownerId = pev(ent, pev_owner);
new Float:vOrigin[3];
entity_get_vector( ent, EV_VEC_origin, vOrigin );
entity_set_vector( ent, EV_VEC_origin, Float:{ 9999.9, 9999.9, 9999.9 } );
entity_set_int( ent, EV_INT_flags, FL_KILLME );
new Float:fDuration;
if(is_user_vip(ownerId)) {
fDuration = g_iSmokeDuration;
}
else {
fDuration = g_iVipSmokeDuration;
}
entity_set_int( iEnt, EV_INT_iuser1, ownerId );
entity_set_string( iEnt, EV_SZ_classname, g_szClassname );
entity_set_float( iEnt, EV_FL_nextthink, get_gametime( ));
entity_set_vector( iEnt, EV_VEC_origin, vOrigin );
entity_set_float( iEnt, EV_FL_animtime, fDuration );
return HC_CONTINUE;
}
public FwdThink_BlackSmoke( iEntity )
{
if( !is_valid_ent( iEntity ) ) {
return PLUGIN_CONTINUE;
}
if( g_Clear > 0 )
{
entity_set_int( iEntity,EV_INT_flags, FL_KILLME );
return PLUGIN_CONTINUE;
}
new ownerId = entity_get_int( iEntity, EV_INT_iuser1 );
new Float:vOrigin[3];
entity_get_vector( iEntity, EV_VEC_origin, vOrigin );
new smokeSprite;
if(is_user_vip(ownerId)) {
smokeSprite = g_szVipSmokeSprite;
}
else {
smokeSprite = g_szSmokeSprite;
}
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_FIREFIELD );
engfunc( EngFunc_WriteCoord, vOrigin[ 0 ] );
engfunc( EngFunc_WriteCoord, vOrigin[ 1 ] );
engfunc( EngFunc_WriteCoord, vOrigin[ 2 ] + 50 );
write_short( 100 );
write_short( smokeSprite );
write_byte( g_iCountSprites );
write_byte( TEFIRE_FLAG_ALPHA );
write_byte( 11 );
message_end();
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_FIREFIELD );
engfunc( EngFunc_WriteCoord, vOrigin[ 0 ] );
engfunc( EngFunc_WriteCoord, vOrigin[ 1 ] );
engfunc( EngFunc_WriteCoord, vOrigin[ 2 ] + 50 );
write_short( 150 );
write_short( smokeSprite );
write_byte( 5 );
write_byte( TEFIRE_FLAG_ALPHA | TEFIRE_FLAG_SOMEFLOAT );
write_byte( 11 );
message_end( );
new Float:time = entity_get_float(iEntity,EV_FL_animtime);
time = time - 0.25;
if( time > 0.0 )
{
entity_set_float( iEntity, EV_FL_nextthink, get_gametime( ) + 0.25 );
entity_set_float( iEntity, EV_FL_animtime, time );
}
else
{
entity_set_int( iEntity, EV_INT_flags, FL_KILLME );
}
return PLUGIN_CONTINUE;
}