Raised This Month: $ Target: $400
 0% 

Smoke Flare


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Samsoniq
Junior Member
Join Date: May 2010
Old 05-05-2010 , 17:31   Smoke Flare
Reply With Quote #1

Please help me with script :
It's work , but on new round The glow around the player remains

Code:
-------------------------------
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>

#define PLUGIN "Smoke Flare"
#define VERSION "0.1"
#define AUTHOR "Samson:)"

#define FLARE_ENTITY args[0]
#define FLARE_DURATION args[1]
#define FLARE_R args[2]
#define FLARE_G args[3]
#define FLARE_B args[4]
#define FLAME_DUATION args[0]

new cvar_flaregrenades, cvar_flareduration, cvar_flaresize,  cvar_flarecolor

new g_trailSpr

new const sprite_grenade_trail[] = { "sprites/laserbeam.spr" }

const PEV_NADE_TYPE = pev_flTimeStepSound

const NADE_TYPE_FLARE = 4444

const PEV_FLARE_COLOR = pev_punchangle

new const grenade_flare[][] = { "items/nvg_on.wav" }

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
       
    cvar_flaregrenades = register_cvar("zp_flare_grenades","1")
    cvar_flareduration = register_cvar("zp_flare_duration", "30")
    cvar_flaresize = register_cvar("zp_flare_size", "30")
    cvar_flarecolor = register_cvar("zp_flare_color", "4")
    register_forward(FM_SetModel, "fw_SetModel")
    RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
       
}

public plugin_precache()
{
       
    g_trailSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_trail)

}

public fw_SetModel(entity, const model[])
{
       
    if (equal(model[7], "w_sm", 4) &&  get_pcvar_num(cvar_flaregrenades)) // Flare
    {
     // Make the flare color
     static rgb[3]
     switch (get_pcvar_num(cvar_flarecolor))
     {
      case 0: // white
      {
       rgb[0] = 255 // r
       rgb[1] = 255 // g
       rgb[2] = 255 // b
      }
      case 1: // red
      {
       rgb[0] = random_num(50,255) // r
       rgb[1] = 0 // g
       rgb[2] = 0 // b
      }
      case 2: // green
      {
       rgb[0] = 0 // r
       rgb[1] = random_num(50,255) // g
       rgb[2] = 0 // b
      }
      case 3: // blue
      {
       rgb[0] = 0 // r
       rgb[1] = 0 // g
       rgb[2] = random_num(50,255) // b
      }
      case 4: // random (all colors)
      {
       rgb[0] = random_num(50,200) // r
       rgb[1] = random_num(50,200) // g
       rgb[2] = random_num(50,200) // b
      }
      case 5: // random (r,g,b)
      {
       switch (random_num(1, 3))
       {
        case 1: // red
        {
         rgb[0]  random_num(50,255) // r
         rgb[1] = 0 // g
         rgb[2] = 0 // b
        }
        case 2: // green
        {
         rgb[0] = 0 // r
         rgb[1] = random_num(50,255) // g
         rgb[2] = 0 // b
        }
        case 3: // blue
        {
         rgb[0] = 0 // r
         rgb[1] = 0 // g
         rgb[2] = random_num(50,255) // b
        }
       }
      }
     }
        
     // Give it a glow
     fm_set_rendering(entity, kRederFxGlowShell, rgb[0], rgb[1],  rgb[2], kRenderNormal, 16);
        
     // And a colored trail
     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
     write_byte(TE_BEAMFOLLOW) // TE id
     write_short(entity) // entity
     write_short(g_trailSpr) // sprite
     write_byte(10) // life
     write_byte(10) // width
     write_byte(rgb[0]) // r
     write_byte(rgb[1]) // g
     write_byte(rgb[2]) // b
     write_byte(200) // brightness
     message_end()
        
     // Set grenade type on the thrown grenade entity
     set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_FLARE)
        
     // Set flare color on the thrown grenade entity
     set_pev(entity, PEV_FLAE_COLOR, rgb)
    }
}

public fw_ThinkGrenade(entity)
{
       
    switch (pev(entity, PEV_NADE_TYPE))
    {
     case NADE_TYPE_FLARE: // Flare
     {      
      // Light up when it's stopped on ground
      if ((pev(entity, pev_flags) & FL_ONGROUND) &&  fm_get_speed(entity) < 10)
      {
       // Flare sound
       engfunc(EngFunc_EmitSound, entity, CHAN_WEAPON,  grenade_flare[random_num(0, sizeof grenade_flare - 1)], 1.0, ATTN_NORM,  0, PITCH_NORM)
          
       // Our task params
       static params[5]
       params[0] = entity // entity id
       params[1] = get_pcvar_num(cvar_flareduration)/5 // duration
          
       // Retrieve flare color from entity
       pev(entity, PEV_FLARE_COLOR, params[2]) // params[2] r -  params[3] g - params[4] b
          
       // Call our lighting task
       set_task(0.1, "flare_lighting", 2800, params, sizeof params)
      }
      else
      {
       // Delay the explosion ntil we hit ground
       set_pev(entity, pev_dmgtime, get_gametime() + 0.5)
       return HAM_IGNORED;
      }
     }
     default: return HAM_IGNORED;
    }
       
    return HAM_SUPERCEDE;
}
public flare_lighting(args[5])
{
    // Unexistant flare entity?
    if (!pev_valid(FLARE_ENTITY))
     return;
       
    // Flare depleted -clean up the mess-
    if (FLARE_DURATION <= 0)
    {
     engfunc(EngFunc_RemoveEntity, FLARE_ENTITY)
     return;
    }
       
    // Get origin
    static Float:originF[3]
    pev(FLARE_ENTITY, pev_origin, originF)
       
    // Lighting
    engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, originF, 0)
    write_byte(TE_DLIGHT) // TE id
    engfunc(EngFunc_WriteCoord, originF[0]) // x
    engfunc(EngFunc_WriteCoord, originF[1]) // y
    engfunc(EngFunc_WriteCoord, originF[2]) // z
    write_byte(get_pcvar_nu(cvar_flaresize)) // radius
    write_byte(FLARE_R) // r
    write_byte(FLARE_G) // g
    write_byte(FLARE_B) // b
    write_byte(51) //life
    write_byte((FLARE_DURATION < 2) ? 3 : 0) //decay rate
    message_end()
       
    // Sparks
    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
    write_byte(TE_SPARKS) // TE id
    engfunc(EngFunc_WriteCoord, originF[0]) // x
    engfunc(EngFunc_WriteCoord, originF[1]) // y
    engfunc(EngFunc_WriteCoord, originF[2]) // z
    message_end()
       
    // Decrease task cycle counter
    FLARE_DURATION -= 1;
       
    // Keep sending flare messaegs
    set_task(5.0, "flare_lighting", 2800, args, sizeof args)
}
-------------------------------------------------------

Last edited by Samsoniq; 05-07-2010 at 05:48.
Samsoniq is offline
 



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 03:37.


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