Raised This Month: $359 Target: $400
 89%   Almost there!

Fix Colored Smoke?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Krystek.
Member
Join Date: May 2022
Old 05-22-2022 , 13:11   Fix Colored Smoke?
Reply With Quote #1

Hello, has anyone tried to deal with the problem of non-vanishing fumes in the new round?
If so, which solution do you prefer?

PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>

#define VERSION "1.1"

new const g_szClassname[] = "colored_smokenade";

new 
g_szSmokeSprites];
new 
g_Cvar_Enabled;

new 
entity
while((entity find_ent_by_class(entity"my_entity_classname")) != 0);

public 
plugin_init( ) {
    
register_plugin"Colored Smoke"VERSION"xPaw" );
    
    
register_cvar"colored_smoke"VERSIONFCVAR_SERVER FCVAR_SPONLY );
    
set_cvar_string"colored_smoke"VERSION );
    
    
g_Cvar_Enabled register_cvar"sv_colored_smoke""1" );
    
    
register_forwardFM_EmitSound"FwdEmitSound" );
    
register_touchg_szClassname"worldspawn""FwdTouch_FakeSmoke" );
    
register_thinkg_szClassname"FwdThink_FakeSmoke" );
}

public 
plugin_precache( ) {
    
g_szSmokeSprites] = precache_model"sprites/gas_puff_01y.spr" );
    
g_szSmokeSprites] = precache_model"sprites/gas_puff_01r.spr" );
    
g_szSmokeSprites] = precache_model"sprites/gas_puff_01b.spr" );
    
g_szSmokeSprites] = precache_model"sprites/gas_puff_01g.spr" );
    
g_szSmokeSprites] = precache_model"sprites/gas_puff_01m.spr" );
    
g_szSmokeSprites] = precache_model"sprites/gas_puff_01o.spr" );
    
    
precache_sound"weapons/grenade_hit1.wav" );
}

public 
FwdEmitSoundiOrigEntiChannel, const szSample[], Float:fVolFloat:fAttniFlagsiPitch ) {
    new 
iCvar get_pcvar_numg_Cvar_Enabled );
    if( 
iCvar ) {
        static const 
szSmokeSound[] = "weapons/sg_explode.wav";
        
        if( 
equalszSampleszSmokeSound ) ) {
            
// cache origin, angles and model
            
new Float:vOrigin], Float:vAngles], szModel64 ], iOwner;
            
iOwner entity_get_edictiOrigEntEV_ENT_owner );
            
entity_get_vectoriOrigEntEV_VEC_originvOrigin );
            
entity_get_vectoriOrigEntEV_VEC_anglesvAngles );
            
entity_get_stringiOrigEntEV_SZ_modelszModelcharsmaxszModel ) );
            
            
// remove entity from world
            
entity_set_vectoriOrigEntEV_VEC_originFloat:{ 9999.99999.99999.9 } );
            
entity_set_intiOrigEntEV_INT_flagsFL_KILLME );
            
            
// create new entity                
            
new iEntity create_entity"info_target" );
            if( 
iEntity ) {
                
entity_set_stringiEntityEV_SZ_classnameg_szClassname0);
                
                
entity_set_originiEntityvOrigin );
                
entity_set_vectoriEntityEV_VEC_anglesvAngles );
                
                
entity_set_intiEntityEV_INT_movetypeMOVETYPE_TOSS );
                
entity_set_intiEntityEV_INT_solidSOLID_BBOX );
                
                
entity_set_floatiEntityEV_FL_nextthinkget_gametime( ) + 21.5 );
                
entity_set_floatiEntityEV_FL_gravity0.5 );
                
entity_set_floatiEntityEV_FL_friction0.8 );
                
                
entity_set_modeliEntityszModel );
                
                new 
Float:vVelocity];
                
vVelocity] = random_float( -220.0220.0 );
                
vVelocity] = random_float( -220.0220.0 );
                
vVelocity] = random_float(  200.0300.0 );
                
entity_set_vectoriEntityEV_VEC_velocityvVelocity );
                
                
emit_soundiEntityiChannelszSamplefVolfAttniFlagsiPitch );
                
                
// Create fake smoke
                
new iSmoke;
                
                if( 
iCvar == )
                    
iSmoke get_user_teamiOwner ); // i did indexes as team, 1 - red, 2 - blue, 3 - green( spec oO )
                
else
                    
iSmoke random_num0);
                
                
// Store the smoke number in entity, we will use it later
                
entity_set_intiEntityEV_INT_iuser4iSmoke );
                
                
message_beginMSG_BROADCASTSVC_TEMPENTITY );
                
write_byteTE_FIREFIELD );
                
engfuncEngFunc_WriteCoordvOrigin] );
                
engfuncEngFunc_WriteCoordvOrigin] );
                
engfuncEngFunc_WriteCoordvOrigin] + 50 );
                
write_short100 );
                
write_shortg_szSmokeSpritesiSmoke ] );
                
write_byte100 );
                
write_byteTEFIRE_FLAG_ALPHA );
                
write_byte1000 );
                
message_end();
                
                
message_beginMSG_BROADCASTSVC_TEMPENTITY );
                
