AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ham_TakeDamage (https://forums.alliedmods.net/showthread.php?t=195656)

vitorrossi 09-09-2012 20:07

Ham_TakeDamage
 
When you register Ham_TakeDamage

PHP Code:

RegisterHam(Ham_TakeDamage"player""Ham_PlayerTakeDamage_Post"1); 

PHP Code:

public Ham_PlayerTakeDamage_Post(iVictim,iInflictor,iAttacker,Float:flDamage,iBits

If the iVictim is hit by a shot from a weapon, iInflictor and iAttacker are the same. How can I find the weapon that was used to cause the damage? i.e. deagle or ak47 or... Thank you

meTaLiCroSS 09-09-2012 20:56

Re: Ham_TakeDamage
 
Quote:

Originally Posted by vitorrossi (Post 1795646)
When you register Ham_TakeDamage

PHP Code:

RegisterHam(Ham_TakeDamage"player""Ham_PlayerTakeDamage_Post"1); 

PHP Code:

public Ham_PlayerTakeDamage_Post(iVictim,iInflictor,iAttacker,Float:flDamage,iBits

If the iVictim is hit by a shot from a weapon, iInflictor and iAttacker are the same. How can I find the weapon that was used to cause the damage? i.e. deagle or ak47 or... Thank you

Just use get_user_weapon(iAttacker) for retrieving the attacker's weapon, but you must be sure that the attacker is a player. For that one, you can just use is_user_connected

fysiks 09-09-2012 20:58

Re: Ham_TakeDamage
 
If iAttacker is a player then get his weapon, get_user_weapon() I think.

vitorrossi 09-09-2012 22:13

Re: Ham_TakeDamage
 
Thank you, I will try that. What if I use instead

PHP Code:

ExecuteHam(Ham_TakeDamage,iVictim,iInflictor,iAttacker,Float:Damage,DMG_GENERIC

If I use this during the round it works fine but if I set this to happen after round is over (ie all Ts or CTs are dead) it doesn't call it. Is there any special parameter or method to make it work even after all players in one team are dead?

fysiks 09-10-2012 01:26

Re: Ham_TakeDamage
 
Quote:

Originally Posted by vitorrossi (Post 1795725)
Thank you, I will try that. What if I use instead

PHP Code:

ExecuteHam(Ham_TakeDamage,iVictim,iInflictor,iAttacker,Float:Damage,DMG_GENERIC

If I use this during the round it works fine but if I set this to happen after round is over (ie all Ts or CTs are dead) it doesn't call it. Is there any special parameter or method to make it work even after all players in one team are dead?

That doesn't make sense. Executing Ham_TakeDamage is not a substitute for registering it . . .

vitorrossi 09-10-2012 11:05

Re: Ham_TakeDamage
 
Quote:

Originally Posted by fysiks (Post 1795793)
That doesn't make sense. Executing Ham_TakeDamage is not a substitute for registering it . . .

Oh no, I understand that, this was a separate question about the same ham command... And btw I figured it out, thank you
P.S. get_user_weapon() worked perfectly!

Liverwiz 09-10-2012 12:23

Re: Ham_TakeDamage
 
also check
Code:

!(0 < iAttacker <= get_maxplayers() )

ConnorMcLeod 09-10-2012 13:29

Re: Ham_TakeDamage
 
Don't forget to check if attacker is the same as inflictor, else inflictor can be a grenade.


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

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