Raised This Month: $51 Target: $400
 12% 

zp50_effects_lighting on/off


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
C.Ronaldo
Senior Member
Join Date: Dec 2014
Old 12-27-2014 , 03:26   zp50_effects_lighting on/off
Reply With Quote #1

Hello guys , i need some help , all know this bomb lights on server zombie and some players got by this bomb low fps , how we can do like that , if you say : /lights you will see all bombs lights off and if you say it again you will see all bombs lights on , you can see on pics.


PHP Code:
/*================================================================================
    
    ---------------------------
    -*- [ZP] Grenade: Flare -*-
    ---------------------------
    
    This plugin is part of Zombie Plague Mod and is distributed under the
    terms of the GNU General Public License. Check ZP_ReadMe.txt for details.
    
================================================================================*/

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <amx_settings_api>
#include <cs_weap_models_api>
#include <zp50_core>

// Settings file
new const ZP_SETTINGS_FILE[] = "zombieplague.ini"

// Default sounds
new const sound_grenade_flare_explode[][] = { "items/nvg_on.wav" }

#define MODEL_MAX_LENGTH 64
#define SOUND_MAX_LENGTH 64
#define SPRITE_MAX_LENGTH 64

// Models
new g_model_grenade_flare[MODEL_MAX_LENGTH] = "models/zombie_plague/v_grenade_flare.mdl"

// Sprites
new g_sprite_grenade_trail[SPRITE_MAX_LENGTH] = "sprites/laserbeam.spr"

new Array:g_sound_grenade_flare_explode

// HACK: pev_ field used to store custom nade types and their values
const PEV_NADE_TYPE pev_flTimeStepSound
const NADE_TYPE_FLARE 4444
const PEV_FLARE_COLOR pev_punchangle
const PEV_FLARE_DURATION pev_flSwimTime

new g_trailSpr

new cvar_grenade_flare_durationcvar_grenade_flare_radiuscvar_grenade_flare_color

public plugin_init()
{
    
register_plugin("[ZP] Grenade: Flare"ZP_VERSION_STRING"ZP Dev Team")
    
    
register_forward(FM_SetModel"fw_SetModel")
    
RegisterHam(Ham_Think"grenade""fw_ThinkGrenade")
    
    
cvar_grenade_flare_duration register_cvar("zp_grenade_flare_duration""60")
    
cvar_grenade_flare_radius register_cvar("zp_grenade_flare_radius""25")
    
cvar_grenade_flare_color register_cvar("zp_grenade_flare_color""0")
}

public 
plugin_precache()
{
    
// Initialize arrays
    
g_sound_grenade_flare_explode ArrayCreate(SOUND_MAX_LENGTH1)
    
    
// Load from external file
    
amx_load_setting_string_arr(ZP_SETTINGS_FILE"Sounds""GRENADE FLARE"g_sound_grenade_flare_explode)
    
    
// If we couldn't load custom sounds from file, use and save default ones
    
new index
    
if (ArraySize(g_sound_grenade_flare_explode) == 0)
    {
        for (
index 0index sizeof sound_grenade_flare_explodeindex++)
            
ArrayPushString(g_sound_grenade_flare_explodesound_grenade_flare_explode[index])
        
        
// Save to external file
        
amx_save_setting_string_arr(ZP_SETTINGS_FILE"Sounds""GRENADE FLARE"g_sound_grenade_flare_explode)
    }
    
    
// Load from external file, save if not found
    
if (!amx_load_setting_string(ZP_SETTINGS_FILE"Weapon Models""GRENADE FLARE"g_model_grenade_flarecharsmax(g_model_grenade_flare)))
        
amx_save_setting_string(ZP_SETTINGS_FILE"Weapon Models""GRENADE FLARE"g_model_grenade_flare)
    if (!
amx_load_setting_string(ZP_SETTINGS_FILE"Grenade Sprites""TRAIL"g_sprite_grenade_trailcharsmax(g_sprite_grenade_trail)))
        
amx_save_setting_string(ZP_SETTINGS_FILE"Grenade Sprites""TRAIL"g_sprite_grenade_trail)
    
    
// Precache models
    
precache_model(g_model_grenade_flare)
    
g_trailSpr precache_model(g_sprite_grenade_trail)
}

public 
zp_fw_core_cure_post(idattacker)
{
    
// Set custom grenade model
    
cs_set_player_view_model(idCSW_SMOKEGRENADEg_model_grenade_flare)
}

public 
zp_fw_core_infect(idattacker)
{
    
// Remove custom grenade model
    
cs_reset_player_view_model(idCSW_SMOKEGRENADE)
}

