View Single Post
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 04-29-2023 , 07:46   Re: Grenade explosion lighting
Reply With Quote #8

Quote:
Originally Posted by HowToRuski View Post
Thanks. Did it work for you? Because for me still not...
yes also in this way

PHP Code:
public plugin_init() 
{
    
register_forward(FM_EmitSound"fw_emit_sound_post"1)
    
    
//..
}

public 
fw_emit_sound_post(entchannel, const sample[])
{
    for(new 
i;3;i++) 
    {
        static 
eSound[20]; formatex(eSoundcharsmax(eSound), "weapons/debris%d.wav"i+1)
        
        if(
equal(sampleeSound))
        {
            if( !
IsHeGrenade(ent) ) 
                return 
FMRES_IGNORED
                
            GrenadeExploded
(ent)
        }
    }
    
    return 
FMRES_IGNORED
}

stock GrenadeExploded(ent)
{
    
// get origin of explosion
    
new Float:origin[3];
    
//pev(greindex,pev_origin,origin);
    
entity_get_vector(entEV_VEC_originorigin)
    
    
// get color from cvar
    
new color[16];
    
get_pcvar_string(color_cvar,color,charsmax(color));

    
// split it into red, green, blue
    
new redamt[5], greenamt[5], blueamt[5];
    
parse(color,redamt,4,greenamt,4,blueamt,4);
    
    
// send the light flash
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
    
write_byte(27); // TE_DLIGHT
    
write_coord(floatround(origin[0])); // x
    
write_coord(floatround(origin[1])); // y
    
write_coord(floatround(origin[2])); // z
    
write_byte(get_pcvar_num(radius_cvar)); // radius
    
write_byte(str_to_num(redamt));    // r
    
write_byte(str_to_num(greenamt)); // g
    
write_byte(str_to_num(blueamt)); // b
    
write_byte(8); // life
    
write_byte(60); // decay rate
    
message_end();

__________________
mlibre is offline