AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Hook Custom Entity Being Destroyed (https://forums.alliedmods.net/showthread.php?t=328253)

hellmonja 11-02-2020 00:17

[HELP] Hook Custom Entity Being Destroyed
 
So let's say I made a breakable entity, and set its classname to 'func_myent' for example. How do I detect if it gets destroyed? I wanted to put some gibs when it gets killed. But I haven't seen anyone do it, only with the classname 'func_breakble' but if I use that classname it would include every breakable entity on the map, not just my custom entity...

HamletEagle 11-02-2020 00:34

Re: [HELP] Hook Custom Entity Being Destroyed
 
Create your entity as func_breakable and use set_pev pev_classne with your classname(func_myent).
Hook TakeDamage with func_breakable. Inside take_damage retrieve pev_classname and check against func_myent.

Natsheh 11-02-2020 05:45

Re: [HELP] Hook Custom Entity Being Destroyed
 
Hook Ham_Killed with func_breakable check if victim ( 1st Param ) classname is equal to your entity classname .

hellmonja 11-02-2020 09:29

Re: [HELP] Hook Custom Entity Being Destroyed
 
Quote:

Originally Posted by HamletEagle (Post 2723400)
Create your entity as func_breakable and use set_pev pev_classne with your classname(func_myent).
Hook TakeDamage with func_breakable. Inside take_damage retrieve pev_classname and check against func_myent.

I see. When you say 'check against' like this right?
PHP Code:

if(equali(classname"func_myent")) 

Sorry, I can't access my unit for the time being.

Also, regarding Natsheh's post and why you didn't suggest it, I suspect Ham_Killed only works on players?...

HamletEagle 11-02-2020 10:42

Re: [HELP] Hook Custom Entity Being Destroyed
 
Quote:

Originally Posted by Natsheh (Post 2723419)
Hook Ham_Killed with func_breakable check if victim ( 1st Param ) classmate is equal to your entity classmate.

Won't work. Killed is not called. In CBreakable::TakeDamage, when health < 0 Die() is called instead.

Quote:

Originally Posted by hellmonja (Post 2723451)
I see. When you say 'check against' like this right?
PHP Code:

if(equali(classname"func_myent")) 

Sorry, I can't access my unit for the time being.

Also, regarding Natsheh's post and why you didn't suggest it, I suspect Ham_Killed only works on players?...

Yes, check if the value retrieved from pev_classname is func_myent. Also check if the health(pev_health) is <= 0.0.
Ham_Killed doesn't work only on players, but it's not called for func_breakable.


All times are GMT -4. The time now is 14:09.

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