AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Detect Grenade Damage (https://forums.alliedmods.net/showthread.php?t=88506)

BOYSplayCS 03-25-2009 18:57

Detect Grenade Damage
 
I've tried several ways and none are efficient enough, can anyone tell me what is the most efficient way to detect grenade damage?

Dr.G 03-25-2009 19:10

Re: Detect Grenade Damage
 
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



ot_207 03-25-2009 19:14

Re: Detect Grenade Damage
 
Quote:

Originally Posted by Dr.G (Post 789081)
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 (Post 789078)
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.

Dr.G 03-25-2009 19:17

Re: Detect Grenade Damage
 
oh ok sry bout that.. i only tested that on DoD and that is grenade damage

ot_207 03-25-2009 19:26

Re: Detect Grenade Damage
 
Quote:

Originally Posted by Dr.G (Post 789087)
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 :).

BOYSplayCS 03-25-2009 20:48

Re: Detect Grenade Damage
 
I only want to catch the damage for an HE grenade. Thank you all for your help so far!

Exolent[jNr] 03-25-2009 20:58

Re: Detect Grenade Damage
 
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     } }

BOYSplayCS 03-25-2009 20:59

Re: Detect Grenade Damage
 
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.

Bugsy 03-25-2009 21:48

Re: Detect Grenade Damage
 
@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;



Dores 03-26-2009 08:56

Re: Detect Grenade Damage
 
@Exolent: Checking cs_get_weapon_id() is enough.


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

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