// Forward Set Model
public fw_SetModel(entity, const model[])
{
    
// We don't care
    
if (strlen(model) < 8)
        return;
    
    
// Narrow down our matches a bit
    
if (model[7] != 'w' || model[8] != '_')
        return;
    
    
// Get damage time of grenade
    
static Float:dmgtime
    pev
(entitypev_dmgtimedmgtime)
    
    
// Grenade not yet thrown
    
if (dmgtime == 0.0)
        return;
    
    
// Grenade's owner is zombie?
    
if (zp_core_is_zombie(pev(entitypev_owner)))
        return;
    
    
// Smoke Grenade
    
if (model[9] == 's' && model[10] == 'm')
    {
        
// Build flare's color
        
static rgb[3]
        switch (
get_pcvar_num(cvar_grenade_flare_color))
        {
            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] = // g
                
rgb[2] = // b
            
}
            case 
2// green
            
{
                
rgb[0] = // r
                
rgb[1] = random_num(50,255// g
                
rgb[2] = // b
            
}
            case 
3// blue
            
{
                
rgb[0] = // r
                
rgb[1] = // 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(13))
                {
                    case 
1// red
                    
{
                        
rgb[0] = random_num(50,255// r
                        
rgb[1] = // g
                        
rgb[2] = // b
                    
}
                    case 
2// green
                    
{
                        
rgb[0] = // r
                        
rgb[1] = random_num(50,255// g
                        
rgb[2] = // b
                    
}
                    case 
3// blue
                    
{
                        
rgb[0] = // r
                        
rgb[1] = // g
                        
rgb[2] = random_num(50,255// b
                    
}
                }
            }
        }
        
        
// Give it a glow
        
fm_set_rendering(entitykRenderFxGlowShellrgb[0], rgb[1], rgb[2], kRenderNormal16);
        
        
// And a colored trail
        
message_begin(MSG_BROADCASTSVC_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(entityPEV_NADE_TYPENADE_TYPE_FLARE)
        
        
// Set flare color on the thrown grenade entity
        
set_pev(entityPEV_FLARE_COLORrgb)
    }
}

// Ham Grenade Think Forward
public fw_ThinkGrenade(entity)
{
    
// Invalid entity
    
if (!pev_valid(entity)) return HAM_IGNORED;
    
    
// Get damage time of grenade
    
static Float:dmgtime
    pev
(entitypev_dmgtimedmgtime)
    
    new 
Float:current_time get_gametime()
    
    
// Check if it's time to go off
    
if (dmgtime current_time)
        return 
HAM_IGNORED;
    
    
// Check if it's one of our custom nades
    
switch (pev(entityPEV_NADE_TYPE))
    {
        case 
NADE_TYPE_FLARE// Flare
        
{
            
// Get its duration
            
new duration pev(entityPEV_FLARE_DURATION)
            
            
// Already went off, do lighting loop for the duration of PEV_FLARE_DURATION
            
if (duration 0)
            {
                
// Check whether this is the last loop
                
if (duration == 1)
                {
                    
// Get rid of the flare entity
                    
engfunc(EngFunc_RemoveEntityentity)
                    return 
HAM_SUPERCEDE;
                }
                
                
// Light it up!
                
flare_lighting(entityduration)
                
                
// Set time for next loop
                
set_pev(entityPEV_FLARE_DURATION, --duration)
                
set_pev(entitypev_dmgtimecurrent_time 2.0)
            }
            
// Light up when it's stopped on ground
            
else if ((pev(entitypev_flags) & FL_ONGROUND) && fm_get_speed(entity) < 10)
            {
                
// Flare sound
                
static sound[SOUND_MAX_LENGTH]
                
ArrayGetString(g_sound_grenade_flare_exploderandom_num(0ArraySize(g_sound_grenade_flare_explode) - 1), soundcharsmax(sound))
                
emit_sound(entityCHAN_WEAPONsound1.0ATTN_NORM0PITCH_NORM)
                
                
// Set duration and start lightning loop on next think
                
set_pev(entityPEV_FLARE_DURATIONget_pcvar_num(cvar_grenade_flare_duration)/2)
                
set_pev(entitypev_dmgtimecurrent_time 0.1)
            }
            else
            {
                
// Delay explosion until we hit ground
                
set_pev(entitypev_dmgtimecurrent_time 0.5)
            }
        }
    }
    
    return 
HAM_IGNORED;
}

// Flare Lighting Effects
flare_lighting(entityduration)
{
    
// Get origin and color
    
static Float:origin[3], color[3]
    
pev(entitypev_originorigin)
    
pev(entityPEV_FLARE_COLORcolor)
    
    
// Lighting
    
engfunc(EngFunc_MessageBeginMSG_PASSVC_TEMPENTITYorigin0)
    
write_byte(TE_DLIGHT// TE id
    
engfunc(EngFunc_WriteCoordorigin[0]) // x
    
engfunc(EngFunc_WriteCoordorigin[1]) // y
    
engfunc(EngFunc_WriteCoordorigin[2]) // z
    
write_byte(get_pcvar_num(cvar_grenade_flare_radius)) // radius
    
write_byte(color[0]) // r
    
write_byte(color[1]) // g
    
write_byte(color[2]) // b
    
write_byte(21//life
    
write_byte((duration 2) ? 0//decay rate
    
message_end()
    
    
// Sparks
    
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYorigin0)
    
write_byte(TE_SPARKS// TE id
    
engfunc(EngFunc_WriteCoordorigin[0]) // x
    
engfunc(EngFunc_WriteCoordorigin[1]) // y
    
engfunc(EngFunc_WriteCoordorigin[2]) // z
    
message_end()
}

// Set entity's rendering type (from fakemeta_util)
stock fm_set_rendering(entityfx kRenderFxNone255255255render kRenderNormalamount 16)
{
    static 
Float:color[3]
    
color[0] = float(r)
    
color[1] = float(g)
    
color[2] = float(b)
    
    
set_pev(entitypev_renderfxfx)
    
set_pev(entitypev_rendercolorcolor)
    
set_pev(entitypev_rendermoderender)
    
set_pev(entitypev_renderamtfloat(amount))
}

// Get entity's speed (from fakemeta_util)
stock fm_get_speed(entity)
{
    static 
Float:velocity[3]
    
pev(entitypev_velocityvelocity)
    
    return 
floatround(vector_length(velocity));

C.Ronaldo is offline
New.ZM.Life
Veteran Member
Join Date: Sep 2014
Location: Iran
Old 12-27-2014 , 04:11   Re: zp50_effects_lighting on/off
Reply With Quote #2

I suggest you to decrease radius of flare bomb and decrease its color to have low lag and better fps
__________________
PLUGINS

Zombie Plague 5.0 + New Modes

Added NightCrawler Mode to ZP





New.ZM.Life is offline
C.Ronaldo
Senior Member
Join Date: Dec 2014
Old 12-27-2014 , 04:19   Re: zp50_effects_lighting on/off
Reply With Quote #3

no i need i say plz help me , anyways thx
C.Ronaldo is offline
C.Ronaldo
Senior Member
Join Date: Dec 2014
Old 12-27-2014 , 12:38   Re: zp50_effects_lighting on/off
Reply With Quote #4

some one can do it!
C.Ronaldo is offline
New.ZM.Life
Veteran Member
Join Date: Sep 2014
Location: Iran
Old 12-27-2014 , 16:18   Re: zp50_effects_lighting on/off
Reply With Quote #5

I think its impossible because all players can see flare lights and its not ok to disable it just for one player who say /Light
But first,try to change lighting radius and colors
__________________
PLUGINS

Zombie Plague 5.0 + New Modes

Added NightCrawler Mode to ZP





New.ZM.Life is offline
C.Ronaldo
Senior Member
Join Date: Dec 2014
Old 12-27-2014 , 16:30   Re: zp50_effects_lighting on/off
Reply With Quote #6

no no , if you say /lights it's will disable but me will not disable on me , just will disable on you only.
C.Ronaldo is offline
C.Ronaldo
Senior Member
Join Date: Dec 2014
Old 12-28-2014 , 09:04   Re: zp50_effects_lighting on/off
Reply With Quote #7

plz help me
C.Ronaldo is offline
C.Ronaldo
Senior Member
Join Date: Dec 2014
Old 12-31-2014 , 13:23   Re: zp50_effects_lighting on/off
Reply With Quote #8

need help here.
C.Ronaldo is offline
C.Ronaldo
Senior Member
Join Date: Dec 2014
Old 09-22-2015 , 11:30   Re: zp50_effects_lighting on/off
Reply With Quote #9

any one?
C.Ronaldo is offline
Chihuahuax
Senior Member
Join Date: Oct 2014
Location: Malaysia
Old 09-22-2015 , 12:20   Re: zp50_effects_lighting on/off
Reply With Quote #10

Take this for reference (see how connor codes the toggle for players)
https://forums.alliedmods.net/showthread.php?t=62224
Chihuahuax is offline
Send a message via Skype™ to Chihuahuax
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 19:15.


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