Raised This Month: $ Target: $400
 0% 

Detect Grenade Damage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BOYSplayCS
BANNED
Join Date: Apr 2008
Location: Gainesville, FL
Old 03-25-2009 , 18:57   Detect Grenade Damage
Reply With Quote #1

I've tried several ways and none are efficient enough, can anyone tell me what is the most efficient way to detect grenade damage?
BOYSplayCS is offline
Dr.G
Senior Member
Join Date: Nov 2008
Old 03-25-2009 , 19:10   Re: Detect Grenade Damage
Reply With Quote #2

idk what else DMG_BLAST will catch but only mortars i assume, but again i dont know. but you can catch it like this:


PHP Code:
RegisterHam(Ham_TakeDamage"player""func_TakeDamage"
PHP Code:
public func_TakeDamage(ididinflictoridattackerFloat:damagedamagebits)
{
 if( 
is_user_alive(id) && get_user_team(id) && (damagebits DMG_BLAST)) 
 {
  
// do something
  
return HAM_HANDLED
 
}
 return 
HAM_IGNORED

__________________
Dr.G is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 03-25-2009 , 19:14   Re: Detect Grenade Damage
Reply With Quote #3

Quote:
Originally Posted by Dr.G View Post
idk what else DMG_BLAST will catch but only mortars i assume, but again i dont know. but you can catch it like this:
DMG_BLAST is not the grenade damage
This one is->
PHP Code:
#define DMG_HEGRENADE     (1 << 24) 
So:

PHP Code:
#define DMG_HEGRENADE     (1 << 24)
public plugin_init()
{
RegisterHam(Ham_TakeDamage"player""func_TakeDamage")

PHP Code:
public func_TakeDamage(ididinflictoridattackerFloat:damagedamagebits)
{
 if( 
is_user_alive(id) && get_user_team(id) && (damagebits == DMG_HEGRENADE)) 
 {
  
// do something
  
return HAM_HANDLED
 
}
 return 
HAM_IGNORED

Quote:
Originally Posted by BOYSplayCS View Post
I've tried several ways and none are efficient enough, can anyone tell me what is the most efficient way to detect grenade damage?
And a question! You want to catch only the damage of the He Grenade? Or you want all nades? For example how to hook the damage from frostnades.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
Dr.G
Senior Member
Join Date: Nov 2008
Old 03-25-2009 , 19:17   Re: Detect Grenade Damage
Reply With Quote #4

oh ok sry bout that.. i only tested that on DoD and that is grenade damage
__________________
Dr.G is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 03-25-2009 , 19:26   Re: Detect Grenade Damage
Reply With Quote #5

Quote:
Originally Posted by Dr.G View Post
oh ok sry bout that.. i only tested that on DoD and that is grenade damage
That is the damage of the grenade for cs. You don't need to be sorry about anything .
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
BOYSplayCS
BANNED
Join Date: Apr 2008
Location: Gainesville, FL
Old 03-25-2009 , 20:48   Re: Detect Grenade Damage
Reply With Quote #6

I only want to catch the damage for an HE grenade. Thank you all for your help so far!
BOYSplayCS is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-25-2009 , 20:58   Re: Detect Grenade Damage
Reply With Quote #7

Why not do this:
Code:
public plugin_init() {     RegisterHam(Ham_TakeDamage, "player", "FwdPlayerDamage"); } public FwdPlayerDamage(client, inflictor, attacker, Float:damage, damagebits) {     if( fm_is_ent_classname(inflictor, "grenade") && cs_get_weapon_id(inflictor) == CSW_HEGRENADE )     {         // damage from grenade     } }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
BOYSplayCS
BANNED
Join Date: Apr 2008
Location: Gainesville, FL
Old 03-25-2009 , 20:59   Re: Detect Grenade Damage
Reply With Quote #8

Ah, thank you Exolent. Now, I'll just set a task after the if statement. Thank you, +karma to you, and the two people above you.

EDIT: Yes, you can do that now. The karma thing.
BOYSplayCS is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-25-2009 , 21:48   Re: Detect Grenade Damage
Reply With Quote #9

@Dr. G, DMG_BLAST will detect C4 damage, but not grenade.

Simplest and most efficient way to do it, IMO.

PHP Code:
#define DMG_GRENADE    (1 << 24)

public plugin_init()
{
    
RegisterHam(Ham_TakeDamage"player""func_TakeDamage")
}  

public 
func_TakeDamage(ididinflictoridattackerFloat:damagedamagebits)
{
    if( 
damagebits DMG_GRENADE 
    {
        
//Nade damage

        //if you want, block the damage with HAM_SUPERCEDE
        //return HAM_SUPERCEDE;
    
}

    return 
HAM_IGNORED;

__________________

Last edited by Bugsy; 03-25-2009 at 21:53.
Bugsy is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 03-26-2009 , 08:56   Re: Detect Grenade Damage
Reply With Quote #10

@Exolent: Checking cs_get_weapon_id() is enough.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores 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 16:01.


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