Raised This Month: $32 Target: $400
 8% 

get owner on grenade_explosion is 0?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
loki_himself
Member
Join Date: Nov 2021
Old 09-05-2022 , 14:42   get owner on grenade_explosion is 0?
Reply With Quote #1

...

Last edited by loki_himself; 11-23-2022 at 12:10.
loki_himself is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 09-05-2022 , 18:15   Re: get owner on grenade_explosion is 0?
Reply With Quote #2

Code:
/* Sublime AMXX Editor v2.2 */ #include <amxmodx> // #include <amxmisc> // #include <cstrike> // #include <engine> // #include <fakemeta> #include <hamsandwich> // #include <fun> // #include <xs> // #include <sqlx> #define PLUGIN  "New Plug-In" #define VERSION "1.0" #define AUTHOR  "Author" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     register_event("23", "grenade_explosion", "a");     RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade");     // Add your code here... } public grenade_explosion(ent) {     someFunction(); } public fw_ThinkGrenade() {     someFunction(); } someFunction() {     // Code here }

Or give more info on what you want to do.
__________________

Last edited by Napoleon_be; 09-05-2022 at 18:36.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
loki_himself
Member
Join Date: Nov 2021
Old 09-05-2022 , 19:15   Re: get owner on grenade_explosion is 0?
Reply With Quote #3

...

Last edited by loki_himself; 11-23-2022 at 13:22.
loki_himself is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-05-2022 , 21:47   Re: get owner on grenade_explosion is 0?
Reply With Quote #4

PHP Code:
RegisterHam(Ham_Think"grenade""fw_ThinkGrenade", .Post false)

public 
fw_ThinkGrenade(ent)
{
    static 
Float:fDamageTime;
    
pev(entpev_dmgtimefDamageTime);

    if(
fDamageTime <= get_gametime())
    {
            
GrenadeGoing2Explode(entpev(entpev_owner))
    }
}

GrenadeGoing2Explode(const iGrenade, const thrower)
{


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

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
loki_himself
Member
Join Date: Nov 2021
Old 09-06-2022 , 08:14   Re: get owner on grenade_explosion is 0?
Reply With Quote #5

...

Last edited by loki_himself; 11-23-2022 at 12:49.
loki_himself is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-06-2022 , 08:50   Re: get owner on grenade_explosion is 0?
Reply With Quote #6

Quote:
Originally Posted by loki_himself View Post
thanks i tried exactly that code with the dmgtime before, however it is not the exact moment of explosion. when i create an additional explosion in GrenadeGoing2Explode, then it does not explode at the same time as the regular HE grenade. there is a delay.

additional question. can i attach custom data to a entity? then i could add a grenade type to the ent when it is thrown, and check on explosion what type of grenade it is without needing the owner?
Show your test code.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
loki_himself
Member
Join Date: Nov 2021
Old 09-06-2022 , 09:06   Re: get owner on grenade_explosion is 0?
Reply With Quote #7

i want 1 big explosion with those TE_EXPLOSION. but am i using those wrong? it creates a huge cluster explosion with multiple explosions happening. this dmgtime does not look like a clean way. grenade_explosion() gave me the exact right moment, but no owner. can i store custom data on an entity somehow?

Code:
RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade", .Post = false)

...


public fw_ThinkGrenade(ent)
{
    static Float:fDamageTime;
    pev(ent, pev_dmgtime, fDamageTime);

    if(fDamageTime <= get_gametime())
    {
            client_print(0, print_chat, "%0.3f% %0.3f% %0.3f%", fDamageTime, get_gametime(), fDamageTime-get_gametime())
            GrenadeGoing2Explode(ent, pev(ent, pev_owner))
    }
}

GrenadeGoing2Explode(const iGrenade, const thrower)
{
	static Float:originF[3]
	pev(iGrenade, pev_origin, originF)

	message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
	write_byte(TE_SMOKE);
	write_coord(floatround(originF[0]));			// Position
	write_coord(floatround(originF[1]));
	write_coord(floatround(originF[2]) + random_num(120, 200));
	write_short(g_iSmokeSprite);	// Sprite index
	write_byte(random_num(100, 120));			// Scale
	write_byte(random_num(10, 20));			// Framerate
	message_end();

	message_begin( MSG_BROADCAST, SVC_TEMPENTITY ) 
	write_byte( TE_EXPLOSION ) 
	write_coord( floatround( originF[0] ) ) 
	write_coord( floatround( originF[1] ) ) 
	write_coord( floatround( originF[2] ) ) 
	write_short( explosion1 ) 
	write_byte( 10 )  // was 50
	write_byte( random_num(10, 20) )  // was 15
	write_byte( 0 )
	message_end() 

	message_begin( MSG_BROADCAST, SVC_TEMPENTITY ) 
	write_byte( TE_EXPLOSION ) 
	write_coord( floatround( originF[0] ) ) 
	write_coord( floatround( originF[1] ) ) 
	write_coord( floatround( originF[2] ) ) 
	write_short( explosion2 ) 
	write_byte( 10 ) 
	write_byte( random_num(10, 20) ) 
	write_byte( 0 )
	message_end() 
}



output

Code:
9.005 9.005 -0.000%
9.005 9.105 -0.100%
9.005 9.655 -0.650%




update:

so now im back to using grenade_explosion()but that itself fires like 20 times on explosion. so i guess thats why it creates 20 extra explosions... how to return after 1 execution? i want it to continue handling regular damage, i dont want to stop the event

Last edited by loki_himself; 09-06-2022 at 09:42.
loki_himself is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-06-2022 , 11:12   Re: get owner on grenade_explosion is 0?
Reply With Quote #8

if you want to replace the explosion simply do as following...

PHP Code:

public plugin_init()
{
    
RegisterHam(Ham_Think"grenade""fw_ThinkGrenade", .Post false)
}

public 
fw_ThinkGrenade(ent)
{
    static 
Float:fDamageTime;
    
pev(entpev_dmgtimefDamageTime);

    if(
fDamageTime get_gametime() && !task_exists(ent))
    {
        if(
GrenadeGoing2Explode(entpev(entpev_owner) >= PLUGIN_HANDLED)
        {
            
set_pev(entpev_dmgtimeget_gametime() + 9999999.0 );
        }
        else
            
set_task((fDamageTime get_gametime()), "task_grenade_exploded"ent);
    }
}

GrenadeGoing2Explode(const iGrenade, const thrower)
{
    return 
PLUGIN_HANDLED// blocking the explosion....
}

public 
task_grenade_exploded(const iGrenade)
{
    
// Grenade exploded successfully!!!

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

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
loki_himself
Member
Join Date: Nov 2021
Old 09-06-2022 , 11:21   Re: get owner on grenade_explosion is 0?
Reply With Quote #9

...

Last edited by loki_himself; 11-23-2022 at 13:21.
loki_himself is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-06-2022 , 12:41   Re: get owner on grenade_explosion is 0?
Reply With Quote #10

If you're just trying to edit the effects you can hook function Pre Explode3 with orpheu or reAPI if you're using regamedll, and block SVC_TEMPENTITY messages and then re-enable them again in Post Explode3.

You can check over here how the grenade explode works....


or you can use the previous way and rather return PLUGIN_CONTINUE in GrenadeGoing2Explode.

try debugging task_grenade_exploded to see if you get satisfied results.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 09-06-2022 at 12:45.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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 02:31.


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