AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to hook entity (https://forums.alliedmods.net/showthread.php?t=281519)

KaLoIaN 04-13-2016 12:35

How to hook entity
 
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.. :nono::):):)

siriusmd99 04-13-2016 12:45

Re: How to hook entity
 
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.

gabuch2 04-13-2016 13:12

Re: How to hook entity
 
HAM_Use // FM_Use

KaLoIaN 04-13-2016 14:06

Re: How to hook entity
 
Yes I think more experienced scripters answer it because the damn entity thingy are very complicated for me .. and maybe for everybody else!?

SpeeDeeR 04-15-2016 09:30

Re: How to hook entity
 
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.


All times are GMT -4. The time now is 18:40.

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