Raised This Month: $ Target: $400
 0% 

detecting knife stab or slash


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
11922911
Senior Member
Join Date: Dec 2011
Location: Yuen Long Country
Old 04-10-2016 , 04:35   detecting knife stab or slash
Reply With Quote #1

I know you can check player buttons IN_ATTACK or IN_ATTACK2,
but what if player pressing left and right click at the same time,
so I need a more accurate way to detect that.
__________________
youtube:
@holla16
11922911 is offline
didoWEE
Senior Member
Join Date: Oct 2012
Location: Bulgaria
Old 04-10-2016 , 05:13   Re: detecting knife stab or slash
Reply With Quote #2

PHP Code:
    RegisterHam(Ham_Weapon_PrimaryAttack"weapon_knife""fwdKnifePrimaryAttackPre");
    
RegisterHam(Ham_Weapon_SecondaryAttack"weapon_knife""fwdKnifeSecondaryAttackPre"); 
didoWEE is offline
11922911
Senior Member
Join Date: Dec 2011
Location: Yuen Long Country
Old 04-10-2016 , 06:04   Re: detecting knife stab or slash
Reply With Quote #3

Quote:
Originally Posted by didoWEE View Post
PHP Code:
    RegisterHam(Ham_Weapon_PrimaryAttack"weapon_knife""fwdKnifePrimaryAttackPre");
    
RegisterHam(Ham_Weapon_SecondaryAttack"weapon_knife""fwdKnifeSecondaryAttackPre"); 
I want to detect outside of these functions, how to do?
__________________
youtube:
@holla16
11922911 is offline
safetymoose
Senior Member
Join Date: Feb 2015
Old 04-10-2016 , 06:05   Re: detecting knife stab or slash
Reply With Quote #4

PHP Code:
new button pev(idpev_button)
if(
button IN_ATTACK && !(button IN_ATTACK2))
{
          
// your code here


Last edited by safetymoose; 04-10-2016 at 06:08.
safetymoose is offline
11922911
Senior Member
Join Date: Dec 2011
Location: Yuen Long Country
Old 04-10-2016 , 06:14   Re: detecting knife stab or slash
Reply With Quote #5

Quote:
Originally Posted by safetymoose View Post
PHP Code:
new button pev(idpev_button)
if(
button IN_ATTACK && !(button IN_ATTACK2))
{
          
// your code here

what if player pressing IN_ATTACK and IN_ATTACK2 at the same time?
__________________
youtube:
@holla16
11922911 is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 04-10-2016 , 07:37   Re: detecting knife stab or slash
Reply With Quote #6

Quote:
Originally Posted by 11922911 View Post
I want to detect outside of these functions, how to do?
What are you trying to achieve?
SpeeDeeR is offline
11922911
Senior Member
Join Date: Dec 2011
Location: Yuen Long Country
Old 04-10-2016 , 07:43   Re: detecting knife stab or slash
Reply With Quote #7

Quote:
Originally Posted by SpeeDeeR View Post
What are you trying to achieve?
Something like detect stab or slash in TakeDamage()
__________________
youtube:
@holla16
11922911 is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 04-10-2016 , 08:02   Re: detecting knife stab or slash
Reply With Quote #8

So you would like to modify knife damage, is that correct?
SpeeDeeR is offline
11922911
Senior Member
Join Date: Dec 2011
Location: Yuen Long Country
Old 04-10-2016 , 08:27   Re: detecting knife stab or slash
Reply With Quote #9

kind of
__________________
youtube:
@holla16
11922911 is offline
didoWEE
Senior Member
Join Date: Oct 2012
Location: Bulgaria
Old 04-10-2016 , 08:33   Re: detecting knife stab or slash
Reply With Quote #10

PHP Code:
#include <amxmodx>
#include <hamsandwich>

#define PLUGIN "dmg"
#define VERSION "1.0"
#define AUTHOR "didoWEE"


public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
RegisterHam(Ham_TakeDamage"player""fwdPlayerTakeDamagePre"0);
}
public 
fwdPlayerTakeDamagePree(idinflictorattackerFloat:dmgdmgbits)
{
    if(!
is_user_connected(attacker))
        return 
HAM_IGNORED;
    if(
get_user_weapon(attacker) != CSW_KNIFE)
        return 
HAM_IGNORED;
    if(
id == attacker || attacker != inflictor)
        return 
HAM_IGNORED;
    
    if(
dmg == 60 || dmg == 50 || dmg 20)
    {
        
// slash
    
}
    else 
    {
        
// slash
    
}
    
    return 
HAM_IGNORED;


Last edited by didoWEE; 04-10-2016 at 08:38.
didoWEE 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 11:08.


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