Raised This Month: $ Target: $400
 0% 

Smoke Flare


Post New Thread Reply   
 
Thread Tools Display Modes
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
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 05-05-2010 , 17:37   Re: Smoke Flare
Reply With Quote #2

you should add [code] or [php] tags around your code. Is much easier to read.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Samsoniq
Junior Member
Join Date: May 2010
Old 05-05-2010 , 17:42   Re: Smoke Flare
Reply With Quote #3

Quote:
Originally Posted by drekes View Post
you should add [code] or [php] tags around your code. Is much easier to read.
Sorry , please.
I here
first
Samsoniq is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 05-05-2010 , 18:38   Re: Smoke Flare
Reply With Quote #4

Quote:
Originally Posted by Samsoniq View Post
Sorry , please.
I here
first
No problem, but edit your first post, add the tags so it is indented and easier to read
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 05-05-2010 , 19:51   Re: Smoke Flare
Reply With Quote #5

if you are glowing players, you can use this.

PHP Code:
public plugin_init()
{
    
RegisterHam(Ham_Spawn"player""Event_PlayerSpawn"1)
}

public 
Event_PlayerSpawn(id)
{
    if(!
is_user_connected(id))
        return 
PLUGIN_HANDLED

    fm_set_user_rendering
(id)

    return 
PLUGIN_HANDLED

these are
PHP Code:
[php
[/php] i prefer these
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Samsoniq
Junior Member
Join Date: May 2010
Old 05-06-2010 , 00:24   Re: Smoke Flare
Reply With Quote #6

The one who threw the grenade glows in the next round
Samsoniq is offline
Leon M.
Senior Member
Join Date: Apr 2009
Location: Germany
Old 05-06-2010 , 00:54   Re: Smoke Flare
Reply With Quote #7

Remove the task flare_ligthning on roundstart.
Leon M. is offline
Samsoniq
Junior Member
Join Date: May 2010
Old 05-06-2010 , 07:25   Re: Smoke Flare
Reply With Quote #8

Quote:
Originally Posted by Leon M. View Post
Remove the task flare_ligthning on roundstart.
public event_round_start()
{
remove_task(????????)
return;
}
so? )

Last edited by Samsoniq; 05-06-2010 at 07:44.
Samsoniq is offline
Leon M.
Senior Member
Join Date: Apr 2009
Location: Germany
Old 05-06-2010 , 08:16   Re: Smoke Flare
Reply With Quote #9

Quote:
Originally Posted by Samsoniq View Post
set_task(0.1, "flare_lighting", 2800, params, sizeof params)
PHP Code:
public event_round_start(){
     
remove_task(2800)
     return 
PLUGIN_CONTINUE
 

Try this!
Leon M. is offline
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 05-06-2010 , 10:41   Re: Smoke Flare
Reply With Quote #10

Although you have copy pasted the code from zombie_plague40.sma , you should atleast change this:
PHP Code:
const NADE_TYPE_FLARE 4444 
to some thing different bcoz it will make conflicts with the Zombie plague plugin
you can change it to something like this:
PHP Code:
const NADE_TYPE_FLARE 5555 
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
Reply



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