Raised This Month: $ Target: $400
 0% 

It's possible to make this?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 08-24-2013 , 18:39   It's possible to make this?
Reply With Quote #1

Hi everybody, well some people help me to edit a plugin of zombie called flare nade serving to illuminate ,well i adding a say when a player type /lights he can turn off the flare and if player type /lights again the flare turn on again and the same history, well this is my question is possible for example when a player say lights all own flare nades including the flares of the other players turn off but only on his screem i mean single (the other people can see the lights only the person who wrote lights affects) and same with turn on, if is possible can someone tell me how i can do this?... thx in advance

Last edited by wicho; 08-24-2013 at 18:48.
wicho is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 09-07-2013 , 16:17   Re: It's possible to make this?
Reply With Quote #2

BUMP, someone know?
wicho is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-07-2013 , 16:23   Re: It's possible to make this?
Reply With Quote #3

If the plugin uses SVC_TEMPENTITY message, instead of sending MSG_ALL or MSG_BROADCAST, loop through all players sending MSG_ONE or MSG_ONE_UNRELIABLE, and send thos messages only to players who should see lights.

If those lights are real entities with pev_effects or EV_INT_effects set on, then you have to hook FM_AddToFullPack and to alter ES_Effects when those entities are passed to players.


Note : You were a bit short to bump your thread, rules say "no bump/double post", it is tolerated after 15 days though, not 13 as you did.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 09-07-2013 at 16:24.
ConnorMcLeod is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 09-07-2013 , 16:54   Re: It's possible to make this?
Reply With Quote #4

Ok sorry for that, can u help to add since i never work with fullpack..

This is the code:

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <amx_settings_api>
#include <cs_weap_models_api>
#include <zp50_core>
#include <colorchat> 

// 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

new bool:g_bajaluz[33

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")
    
    
register_clcmd("say /lights""bajarluz")
}

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

