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(PLUGIN, VERSION, "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(es, e, ent, id, hostflags, player )
{
static bitEffects
if( player
&& ent != id
&& get_orig_retval()
&& (bitEffects = get_es(es, ES_Effects)) & EF_DIMLIGHT )
{
set_es(es, ES_Effects, bitEffects & ~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(id, channel, 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.
|