AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Render flashlight for only that player (https://forums.alliedmods.net/showthread.php?t=183171)

Y060N 04-18-2012 11:29

Render flashlight for only that player
 
When my server is full (zombie server), many people will get FPS lag from others using flashlights. I was wondering if it is possible to only render the flashlight for that specific player using it, rather than have it server wide.

If it is, I was wondering how you'd go about doing that.

Many thanks in advanced.

NiHiLaNTh 04-18-2012 12:14

Re: Render flashlight for only that player
 
I remember that in last version of ZP was a CVAR for a flashlight..I think it was zp_flashlight_show_all 0 or something....

yokomo 04-18-2012 13:26

Re: Render flashlight for only that player
 
Quote:

Originally Posted by Y060N (Post 1691806)
When my server is full (zombie server), many people will get FPS lag from others using flashlights. I was wondering if it is possible to only render the flashlight for that specific player using it, rather than have it server wide.

If it is, I was wondering how you'd go about doing that.

Many thanks in advanced.

Check out my thread, i already made it. It using addtofullpack forward by the way.

ConnorMcLeod 04-20-2012 01:15

Re: Render flashlight for only that player
 
Quote:

Originally Posted by yokomo (Post 1691869)
Check out my thread, i already made it. It using addtofullpack forward by the way.

You forgot to optimize it though.

PHP Code:

#include <amxmodx>
#include <fakemeta>

#define VERSION "0.0.1"
#define PLUGIN "Personal FlashLight"

new g_iMaxPlayers
#define IsPlayer(%0)    ( 1 <= %0 <= g_iMaxPlayers )

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")
    
register_forward(FM_AddToFullPack"AddToFullPack_Post"true)
    
register_forward(FM_EmitSound"EmitSound"false)
    
g_iMaxPlayers get_maxplayers()
}

// int  )            (struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet);
public AddToFullPack_Post(eseentidhostflagsplayer )
{
    static 
bitEffects
    
if(    player
    
&&    ent != id
    
&&    get_orig_retval()
    &&    (
bitEffects get_es(esES_Effects)) & EF_DIMLIGHT    )
    {
        
set_es(esES_EffectsbitEffects & ~EF_DIMLIGHT)
    }
}

//EmitSound(id, CHAN_ITEM, "items/flashlight1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
// void )            (edict_t *entity, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch);
public EmitSound(idchannel, const sample[])
{
    if( 
IsPlayer(id) && channel == CHAN_ITEM && equal(sample"items/flashlight1.wav") )
    {
        
client_cmd(id"spk items/flashlight1.wav")
        return 
FMRES_SUPERCEDE
    
}
    return 
FMRES_IGNORED



yokomo 04-20-2012 03:05

Re: Render flashlight for only that player
 
Quote:

Originally Posted by ConnorMcLeod (Post 1692761)
You forgot to optimize it though.

PHP Code:

#include <amxmodx>
#include <fakemeta>

#define VERSION "0.0.1"
#define PLUGIN "Personal FlashLight"

new g_iMaxPlayers
#define IsPlayer(%0)    ( 1 <= %0 <= g_iMaxPlayers )

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")
    
register_forward(FM_AddToFullPack"AddToFullPack_Post"true)
    
register_forward(FM_EmitSound"EmitSound"false)
    
g_iMaxPlayers get_maxplayers()
}

// int  )            (struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet);
public AddToFullPack_Post(eseentidhostflagsplayer )
{
    static 
bitEffects
    
if(    player
    
&&    ent != id
    
&&    get_orig_retval()
    &&    (
bitEffects get_es(esES_Effects)) & EF_DIMLIGHT    )
    {
        
set_es(esES_EffectsbitEffects & ~EF_DIMLIGHT)
    }
}

//EmitSound(id, CHAN_ITEM, "items/flashlight1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
// void )            (edict_t *entity, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch);
public EmitSound(idchannel, const sample[])
{
    if( 
IsPlayer(id) && channel == CHAN_ITEM && equal(sample"items/flashlight1.wav") )
    {
        
client_cmd(id"spk items/flashlight1.wav")
        return 
FMRES_SUPERCEDE
    
}
    return 
FMRES_IGNORED



Ehhe, because i don't know much about AddToFullPack forward. This forward is a bit tricky. By the way thanks for the full code.

csoldjb 04-22-2012 09:55

Re: Render flashlight for only that player
 
I think you'd better use a module. Use AMXX plugins to hook AddToFullPack may use so much CPU.

naSTR 06-11-2012 10:48

Re: Render flashlight for only that player
 
Quote:

Originally Posted by ConnorMcLeod (Post 1692761)
You forgot to optimize it though.

PHP Code:

#include <amxmodx>
#include <fakemeta>

#define VERSION "0.0.1"
#define PLUGIN "Personal FlashLight"

new g_iMaxPlayers
#define IsPlayer(%0)    ( 1 <= %0 <= g_iMaxPlayers )

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")
    
register_forward(FM_AddToFullPack"AddToFullPack_Post"true)
    
register_forward(FM_EmitSound"EmitSound"false)
    
g_iMaxPlayers get_maxplayers()
}

// int  )            (struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet);
public AddToFullPack_Post(eseentidhostflagsplayer )
{
    static 
bitEffects
    
if(    player
    
&&    ent != id
    
&&    get_orig_retval()
    &&    (
bitEffects get_es(esES_Effects)) & EF_DIMLIGHT    )
    {
        
set_es(esES_EffectsbitEffects & ~EF_DIMLIGHT)
    }
}

//EmitSound(id, CHAN_ITEM, "items/flashlight1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
// void )            (edict_t *entity, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch);
public EmitSound(idchannel, const sample[])
{
    if( 
IsPlayer(id) && channel == CHAN_ITEM && equal(sample"items/flashlight1.wav") )
    {
        
client_cmd(id"spk items/flashlight1.wav")
        return 
FMRES_SUPERCEDE
    
}
    return 
FMRES_IGNORED



Well still have aura from original flashlight

cOMpirm 07-17-2012 03:03

Re: Render flashlight for only that player
 
yeah, not work too


All times are GMT -4. The time now is 07:52.

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