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

How to detect grenade damage in the Ham_takedamage function?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 06-03-2008 , 15:30   How to detect grenade damage in the Ham_takedamage function?
Reply With Quote #1

I know that in cs the grenade doesn't have an assigned damage type ...
Is it possible to detect if an attack is made by a gun or by a grenade in ham_takedamage?
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
DA
Veteran Member
Join Date: Nov 2005
Location: Germany/Münster
Old 06-03-2008 , 16:14   Re: How to detect grenade damage in the Ham_takedamage function?
Reply With Quote #2

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,
This is from ham_const.inc. idinflictor is the id from the weapon.
__________________
DA is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 06-03-2008 , 16:22   Re: How to detect grenade damage in the Ham_takedamage function?
Reply With Quote #3

What id???
As an entity or CSW_HEGRENADE?
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 06-04-2008 , 06:27   Re: How to detect grenade damage in the Ham_takedamage function?
Reply With Quote #4

Lol...const !
CSW_HEGRENADE
__________________

anakin_cstrike is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 06-04-2008 , 06:45   Re: How to detect grenade damage in the Ham_takedamage function?
Reply With Quote #5

I remember connorr detected a damage flag for HE grenades, but idr now...
You can make like this

Code:
if(!(bitDamage & (DMG_FALL | DMG_DROWN)))     //Damage maked by HE grenade.
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
DA
Veteran Member
Join Date: Nov 2005
Location: Germany/Münster
Old 06-04-2008 , 07:31   Re: How to detect grenade damage in the Ham_takedamage function?
Reply With Quote #6

Quote:
Originally Posted by ot_207 View Post
What id???
As an entity or CSW_HEGRENADE?
Yes. You can with CSW_HEGRENADE detect which gun the player has.

Quote:
Originally Posted by Alka View Post
I remember connorr detected a damage flag for HE grenades, but idr now...
You can make like this

Code:
if(!(bitDamage & (DMG_FALL | DMG_DROWN)))     //Damage maked by HE grenade.
Well. The function result the weapon. Why should he detect the weapon like this?
__________________
DA is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 06-04-2008 , 08:05   Re: How to detect grenade damage in the Ham_takedamage function?
Reply With Quote #7

i will try the CSW_HEGRENADE id ...
[EDIT] that isn't it

There is a problem with my nanosuit plugin.
The problem is when a user throws a grenade, if he has the knife and strength mode on when the nade explodes the grenade deals 4* damage ... a thing which i don't know how to detect ...[/EDIT]
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 06-04-2008 at 08:16.
ot_207 is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 06-04-2008 , 08:17   Re: How to detect grenade damage in the Ham_takedamage function?
Reply With Quote #8

Quote:
Originally Posted by Alka View Post
I remember connorr detected a damage flag for HE grenades, but idr now...
You can make like this

Code:
if(!(bitDamage & (DMG_FALL | DMG_DROWN)))     //Damage maked by HE grenade.
I don't think that's it ...
What about DMG_BULLET ???
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-04-2008 , 08:53   Re: How to detect grenade damage in the Ham_takedamage function?
Reply With Quote #9

Ham way :

Code:
    #include <amxmodx>     #include <hamsandwich>         #define DMG_GRENADE ( 1 << 24 )         public plugin_init ()     {         RegisterHam ( Ham_TakeDamage, "player", "fwd_TakeDamage" );     }         public fwd_TakeDamage ( id, i_Inflictor, i_Attacker, Float:f_Damage, i_DamageBits )     {         if ( i_DamageBits & DMG_GRENADE )         {             client_print ( id, print_chat, "Grenade triggered." );         }     }

if not enough, or doesn't work well, try this :

Code:
    #include <amxmodx>     #include <fakemeta>     #include <hamsandwich>     public plugin_init ()     {         RegisterHam ( Ham_TakeDamage, "player", "fwd_TakeDamage" );     }         public fwd_TakeDamage ( id, i_Inflictor, i_Attacker, Float:f_Damage, i_DamageBits )     {         if ( IsGrenade ( i_Inflictor ) )         {             client_print ( id, print_chat, "Grenade triggered." );         }     }         bool:IsGrenade ( i_Inflictor )     {         static s_Classname[ 8 ];         pev ( i_Inflictor, pev_classname, s_Classname, charsmax ( s_Classname ) );                 return equal ( s_Classname, "grenade" ) ? true : false;     }


Fakemeta way :

Code:
    #include <amxmodx>     #include <fakemeta>     public plugin_init ()     {         register_event ( "Damage", "e_Damage", "be", "2!0" );     }         public e_Damage ( i_Victim )     {         if ( IsGrenade ( pev ( i_Victim, pev_dmg_inflictor ) ) )         {             client_print ( i_Victim, print_chat, "Grenade triggered." );         }     }         bool:IsGrenade ( i_Inflictor )     {         static s_Classname[ 8 ];         pev ( i_Inflictor, pev_classname, s_Classname, charsmax ( s_Classname ) );                 return equal ( s_Classname, "grenade" ) ? true : false;     }
__________________

Last edited by Arkshine; 06-04-2008 at 09:13.
Arkshine is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 06-04-2008 , 12:05   Re: How to detect grenade damage in the Ham_takedamage function?
Reply With Quote #10

Thanks arkshine! +k

Just another question what does the << operator do exactly?
I didn't quite understood from the tutorial ...
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 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 12:11.


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