搜索
查看: 37|回复: 0

求助 彩色烟雾 本局对战结束时下一局对战烟雾还存在的问题

[复制链接]
发表于 前天 10:56 | 显示全部楼层 |阅读模式 来自 中国–浙江–嘉兴
本帖最后由 zhouqundao 于 2025-8-11 10:59 编辑

外网扒来得 代码

运行能运行

就是 烟雾效果 本局对战结束后   新一局对战   上一局得烟雾效果还在   

可能是没有对局结束事件判定 烟雾没有清除变量   


附上源码


请大佬帮忙  修复一下   




  1. #include <amxmodx>
  2. #include <engine>
  3. #include <fakemeta>

  4. #define VERSION "1.1"

  5. new const g_szClassname[] = "colored_smokenade";

  6. new g_szSmokeSprites[ 6 ];
  7. new g_Cvar_Enabled;

  8. public plugin_init( ) {
  9.         register_plugin( "Colored Smoke", VERSION, "xPaw" );
  10.        
  11.         register_cvar( "colored_smoke", VERSION, FCVAR_SERVER | FCVAR_SPONLY );
  12.         set_cvar_string( "colored_smoke", VERSION );
  13.        
  14.         g_Cvar_Enabled = register_cvar( "sv_colored_smoke", "1" );
  15.        
  16.         register_forward( FM_EmitSound, "FwdEmitSound" );
  17.         register_touch( g_szClassname, "worldspawn", "FwdTouch_FakeSmoke" );
  18.         register_think( g_szClassname, "FwdThink_FakeSmoke" );
  19. }

  20. public plugin_precache( ) {
  21.         g_szSmokeSprites[ 0 ] = precache_model( "sprites/gas_puff_01y.spr" );
  22.         g_szSmokeSprites[ 1 ] = precache_model( "sprites/gas_puff_01r.spr" );
  23.         g_szSmokeSprites[ 2 ] = precache_model( "sprites/gas_puff_01b.spr" );
  24.         g_szSmokeSprites[ 3 ] = precache_model( "sprites/gas_puff_01g.spr" );
  25.         g_szSmokeSprites[ 4 ] = precache_model( "sprites/gas_puff_01m.spr" );
  26.         g_szSmokeSprites[ 5 ] = precache_model( "sprites/gas_puff_01o.spr" );
  27.        
  28.         precache_sound( "weapons/grenade_hit1.wav" );
  29. }

  30. public FwdEmitSound( iOrigEnt, iChannel, const szSample[], Float:fVol, Float:fAttn, iFlags, iPitch ) {
  31.         new iCvar = get_pcvar_num( g_Cvar_Enabled );
  32.         if( iCvar > 0 ) {
  33.                 static const szSmokeSound[] = "weapons/sg_explode.wav";
  34.                
  35.                 if( equal( szSample, szSmokeSound ) ) {
  36.                         // cache origin, angles and model
  37.                         new Float:vOrigin[ 3 ], Float:vAngles[ 3 ], szModel[ 64 ], iOwner;
  38.                         iOwner = entity_get_edict( iOrigEnt, EV_ENT_owner );
  39.                         entity_get_vector( iOrigEnt, EV_VEC_origin, vOrigin );
  40.                         entity_get_vector( iOrigEnt, EV_VEC_angles, vAngles );
  41.                         entity_get_string( iOrigEnt, EV_SZ_model, szModel, charsmax( szModel ) );
  42.                        
  43.                         // remove entity from world
  44.                         entity_set_vector( iOrigEnt, EV_VEC_origin, Float:{ 9999.9, 9999.9, 9999.9 } );
  45.                         entity_set_int( iOrigEnt, EV_INT_flags, FL_KILLME );
  46.                        
  47.                         // create new entity
  48.                         new iEntity = create_entity( "info_target" );
  49.                         if( iEntity > 0 ) {
  50.                                 entity_set_string( iEntity, EV_SZ_classname, g_szClassname );
  51.                                
  52.                                 entity_set_origin( iEntity, vOrigin );
  53.                                 entity_set_vector( iEntity, EV_VEC_angles, vAngles );
  54.                                
  55.                                 entity_set_int( iEntity, EV_INT_movetype, MOVETYPE_TOSS );
  56.                                 entity_set_int( iEntity, EV_INT_solid, SOLID_BBOX );
  57.                                
  58.                                 entity_set_float( iEntity, EV_FL_nextthink, get_gametime( ) + 21.5 );
  59.                                 entity_set_float( iEntity, EV_FL_gravity, 0.5 );
  60.                                 entity_set_float( iEntity, EV_FL_friction, 0.8 );
  61.                                
  62.                                 entity_set_model( iEntity, szModel );
  63.                                
  64.                                 new Float:vVelocity[ 3 ];
  65.                                 vVelocity[ 0 ] = random_float( -220.0, 220.0 );
  66.                                 vVelocity[ 1 ] = random_float( -220.0, 220.0 );
  67.                                 vVelocity[ 2 ] = random_float(  200.0, 300.0 );
  68.                                 entity_set_vector( iEntity, EV_VEC_velocity, vVelocity );
  69.                                
  70.                                 emit_sound( iEntity, iChannel, szSample, fVol, fAttn, iFlags, iPitch );
  71.                                
  72.                                 // Create fake smoke
  73.                                 new iSmoke;
  74.                                
  75.                                 if( iCvar == 2 )
  76.                                         iSmoke = get_user_team( iOwner ); // i did indexes as team, 1 - red, 2 - blue, 3 - green( spec oO )
  77.                                 else
  78.                                         iSmoke = random_num( 0, 5 );
  79.                                
  80.                                 // Store the smoke number in entity, we will use it later
  81.                                 entity_set_int( iEntity, EV_INT_iuser4, iSmoke );
  82.                                
  83.                                 message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
  84.                                 write_byte( TE_FIREFIELD );
  85.                                 engfunc( EngFunc_WriteCoord, vOrigin[ 0 ] );
  86.                                 engfunc( EngFunc_WriteCoord, vOrigin[ 1 ] );
  87.                                 engfunc( EngFunc_WriteCoord, vOrigin[ 2 ] + 50 );
  88.                                 write_short( 100 );
  89.                                 write_short( g_szSmokeSprites[ iSmoke ] );
  90.                                 write_byte( 100 );
  91.                                 write_byte( TEFIRE_FLAG_ALPHA );
  92.                                 write_byte( 1000 );
  93.                                 message_end();
  94.                                
  95.                                 message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
  96.                                 write_byte( TE_FIREFIELD );
  97.                                 engfunc( EngFunc_WriteCoord, vOrigin[ 0 ] );
  98.                                 engfunc( EngFunc_WriteCoord, vOrigin[ 1 ] );
  99.                                 engfunc( EngFunc_WriteCoord, vOrigin[ 2 ] + 50 );
  100.                                 write_short( 150 );
  101.                                 write_short( g_szSmokeSprites[ iSmoke ] );
  102.                                 write_byte( 10 );
  103.                                 write_byte( TEFIRE_FLAG_ALPHA | TEFIRE_FLAG_SOMEFLOAT );
  104.                                 write_byte( 1000 );
  105.                                 message_end( );
  106.                         }
  107.                 }
  108.         }
  109. }

  110. public FwdTouch_FakeSmoke( iEntity, iWorld ) {
  111.         if( !is_valid_ent( iEntity ) )
  112.                 return PLUGIN_CONTINUE;
  113.        
  114.         // Bounce sound
  115.         emit_sound( iEntity, CHAN_VOICE, "weapons/grenade_hit1.wav", 0.25, ATTN_NORM, 0, PITCH_NORM );
  116.        
  117.         new Float:vVelocity[ 3 ];
  118.         entity_get_vector( iEntity, EV_VEC_velocity, vVelocity );
  119.        
  120.         if( vVelocity[ 1 ] <= 0.0 && vVelocity[ 2 ] <= 0.0 ) {
  121.                 new Float:vOrigin[ 3 ];
  122.                 new iSmoke = entity_get_int( iEntity, EV_INT_iuser4 );
  123.                 entity_get_vector( iEntity, EV_VEC_origin, vOrigin );
  124.                
  125.                 // Make small smoke near grenade on ground
  126.                 message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
  127.                 write_byte( TE_FIREFIELD );
  128.                 engfunc( EngFunc_WriteCoord, vOrigin[ 0 ] );
  129.                 engfunc( EngFunc_WriteCoord, vOrigin[ 1 ] );
  130.                 engfunc( EngFunc_WriteCoord, vOrigin[ 2 ] + 10 );
  131.                 write_short( 2 );
  132.                 write_short( g_szSmokeSprites[ iSmoke ] );
  133.                 write_byte( 2 );
  134.                 write_byte( TEFIRE_FLAG_ALLFLOAT | TEFIRE_FLAG_ALPHA );
  135.                 write_byte( 30 );
  136.                 message_end();
  137.         }
  138.        
  139.         return PLUGIN_CONTINUE;
  140. }

  141. public FwdThink_FakeSmoke( iEntity ) {
  142.         if( !is_valid_ent( iEntity ) )
  143.                 return PLUGIN_CONTINUE;
  144.        
  145.         remove_entity( iEntity );
  146.        
  147.         return PLUGIN_CONTINUE;
  148. }
复制代码
游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

快速回复 返回顶部 返回列表