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

[HELP] Hook Custom Entity Being Destroyed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hellmonja
Senior Member
Join Date: Oct 2015
Old 11-02-2020 , 00:17   [HELP] Hook Custom Entity Being Destroyed
Reply With Quote #1

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...
__________________
hellmonja is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-02-2020 , 00:34   Re: [HELP] Hook Custom Entity Being Destroyed
Reply With Quote #2

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.
__________________

Last edited by HamletEagle; 11-02-2020 at 00:35.
HamletEagle is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 11-02-2020 , 05:45   Re: [HELP] Hook Custom Entity Being Destroyed
Reply With Quote #3

Hook Ham_Killed with func_breakable check if victim ( 1st Param ) classname is equal to your entity classname .
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 07-04-2021 at 11:53. Reason: typo
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
hellmonja
Senior Member
Join Date: Oct 2015
Old 11-02-2020 , 09:29   Re: [HELP] Hook Custom Entity Being Destroyed
Reply With Quote #4

Quote:
Originally Posted by HamletEagle View Post
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?...
__________________
hellmonja is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-02-2020 , 10:42   Re: [HELP] Hook Custom Entity Being Destroyed
Reply With Quote #5

Quote:
Originally Posted by Natsheh View Post
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 View Post
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.
__________________
HamletEagle 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 20:08.


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