AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   ham_takedamage or ham_traceattack? (https://forums.alliedmods.net/showthread.php?t=172799)

Isaac999 11-26-2011 06:54

ham_takedamage or ham_traceattack?
 
whats the difference?

ham_TakeDamage

ham_TraceAttack

and what should be use?

drekes 11-26-2011 07:28

Re: ham_takedamage or ham_traceattack?
 
Depends on what you want to do.

Ham_TakeDamage is called when damage is done
Ham_TraceAttack is called when a player shoots for example. (Not sure what it does for other entities)

Snaker beatter 11-26-2011 07:45

Re: ham_takedamage or ham_traceattack?
 
Ham_TraceAttack - even when a player did not have damage (example: shoot team mate but disabled freindlyfire)

Not sure.

drekes 11-26-2011 09:32

Re: ham_takedamage or ham_traceattack?
 
From ham_const.inc
PHP Code:

/**
     * Description:        Usually called whenever an entity gets attacked by a hitscan (such as a gun) weapon.
     *                    Use the get/set tr2 natives in fakemeta to handle the traceresult data.
     *                    Do not use a handle of 0 as a traceresult in execution, use create_tr2() from Fakemeta
     *                    to pass a custom handle instead.  (Don't forget to free the handle when you're done.)
     * Forward params:    function(this, idattacker, Float:damage, Float:direction[3], traceresult, damagebits)
     * Return type:        None.
     * Execute params:    ExecuteHam(Ham_TraceAttack, this, idattacker, Float:damage, Float:direction[3], tracehandle, damagebits);
     */
    
Ham_TraceAttack 

PHP Code:

    /**
     * Description:        Usually called whenever an entity takes any kind of damage.
     *                    Inflictor is the entity that caused the damage (such as a gun).
     *                    Attacker is the entity that tirggered the damage (such as the gun's owner).
     * Forward params:    function(this, idinflictor, idattacker, Float:damage, damagebits);
     * Return type:        Integer.
     * Execute params:    ExecuteHam(Ham_TakeDamage, this, idinflictor, idattacker, Float:damage, damagebits);
     */
    
Ham_TakeDamage


Hunter-Digital 11-26-2011 09:58

Re: ham_takedamage or ham_traceattack?
 
Ham_TraceAttack is the traceline of the attack/bullet/damage whatever, you can use it with entities or even with worldspawn to detect bullets hitting walls, use this if you need something complicated like seeing if the shot was near a something else... this would be excelent for exploding ammo =)

If you just want to check when someone was damaged by something/someone, use Ham_TakeDamage.

Isaac999 11-26-2011 10:01

Re: ham_takedamage or ham_traceattack?
 
Thanks every one.

One last question:

Ham_TraceAttack can trace a attack from teammate (even if no friendlyfire)

Hunter-Digital 11-26-2011 10:01

Re: ham_takedamage or ham_traceattack?
 
Yes but you can use Ham_TakeDamage for that too, it triggers regardless of mp_friendlyfire when you shoot teammates.

Isaac999 11-26-2011 10:04

Re: ham_takedamage or ham_traceattack?
 
Thanks :up:


All times are GMT -4. The time now is 08:23.

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