write_byteTE_FIREFIELD );
                
engfuncEngFunc_WriteCoordvOrigin] );
                
engfuncEngFunc_WriteCoordvOrigin] );
                
engfuncEngFunc_WriteCoordvOrigin] + 50 );
                
write_short150 );
                
write_shortg_szSmokeSpritesiSmoke ] );
                
write_byte10 );
                
write_byteTEFIRE_FLAG_ALPHA TEFIRE_FLAG_SOMEFLOAT );
                
write_byte1000 );
                
message_end( );
            }
        }
    }
}

public 
FwdTouch_FakeSmokeiEntityiWorld ) {
    if( !
is_valid_entiEntity ) )
        return 
PLUGIN_CONTINUE;
    
    
// Bounce sound
    
emit_soundiEntityCHAN_VOICE"weapons/grenade_hit1.wav"0.25ATTN_NORM0PITCH_NORM );
    
    new 
Float:vVelocity];
    
entity_get_vectoriEntityEV_VEC_velocityvVelocity );
    
    if( 
vVelocity] <= 0.0 && vVelocity] <= 0.0 ) {
        new 
Float:vOrigin];
        new 
iSmoke entity_get_intiEntityEV_INT_iuser4 );
        
entity_get_vectoriEntityEV_VEC_originvOrigin );
        
        
// Make small smoke near grenade on ground
        
message_beginMSG_BROADCASTSVC_TEMPENTITY );
        
write_byteTE_FIREFIELD );
        
engfuncEngFunc_WriteCoordvOrigin] );
        
engfuncEngFunc_WriteCoordvOrigin] );
        
engfuncEngFunc_WriteCoordvOrigin] + 10 );
        
write_short);
        
write_shortg_szSmokeSpritesiSmoke ] );
        
write_byte);
        
write_byteTEFIRE_FLAG_ALLFLOAT TEFIRE_FLAG_ALPHA );
        
write_byte30 );
        
message_end();
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
FwdThink_FakeSmokeiEntity ) {
    if( !
is_valid_entiEntity ) )
        return 
PLUGIN_CONTINUE;
    
    
remove_entityiEntity );
    
    return 
PLUGIN_CONTINUE;


Last edited by Krystek.; 05-22-2022 at 23:33.
Krystek. is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 05-22-2022 , 20:44   Re: Fix Colored Smoke?
Reply With Quote #2

you could find all entity named "colored_smokenade" and remove it at eventNewRound

https://forums.alliedmods.net/showthread.php?t=42159
__________________
My plugin:
Celena Luna is offline
Krystek.
Member
Join Date: May 2022
Old 05-23-2022 , 15:14   Re: Fix Colored Smoke?
Reply With Quote #3

Quote:
Originally Posted by Celena Luna View Post
you could find all entity named "colored_smokenade" and remove it at eventNewRound

https://forums.alliedmods.net/showthread.php?t=42159
From what I remember, there was already such an attempt and it did not work
Krystek. is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 05-23-2022 , 21:13   Re: Fix Colored Smoke?
Reply With Quote #4

PHP Code:
#include <engine>

new const g_szClassname[] = "colored_smokenade";

public 
plugin_init()
{
    
register_event("HLTV""Event_HLTV_New_Round""a""1=0""2=0")
}

public 
Event_HLTV_New_Round()
{
    new 
ent = -1
    
while( (find_ent_by_class(entg_szClassname)) > )
    {
        
remove_entity(ent)
    }

could you try this?
__________________
My plugin:

Last edited by Celena Luna; 05-23-2022 at 21:13.
Celena Luna is offline
Krystek.
Member
Join Date: May 2022
Old 05-24-2022 , 01:31   Re: Fix Colored Smoke?
Reply With Quote #5

Quote:
Originally Posted by Celena Luna View Post
PHP Code:
#include <engine>

new const g_szClassname[] = "colored_smokenade";

public 
plugin_init()
{
    
register_event("HLTV""Event_HLTV_New_Round""a""1=0""2=0")
}

public 
Event_HLTV_New_Round()
{
    new 
ent = -1
    
while( (find_ent_by_class(entg_szClassname)) > )
    {
        
remove_entity(ent)
    }

could you try this?

Unfortunately not
Krystek. is offline
Krystek.
Member
Join Date: May 2022
Old 05-28-2022 , 22:32   Re: Fix Colored Smoke?
Reply With Quote #6

Anyone have any ideas?
Krystek. is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 05-29-2022 , 00:04   Re: Fix Colored Smoke?
Reply With Quote #7

It will not disappear until the duration set by TE_FIREFIELD ends.
If you want it to disappear at will, the only way is to modify it by creating an entity to represent it.
__________________
GitHub
SteamWishlist

六四天安門事件
+ARUKARI- is offline
Krystek.
Member
Join Date: May 2022
Old 05-29-2022 , 05:02   Re: Fix Colored Smoke?
Reply With Quote #8

Quote:
Originally Posted by +ARUKARI- View Post
It will not disappear until the duration set by TE_FIREFIELD ends.
If you want it to disappear at will, the only way is to modify it by creating an entity to represent it.
I also found such a code

PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>

#if !defined write_coord_f
    #define write_coord_f(%1)   engfunc( EngFunc_WriteCoord, %1 )
#endif

#define VERSION "1.07"
#define SMOKE_SPRITE "sprites/newsmoke.spr"

new const g_szClassname[] = "custom_smoke";
new 
g_fwid
new g_evCreateSmoke;
new 
g_szSmokeSprite;
new 
g_Cvar_Enabled;
new 
g_Cvar_Duration;
new 
g_Cvar_CountSprites;
new 
g_Clear;
new 
g_iCvar_Enebled;
new 
g_iCountSprites;

public 
plugin_init( )
{
    
register_plugin"Custom Smoke"VERSION"bionext" );

    
g_Clear 0;
    
g_iCvar_Enebled 0;
    
g_Cvar_Enabled register_cvar"sv_customsmoke""1" );
    
g_Cvar_Duration register_cvar"sv_smokeduration""10.0" );
    
