Raised This Month: $ Target: $400
 0% 

Check Slash


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Monster Truck
Member
Join Date: Jan 2012
Location: France
Old 06-27-2014 , 06:51   Check Slash
Reply With Quote #1

Hi, i just wanted to know, is there a way to check in takedamagepre a slash and a stab ? I want to lower the slash damage, without touching to the stab damage.

Thx
Monster Truck is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 06-27-2014 , 07:01   Re: Check Slash
Reply With Quote #2

Check attacker's button bitsum for IN_ATTACK. Like so:
PHP Code:
if(pev(iAttackerpev_button) & IN_ATTACK)
{
       
// slash

To check for stab(if you ever need it), check for IN_ATTACK2.
klippy is offline
Monster Truck
Member
Join Date: Jan 2012
Location: France
Old 06-27-2014 , 07:06   Re: Check Slash
Reply With Quote #3

So, Something like this will be good ?

PHP Code:
public fwTakeDamagePrevictiminflictorattackerFloat:damagedamage_bits )
{
    if ( 
IsPlayerattacker ) && g_bHasSuperKnifeattacker ] && is_user_aliveattacker ) && inflictor == attacker && get_user_weaponattacker ) == CSW_KNIFE )
    {
        if( 
peviAttackerpev_button ) & IN_ATTACK )
        {
            
SetHamParamFloat4damage 15 );
        }
        else
        {
            
SetHamParamFloat4damage 100 );
        }
    }

Monster Truck is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 06-27-2014 , 07:31   Re: Check Slash
Reply With Quote #4

I don't think inflictor will equal to attacker.
Also, if you're changing a parameter you have to return HAM_HANDLED. Otherwise it will be ignored by Ham.

Here's another way, don't know which is better/more efficient though.
Code:
#include <amxmodx> #include <hamsandwich> const m_pPlayer = 41; const CBasePlayerItemOffset = 4; new bool:gSlashing[33]; public plugin_init() {     RegisterHam(Ham_TakeDamage, "player", "fwdTakeDamage");     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_knife", "fwdPrimaryAttackKnifePre");     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_knife", "fwdPrimaryAttackKnifePost", 1); } public fwdTakeDamage(Victim, Inflictor, Attacker, Float:Damage, Damagebits) {         if ( is_user_connected(Attacker) && gSlashing[Attacker] ) {         SetHamParamFloat(4, Damage * 1.5);         return HAM_HANDLED;     }         return HAM_IGNORED; } public fwdPrimaryAttackKnifePre(ent)     gSlashing[get_pdata_cbase(ent, m_pPlayer, CBasePlayerItemOffset)] = true; public fwdPrimaryAttackKnifePost(ent)     gSlashing[get_pdata_cbase(ent, m_pPlayer, CBasePlayerItemOffset)] = false;
__________________
Black Rose 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 10:44.


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