AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   detecting knife stab or slash (https://forums.alliedmods.net/showthread.php?t=281383)

11922911 04-10-2016 04:35

detecting knife stab or slash
 
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.

didoWEE 04-10-2016 05:13

Re: detecting knife stab or slash
 
PHP Code:

    RegisterHam(Ham_Weapon_PrimaryAttack"weapon_knife""fwdKnifePrimaryAttackPre");
    
RegisterHam(Ham_Weapon_SecondaryAttack"weapon_knife""fwdKnifeSecondaryAttackPre"); 


11922911 04-10-2016 06:04

Re: detecting knife stab or slash
 
Quote:

Originally Posted by didoWEE (Post 2409612)
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?

safetymoose 04-10-2016 06:05

Re: detecting knife stab or slash
 
PHP Code:

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



11922911 04-10-2016 06:14

Re: detecting knife stab or slash
 
Quote:

Originally Posted by safetymoose (Post 2409626)
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?:shock:

SpeeDeeR 04-10-2016 07:37

Re: detecting knife stab or slash
 
Quote:

Originally Posted by 11922911 (Post 2409624)
I want to detect outside of these functions, how to do?

What are you trying to achieve?

11922911 04-10-2016 07:43

Re: detecting knife stab or slash
 
Quote:

Originally Posted by SpeeDeeR (Post 2409659)
What are you trying to achieve?

Something like detect stab or slash in TakeDamage()

SpeeDeeR 04-10-2016 08:02

Re: detecting knife stab or slash
 
So you would like to modify knife damage, is that correct?

11922911 04-10-2016 08:27

Re: detecting knife stab or slash
 
kind of

didoWEE 04-10-2016 08:33

Re: detecting knife stab or slash
 
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;




All times are GMT -4. The time now is 07:23.

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