g_Cvar_CountSprites register_cvar"sv_smokespritescount""100" );

    
unregister_forward(FM_PrecacheEventg_fwid1);

    
register_thinkg_szClassname"FwdThink_BlackSmoke" );
    
register_forward(FM_PlaybackEvent"FwdPlaybackEvent");
    
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_iCvar_Enebled get_pcvar_numg_Cvar_Enabled );
    
g_Clear 0;
}

public 
plugin_precache( )
{
    
g_szSmokeSprite precache_modelSMOKE_SPRITE );
    
g_fwid register_forward(FM_PrecacheEvent"FwdPrecacheEvent"1);
    
force_unmodified(force_exactfile, {0,0,0},{0,0,0}, SMOKE_SPRITE);
}

public 
FwdPlaybackEventiFlags iEntity iEventindexFloat:fDelayFloat:vOrigin[3], Float:vAngles[3], Float:fParam1Float:fParam2iParam1iParam2iBparam1iBparam2 )
{
    if(
iEventindex != g_evCreateSmoke || iBparam2 || !g_iCvar_Enebled)
        return 
FMRES_IGNORED;

    new 
iEnt create_entity"info_target" );

    if( !
iEnt )
        return 
FMRES_IGNORED;
  
    
g_iCountSprites get_pcvar_numg_Cvar_CountSprites );
    new 
Float:fDuration get_pcvar_floatg_Cvar_Duration );
          
    
entity_set_stringiEntEV_SZ_classnameg_szClassname );
    
entity_set_floatiEntEV_FL_nextthinkget_gametime( ));
    
entity_set_vectoriEntEV_VEC_originvOrigin );
    
entity_set_floatiEntEV_FL_animtimefDuration );

    return 
FMRES_SUPERCEDE;
}

public 
FwdPrecacheEvent(type, const name[])
{
    if (
equal("events/createsmoke.sc"name))
    {
        
g_evCreateSmoke get_orig_retval();
        return 
FMRES_HANDLED;
    }

    return 
FMRES_IGNORED;
}

public 
FwdThink_BlackSmokeiEntity )
{
    if( !
is_valid_entiEntity ) )
        return 
PLUGIN_CONTINUE;

    if( 
g_Clear )
    {
        
entity_set_intiEntity,EV_INT_flagsFL_KILLME );
        return 
PLUGIN_CONTINUE;
    }

    new 
Float:vOrigin[3];
    
entity_get_vectoriEntityEV_VEC_originvOrigin );

    
message_beginMSG_BROADCASTSVC_TEMPENTITY );
    
write_byteTE_FIREFIELD );
    
write_coord_fvOrigin] );
    
write_coord_fvOrigin] );
    
write_coord_fvOrigin] + 50 );
    
write_short100 );
    
write_shortg_szSmokeSprite );
    
write_byteg_iCountSprites );
    
write_byteTEFIRE_FLAG_ALPHA );
    
write_byte11 );
    
message_end();

    
message_beginMSG_BROADCASTSVC_TEMPENTITY );
    
write_byteTE_FIREFIELD );
    
write_coord_fvOrigin] );
    
write_coord_fvOrigin] );
    
write_coord_fvOrigin] + 50 );
    
write_short150 );
    
write_shortg_szSmokeSprite );
    
write_byte);
    
write_byteTEFIRE_FLAG_ALPHA TEFIRE_FLAG_SOMEFLOAT );
    
write_byte11 );
    
message_end( );

    new 
Float:time entity_get_float(iEntity,EV_FL_animtime);
    
time time 0.25;

    if( 
time 0.0 )
    {
        
entity_set_floatiEntityEV_FL_nextthinkget_gametime( ) + 0.25 );
        
entity_set_floatiEntityEV_FL_animtimetime );
    }
    else
    {
        
entity_set_intiEntity,EV_INT_flagsFL_KILLME );
    }

    return 
PLUGIN_CONTINUE;

But I don't know at all how to add a few colors to it because when I try to add it it varies over time
Krystek. is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:03.


Powered by vBulletin®
Copyright ©2000 - 2022, vBulletin Solutions, Inc.
Theme made by Freecode