Advertisement
useless28

Untitled

Jun 4th, 2019
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.89 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <engine>
  3. #include <fakemeta>
  4.  
  5. #if !defined write_coord_f
  6.     #define write_coord_f(%1)   engfunc( EngFunc_WriteCoord, %1 )
  7. #endif
  8.  
  9. #define VERSION "1.07"
  10. #define SMOKE_SPRITE "sprites/gas_puff_011.spr"
  11.  
  12. new const g_szClassname[] = "custom_smoke";
  13. new g_fwid
  14. new g_evCreateSmoke;
  15. new g_szSmokeSprite;
  16. new g_Cvar_Enabled;
  17. new g_Cvar_Duration;
  18. new g_Cvar_CountSprites;
  19. new g_Clear;
  20. new g_iCvar_Enebled;
  21. new g_iCountSprites;
  22.  
  23. public plugin_init( )
  24. {
  25.     register_plugin( "Custom Smoke", VERSION, "bionext" );
  26.  
  27.     g_Clear = 0;
  28.     g_iCvar_Enebled = 0;
  29.     g_Cvar_Enabled = register_cvar( "sv_customsmoke", "1" );
  30.     g_Cvar_Duration = register_cvar( "sv_smokeduration", "10.0" );
  31.     g_Cvar_CountSprites = register_cvar( "sv_smokespritescount", "30" );
  32.  
  33.     unregister_forward(FM_PrecacheEvent, g_fwid, 1);
  34.  
  35.     register_think( g_szClassname, "FwdThink_BlackSmoke" );
  36.     register_forward(FM_PlaybackEvent, "FwdPlaybackEvent");
  37.     register_logevent("FwdClear", 2, "1=Round_End");
  38.     register_logevent("FwdStart", 2, "1=Round_Start");
  39.     register_event("TextMsg", "FwdClear", "a", "2=#Game_will_restart_in","2=#Game_Commencing");
  40. }
  41.  
  42. public FwdClear( )
  43. {
  44.     g_Clear = 1;
  45. }
  46.  
  47. public FwdStart( )
  48. {
  49.     g_iCvar_Enebled = get_pcvar_num( g_Cvar_Enabled );
  50.    
  51.     new map[33];
  52.     get_mapname(map, 32);
  53.    
  54.     if (containi(map, "de_aztec") != -1)
  55.         g_iCvar_Enebled = 0;
  56.    
  57.     g_Clear = 0;
  58. }
  59.  
  60. public plugin_precache( )
  61. {
  62.     g_szSmokeSprite = precache_model( SMOKE_SPRITE );
  63.     g_fwid = register_forward(FM_PrecacheEvent, "FwdPrecacheEvent", 1);
  64.     force_unmodified(force_exactfile, {0,0,0},{0,0,0}, SMOKE_SPRITE);
  65. }
  66.  
  67. public FwdPlaybackEvent( iFlags , iEntity , iEventindex, Float:fDelay, Float:vOrigin[3], Float:vAngles[3], Float:fParam1, Float:fParam2, iParam1, iParam2, iBparam1, iBparam2 )
  68. {
  69.     if(iEventindex != g_evCreateSmoke || iBparam2 || !g_iCvar_Enebled)
  70.         return FMRES_IGNORED;
  71.  
  72.     new iEnt = create_entity( "info_target" );
  73.  
  74.     if( !iEnt )
  75.         return FMRES_IGNORED;
  76.  
  77.     g_iCountSprites = get_pcvar_num( g_Cvar_CountSprites );
  78.     new Float:fDuration = get_pcvar_float( g_Cvar_Duration );
  79.          
  80.     entity_set_string( iEnt, EV_SZ_classname, g_szClassname );
  81.     entity_set_float( iEnt, EV_FL_nextthink, get_gametime( ));
  82.     entity_set_vector( iEnt, EV_VEC_origin, vOrigin );
  83.     entity_set_float( iEnt, EV_FL_animtime, fDuration );
  84.  
  85.     return FMRES_SUPERCEDE;
  86. }
  87.  
  88. public FwdPrecacheEvent(type, const name[])
  89. {
  90.     if (equal("events/createsmoke.sc", name))
  91.     {
  92.         g_evCreateSmoke = get_orig_retval();
  93.         return FMRES_HANDLED;
  94.     }
  95.  
  96.     return FMRES_IGNORED;
  97. }
  98.  
  99. public FwdThink_BlackSmoke( iEntity )
  100. {
  101.     if( !is_valid_ent( iEntity ) )
  102.         return PLUGIN_CONTINUE;
  103.  
  104.     if( g_Clear > 0 )
  105.     {
  106.         entity_set_int( iEntity,EV_INT_flags, FL_KILLME );
  107.         return PLUGIN_CONTINUE;
  108.     }
  109.  
  110.     new Float:vOrigin[3];
  111.     entity_get_vector( iEntity, EV_VEC_origin, vOrigin );
  112.  
  113.     message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
  114.     write_byte( TE_FIREFIELD );
  115.     write_coord_f( vOrigin[ 0 ] );
  116.     write_coord_f( vOrigin[ 1 ] );
  117.     write_coord_f( vOrigin[ 2 ] + 50 );
  118.     write_short( 75 );
  119.     write_short( g_szSmokeSprite );
  120.     write_byte( g_iCountSprites );
  121.     write_byte( TEFIRE_FLAG_ALPHA | TEFIRE_FLAG_PLANAR );
  122.     write_byte( 11 );
  123.     message_end();
  124.  
  125.     new Float:time = entity_get_float(iEntity,EV_FL_animtime);
  126.     time = time - 0.25;
  127.  
  128.     if( time > 0.0 )
  129.     {
  130.         entity_set_float( iEntity, EV_FL_nextthink, get_gametime( ) + 0.25 );
  131.         entity_set_float( iEntity, EV_FL_animtime, time );
  132.     }
  133.     else
  134.     {
  135.         entity_set_int( iEntity,EV_INT_flags, FL_KILLME );
  136.     }
  137.  
  138.     return PLUGIN_CONTINUE;
  139. }
  140.  
  141. public inconsistent_file(id, const filename[], reason[64])
  142. {
  143.     if(equal(filename, SMOKE_SPRITE))
  144.         return PLUGIN_CONTINUE
  145.    
  146.     return PLUGIN_HANDLED;
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement