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

How to hook entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KaLoIaN
Senior Member
Join Date: Feb 2013
Old 04-13-2016 , 12:35   How to hook entity
Reply With Quote #1

How I can hook entities like func_vehicle func_breakable etc? And other entities for example when someone pushes a button to write his name in chat?

In case: func_breakable when it get killed (pev_health >= 0.0 for example) to write in chat the destroyer name?
In case: func_vehicle when someone activate it to write his name in chat?

I has never liked these entity thingy..
KaLoIaN is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 04-13-2016 , 12:45   Re: How to hook entity
Reply With Quote #2

I know that func breakable can be checked on damage event checking if victim is an entity func_breakable and health <= 0, but vehicle or button don't know if possible to hook.

On button maybe you can catch +use and get the entity by player aim and then check if it's a button and also check distance between player and entity , if it's in the radius where button can be pushed.

With these tricky checks is possible but with directly by catching event don't know if exists, maybe hamsandwich has.. Let more experienced scripters answer this question.
siriusmd99 is offline
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 04-13-2016 , 13:12   Re: How to hook entity
Reply With Quote #3

HAM_Use // FM_Use
__________________
gabuch2 is offline
KaLoIaN
Senior Member
Join Date: Feb 2013
Old 04-13-2016 , 14:06   Re: How to hook entity
Reply With Quote #4

Yes I think more experienced scripters answer it because the damn entity thingy are very complicated for me .. and maybe for everybody else!?
KaLoIaN is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 04-15-2016 , 09:30   Re: How to hook entity
Reply With Quote #5

PHP Code:
RegisterHam(Ham_TakeDamage"func_breakable""FwdBreakableTakeDamage");
 
public 
FwdBreakableTakeDamage(thisattackerinflictorFloatdamage)
{
    new 
Floathealth;
    
pev(this,pev_healthhealth); 
    if (
health damage <= 0.0)
    {
//breakable killed
    
}

For the button: Try hooking Ham_Use for player and play around with button classnames.

There is no point in creating multiple threads for one question.

Last edited by SpeeDeeR; 04-15-2016 at 09:36.
SpeeDeeR 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 21:07.


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