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

Grenade explosion lighting


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 04-09-2023 , 14:32   Grenade explosion lighting
Reply With Quote #1

Hello, im trying to create a lighting for HE grenade explosion, i think im doing this wrong, could someone help?

PHP Code:
#include < amxmodx >
#include < amxmisc >
#include <fakemeta> 

public plugin_init()
{
    
register_plugin("Dynamic Light Grenade Explosion""""");
    
register_event("Explosion""OnGrenadeExplosion""ai");
}

public 
OnGrenadeExplosion(attackerentityweapon)
{
    if (
weapon == CSW_HEGRENADE)
    {
    static 
FloatoriginF[3]
    
pev(entitypev_originoriginF);
    
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY);
    
write_byte(TE_EXPLOSION);
    
engfunc(EngFunc_WriteCoordoriginF[0]);
    
engfunc(EngFunc_WriteCoordoriginF[1]);
    
engfunc(EngFunc_WriteCoordoriginF[2]);
    
write_byte(30);
    
write_byte(15);
    
write_byte(0);
    
message_end();
    }

HowToRuski is offline
thEsp
BANNED
Join Date: Aug 2017
Old 04-11-2023 , 05:21   Re: Grenade explosion lighting
Reply With Quote #2

That event doesn't exist. You should hook grenade's thinking, check if it's about to explode (pev_dmgtime) and just before it does (1 frame maybe) add your effects.
thEsp is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 04-11-2023 , 12:50   Re: Grenade explosion lighting
Reply With Quote #3

Quote:
Originally Posted by Silencer123 View Post
Include:
#include <hamsandwich>

In plugin_init():
RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")

Somewhere else:
public fw_ThinkGrenade(entity) {
// [...]
}

Taken from: http://forums.alliedmods.net/showthread.php?t=74905
Found in 10 Seconds with the Forums' search function. D;
Note that the above is not the whole secret. Conduct your own research on the plugin linked to above. ;)
__________________
mlibre is offline
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 04-14-2023 , 11:36   Re: Grenade explosion lighting
Reply With Quote #4

Im currently using this script, however it does not work..
Anyone with recommendations?

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

new color_cvarradius_cvar;

public 
plugin_init()
{
    
RegisterHam(Ham_Think"grenade""fw_ThinkGrenade")

    
color_cvar register_cvar("hex_color","255 255 255");
    
radius_cvar register_cvar("fbl_radius","50");
}

#define cm(%0)    ( sizeof(%0) - 1 )

const m_bIsC4 385;
const 
m_usEvent_Grenade 228;

public 
fw_ThinkGrenade(playernade)
{
if( 
is_user_alive(player) && GetGrenadeType(nade) == CSW_HEGRENADE )
{
hegrenade_explode(nade);
}
}

GetGrenadeTypeentbool:bCheckClass true )
{
    if( 
bCheckClass )
    {
        new class[
9];
        
pev(entpev_classname, class, charsmax(class));
        if( !
equal(class, "grenade") )
        {
            return 
0;
        }
    }

    if( 
get_pdata_bool(entm_bIsC4) )
    {
        return 
CSW_C4;
    }

    new 
usEvent get_pdata_short(entm_usEvent_Grenade);
    if( !
usEvent )
    {
        return 
CSW_HEGRENADE;
    }

    static 
m_usHgrenExplo// , m_usSmokeExplo
    
if( !m_usHgrenExplo )
    {
        
m_usHgrenExplo engfunc(EngFunc_PrecacheEvent1"events/createexplo.sc");
        
// m_usSmokeExplo = engfunc(EngFunc_PrecacheEvent, 1, "events/createsmoke.sc");
    
}

    return 
usEvent == m_usHgrenExplo CSW_HEGRENADE CSW_SMOKEGRENADE;
}

public 
hegrenade_explode(greindex)
 {
    
// invalid entity
    
if(!pev_valid(greindex)) return;

    
// get origin of explosion
    
new Float:origin[3];
    
pev(greindex,pev_origin,origin);

    
// get color from cvar
    
new color[16];
    
get_pcvar_string(color_cvar,color,15);

    
// 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();
 } 
HowToRuski is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 04-28-2023 , 17:48   Re: Grenade explosion lighting
Reply With Quote #5

Quote:
Originally Posted by HowToRuski View Post
Im currently using this script, however it does not work..
Anyone with recommendations?

Spoiler
proof

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <engine>
#include <fakemeta>

new color_cvarradius_cvar;

public 
plugin_init() 
{
    
RegisterHam(Ham_Think"grenade""fw_ThinkGrenade")
    
    
color_cvar register_cvar("hex_color","255 255 255");
    
radius_cvar register_cvar("fbl_radius","50");
}

public 
fw_ThinkGrenade(ent)
{
    if(
entity_get_float(entEV_FL_dmgtime) >= get_gametime()) 
        return 
HAM_IGNORED
        
    
if( !IsHeGrenade(ent) ) 
        return 
HAM_IGNORED
        
    
// 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();
    
    return 
HAM_IGNORED
}

stock IsHeGrenadeent

    new const 
m_bIsC4 385
    
new const m_usEvent_Grenade 228
    
    
if( get_pdata_bool(entm_bIsC4) ) 
    { 
        return 
0
    

    
    new 
usEvent get_pdata_short(entm_usEvent_Grenade

    static 
m_usHgrenExplo
    
if( !m_usHgrenExplo 
    { 
        
m_usHgrenExplo engfunc(EngFunc_PrecacheEvent1"events/createexplo.sc"
    } 
    
    return 
usEvent == m_usHgrenExplo 0


#if AMXX_VERSION_NUM < 183

#define SHORT_BYTES    2 
#define INT_BYTES    4 
#define BYTE_BITS    8 

stock bool:get_pdata_bool(entcharbased_offsetintbase_linuxdiff 5

    return !!( 
get_pdata_int(entcharbased_offset INT_BYTESintbase_linuxdiff) & (0xFF<<((charbased_offset INT_BYTES) * BYTE_BITS)) ) 

stock get_pdata_short(entshortbased_offsetintbase_linuxdiff 5

    return ( 
get_pdata_int(entshortbased_offset SHORT_BYTESintbase_linuxdiff)>>>((shortbased_offset SHORT_BYTES) * BYTE_BITS) ) & 0xFFFF 

#endif 
__________________
mlibre is offline
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 04-29-2023 , 02:29   Re: Grenade explosion lighting
Reply With Quote #6

Quote:
Originally Posted by mlibre View Post
proof

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <engine>
#include <fakemeta>

new color_cvarradius_cvar;

public 
plugin_init() 
{
    
RegisterHam(Ham_Think"grenade""fw_ThinkGrenade")
    
    
color_cvar register_cvar("hex_color","255 255 255");
    
radius_cvar register_cvar("fbl_radius","50");
}

public 
fw_ThinkGrenade(ent)
{
    if(
entity_get_float(entEV_FL_dmgtime) >= get_gametime()) 
        return 
HAM_IGNORED
        
    
if( !IsHeGrenade(ent) ) 
        return 
HAM_IGNORED
        
    
// 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();
    
    return 
HAM_IGNORED
}

stock IsHeGrenadeent

    new const 
m_bIsC4 385
    
new const m_usEvent_Grenade 228
    
    
if( get_pdata_bool(entm_bIsC4) ) 
    { 
        return 
0
    

    
    new 
usEvent get_pdata_short(entm_usEvent_Grenade

    static 
m_usHgrenExplo
    
if( !m_usHgrenExplo 
    { 
        
m_usHgrenExplo engfunc(EngFunc_PrecacheEvent1"events/createexplo.sc"
    } 
    
    return 
usEvent == m_usHgrenExplo 0


#if AMXX_VERSION_NUM < 183

#define SHORT_BYTES    2 
#define INT_BYTES    4 
#define BYTE_BITS    8 

stock bool:get_pdata_bool(entcharbased_offsetintbase_linuxdiff 5

    return !!( 
get_pdata_int(entcharbased_offset INT_BYTESintbase_linuxdiff) & (0xFF<<((charbased_offset INT_BYTES) * BYTE_BITS)) ) 

stock get_pdata_short(entshortbased_offsetintbase_linuxdiff 5

    return ( 
get_pdata_int(entshortbased_offset SHORT_BYTESintbase_linuxdiff)>>>((shortbased_offset SHORT_BYTES) * BYTE_BITS) ) & 0xFFFF 

#endif 
Thanks. Did it work for you? Because for me still not...

Last edited by HowToRuski; 04-29-2023 at 02:29.
HowToRuski is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-29-2023 , 06:39   Re: Grenade explosion lighting
Reply With Quote #7

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <engine>
#include <fakemeta>

new color_cvarradius_cvar;

public 
plugin_init() 
{
    
RegisterHam(Ham_Think"grenade""fw_ThinkGrenade")
    
    
color_cvar register_cvar("hex_color","255 255 255");
    
radius_cvar register_cvar("fbl_radius","50");
}

public 
fw_ThinkGrenade(ent)
{
    if(
entity_get_float(entEV_FL_dmgtime) > get_gametime()) 
        return 
HAM_IGNORED
        
    
if( !IsHeGrenade(ent) ) 
        return 
HAM_IGNORED
        
    
// 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();
    
    return 
HAM_IGNORED
}

stock IsHeGrenadeent

    new const 
m_bIsC4 385
    
new const m_usEvent_Grenade 228
    
    
if( get_pdata_bool(entm_bIsC4) ) 
    { 
        return 
0
    

    
    new 
usEvent get_pdata_short(entm_usEvent_Grenade

    static 
m_usHgrenExplo
    
if( !m_usHgrenExplo 
    { 
        
m_usHgrenExplo engfunc(EngFunc_PrecacheEvent1"events/createexplo.sc"
    } 
    
    return 
usEvent == m_usHgrenExplo 0


#if AMXX_VERSION_NUM < 183

#define SHORT_BYTES    2 
#define INT_BYTES    4 
#define BYTE_BITS    8 

stock bool:get_pdata_bool(entcharbased_offsetintbase_linuxdiff 5

    return !!( 
get_pdata_int(entcharbased_offset INT_BYTESintbase_linuxdiff) & (0xFF<<((charbased_offset INT_BYTES) * BYTE_BITS)) ) 

stock get_pdata_short(entshortbased_offsetintbase_linuxdiff 5

    return ( 
get_pdata_int(entshortbased_offset SHORT_BYTESintbase_linuxdiff)>>>((shortbased_offset SHORT_BYTES) * BYTE_BITS) ) & 0xFFFF 

#endif 
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 04-29-2023 at 06:56.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 05-01-2023 , 10:13   Re: Grenade explosion lighting
Reply With Quote #9

I dont know, its not working for me on Steamed cs, its not like its missing those files, cs even wouldnt launch then, maybe thats because im on amxx 1.9?
HowToRuski is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 05-01-2023 , 15:00   Re: Grenade explosion lighting
Reply With Quote #10

maybe it shouldn't, i tried it in 182
__________________
mlibre is offline
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 05:35.


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