AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Smoke Flare (https://forums.alliedmods.net/showthread.php?t=126124)

Samsoniq 05-05-2010 17:31

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

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)
}
-------------------------------------------------------


drekes 05-05-2010 17:37

Re: Smoke Flare
 
you should add [code] or [php] tags around your code. Is much easier to read.

Samsoniq 05-05-2010 17:42

Re: Smoke Flare
 
Quote:

Originally Posted by drekes (Post 1171835)
you should add [code] or [php] tags around your code. Is much easier to read.

Sorry , please.
I here
first :)

drekes 05-05-2010 18:38

Re: Smoke Flare
 
Quote:

Originally Posted by Samsoniq (Post 1171846)
Sorry , please.
I here
first :)

No problem, but edit your first post, add the tags so it is indented and easier to read

drekes 05-05-2010 19:51

Re: Smoke Flare
 
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

Samsoniq 05-06-2010 00:24

Re: Smoke Flare
 
The one who threw the grenade glows in the next round :cry:

Leon M. 05-06-2010 00:54

Re: Smoke Flare
 
Remove the task flare_ligthning on roundstart.

Samsoniq 05-06-2010 07:25

Re: Smoke Flare
 
Quote:

Originally Posted by Leon M. (Post 1172205)
Remove the task flare_ligthning on roundstart.

public event_round_start()
{
remove_task(????????)
return;
}
so? )

Leon M. 05-06-2010 08:16

Re: Smoke Flare
 
Quote:

Originally Posted by Samsoniq (Post 1172383)
set_task(0.1, "flare_lighting", 2800, params, sizeof params)

PHP Code:

public event_round_start(){
     
remove_task(2800)
     return 
PLUGIN_CONTINUE
 


Try this!

Samsoniq 05-06-2010 08:30

Re: Smoke Flare
 
Quote:

Originally Posted by Leon M. (Post 1172434)
PHP Code:

public event_round_start(){
     
remove_task(2800)
     return 
PLUGIN_CONTINUE
 


Try this!

no :cry:


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

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