Raised This Month: $ Target: $400
 0% 

Detect damage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
reinert
Veteran Member
Join Date: Feb 2007
Old 06-17-2011 , 05:21   Detect damage
Reply With Quote #1

How to detect a weapon with which was damage done ?

Like I've plugin that deals extra damage if you are with knife, but it hooks like
if(AttackerWeapon == CSW_KNIFE)

and there is a bug when I throw HE, and instantly switch my gun to knife, it deals KNIFE damage, even if it was done by HE.
reinert is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 06-17-2011 , 06:30   Re: Detect damage
Reply With Quote #2

Hook damage with ham and...

Just making sure you know, first you must make sure attacker is a player (1 <= attacker <= g_iMaxPlayers)

In the ham called function you get the "inflictor" input, you can check that against "attacker", if they're equal, the attacker used a weapon, if it's not, the attacker used a nade or something else to attack.

Then you can just get_user_weapon()...
__________________
Hunter-Digital is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 06-17-2011 , 07:48   Re: Detect damage
Reply With Quote #3

Like this: ?

PHP Code:
RegisterHam(Ham_TakeDamage"player""Ham_DamageKNIFE")

public 
Ham_DamageKNIFE(idinflictorattackerFloat:damagedamagebits)
{
    if ( !(
<= attacker <= g_maxplayers) || !g_KNIFE[attacker])
            return 
HAM_IGNORED;
        
    if(
inflictor == attacker)
    {
        new 
weaponx get_user_weapon(attacker__);
        if( 
weaponx == CSW_KNIFE && get_user_team(attacker) == 2)
        {
        
SetHamParamFloat(4damage get_pcvar_float(damage_knife)); //Knife damage
        
return HAM_HANDLED;
        }
    }
    return 
HAM_IGNORED;

reinert is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 06-17-2011 , 12:34   Re: Detect damage
Reply With Quote #4

Simple, try it.
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu 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 23:30.


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