public 
bajarluz(id

    if (!
g_bajaluz[id]) 
    { 
        
g_bajaluz[id] = true  
        
    

    
    else 
    
    { 
       
g_bajaluz[id] = false 
      
    




// 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
                    
g_bajaluz[pev(entitypev_owner)] = false 
                    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
    
if (g_bajaluz[pev(entitypev_owner)]) 
              
write_byte(2
         else 
         
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));

wicho is offline
Old 09-07-2013, 17:56
akcaliberg
This message has been deleted by akcaliberg.
akcaliberg
Senior Member
Join Date: Nov 2011
Location: Istanbul
Old 09-07-2013 , 18:27   Re: It's possible to make this?
Reply With Quote #5

The lights are message, I think you can't do this with addtofullpack. You should do the first thing that Connor said.

PHP Code:
#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 

new bool:g_bajaluz[33]
new 
boolflare_disabled[33]

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"
    
    
register_clcmd("say /lights""bajarluz"


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


public 
bajarluz(id)  
{      
    
g_bajaluz[id] = g_bajaluz[id] ? false true
    flare_disabled
[id] = flare_disabled[id] ? false true
}  

// 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 
                    
g_bajaluz[pev(entitypev_owner)] = false  
                    engfunc
(EngFunc_RemoveEntityentity
                    return 
HAM_SUPERCEDE
                } 
                
                
// Light it up! 
                
                
static players[32], inum;
                
get_players(players,inum)
                for(new 
ii<inum ;i++) {
                    if(
is_user_connected(players[i]) && !flare_disabled[players[i]]) {
                        
flare_lighting(players[i], 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(identityduration) {
    
    
// Get origin and color 
    
static Float:origin[3], color[3
    
pev(entitypev_originorigin
    
pev(entityPEV_FLARE_COLORcolor
    
    
// Lighting 
    
engfunc(EngFunc_MessageBeginMSG_ONE_UNRELIABLESVC_TEMPENTITYoriginid
    
write_byte(TE_DLIGHT// TE id 
    
engfunc(EngFunc_WriteCoordorigin[0]) // x 
    
engfunc(EngFunc_WriteCoordorigin[1]) // y 
    
engfunc(EngFunc_WriteCoordorigin[2]) // z 
    
if (g_bajaluz[pev(entitypev_owner)])  
        
write_byte(2)  
    else  
        
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_ONE_UNRELIABLESVC_TEMPENTITYoriginid
    
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)); 

try this.

Last edited by akcaliberg; 09-07-2013 at 19:25.
akcaliberg is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-07-2013 , 18:59   Re: It's possible to make this?
Reply With Quote #6

Quote:
Originally Posted by akcaliberg View Post
The lights are message, I think you can't do this with addtofullpack. You should do the first thing that Connor said.

try this.
Don't loop players this way, use get_players so you don't need to call is_user_connected when you loop.
Other than that, seems correct.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 09-07-2013 at 19:00.
ConnorMcLeod is offline
akcaliberg
Senior Member
Join Date: Nov 2011
Location: Istanbul
Old 09-07-2013 , 19:22   Re: It's possible to make this?
Reply With Quote #7

Quote:
Originally Posted by ConnorMcLeod View Post
Don't loop players this way, use get_players so you don't need to call is_user_connected when you loop.
Other than that, seems correct.
Yes, I always use get_players for player loops but I was thinking get_players slower than is_user_connected. I noticed that will call the native 32 times when you said.
Thanks for correction.
I edited the code.

Is there something wrong with using static for these:

static players[32],inum

I think that will be faster since fw_ThinkGrenade is being called so often. Is that correct ?

Last edited by akcaliberg; 09-07-2013 at 19:30.
akcaliberg is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 09-09-2013 , 03:42   Re: It's possible to make this?
Reply With Quote #8

Work but i have a problem, for example when i have enabled my lights others players can control my lights when they type /lights, same with me if i type /lights and the others players have enabled the lights i can control his lights, with disable work fine i mean if i have disabled the lights the other players when they type /lights they cant control my lights just work for me, can someone tell me why happen this?

this is the code:

PHP Code:
#include <amxmodx> 
#include <fakemeta> 
#include <hamsandwich> 
#include <amx_settings_api> 
#include <cs_weap_models_api> 
#include <zp50_core> 
#include <colorchat> 

// 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 

new bool:g_bajaluz[33]  
new 
iMaxPlayers;
new 
boolflare_disabled[33]

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"
    
    
iMaxPlayers get_maxplayers()
    
    
register_clcmd("say /lights""bajarluz"


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


public 
bajarluz(id)  
{      
    
    if (!
g_bajaluz[id] && !flare_disabled[id]) 
    { 
        
g_bajaluz[id] = true  
        flare_disabled
[id] = true 
        ColorChat
(idTEAM_COLOR"^x04 ZP |^x01 You have disabled lighting!")
    } 
    
    else 
    
    { 
       
g_bajaluz[id] = false 
       flare_disabled
[id] = false 
       ColorChat
(idTEAM_COLOR"^x04 ZP |^x01 You have enabled lighting!")
    } 
    

 
// 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 
                    
g_bajaluz[pev(entitypev_owner)] = false  
                    engfunc
(EngFunc_RemoveEntityentity
                    return 
HAM_SUPERCEDE
                } 
                
                
// Light it up!                
                
for(new i=1i<=iMaxPlayers ;i++) 
           {
                    if(
is_user_connected(i) && !flare_disabled[i]) 
          {
                        
flare_lighting(ientityduration
                    }
                }
                          
                
// 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(identityduration
{
    
    
// Get origin and color 
    
static Float:origin[3], color[3
    
pev(entitypev_originorigin
    
pev(entityPEV_FLARE_COLORcolor
    
    
// Lighting 
    
engfunc(EngFunc_MessageBeginMSG_ONE_UNRELIABLESVC_TEMPENTITYoriginid
    
write_byte(TE_DLIGHT// TE id 
    
engfunc(EngFunc_WriteCoordorigin[0]) // x 
    
engfunc(EngFunc_WriteCoordorigin[1]) // y 
    
engfunc(EngFunc_WriteCoordorigin[2]) // z 
    
if (g_bajaluz[pev(entitypev_owner)])  
        
write_byte(2)  
    else  
        
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_ONE_UNRELIABLESVC_TEMPENTITYoriginid
    
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)); 


Last edited by wicho; 09-09-2013 at 03:44.
wicho is offline
akcaliberg
Senior Member
Join Date: Nov 2011
Location: Istanbul
Old 09-09-2013 , 09:15   Re: It's possible to make this?
Reply With Quote #9

I think g_bajaluz variable changing regardless of user control. Change that check:

if (!g_bajaluz[id] && !flare_disabled[id])

to

if (!flare_disabled[id])

plus as connor said, use get_players instead of is_user_connected checks. If you check my code you will see. it's different.
akcaliberg is offline
Old 09-09-2013, 15:53
wicho
This message has been deleted by wicho.
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:02.


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