AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Efficent way to block secondary Attack of knife (https://forums.alliedmods.net/showthread.php?t=232835)

Kia 01-05-2014 13:20

Efficent way to block secondary Attack of knife
 
Hey there,

I want to block the secondary Attack from the knife using this code by now :

PHP Code:

RegisterHam(Ham_Weapon_SecondaryAttack"weapon_knife""Ham_KnifeSecondaryAttackPre"

PHP Code:

public Ham_KnifeSecondaryAttackPre()
    return 
HAM_SUPERCEDE 

It is working, but sometimes you can see a bit of the animation and if you do it fast you see the full stab.
Is there any more efficent way to block stabbing?

Bos93 01-05-2014 16:00

Re: Efficent way to block secondary Attack of knife
 
try this:
PHP Code:

public Ham_KnifeSecondaryAttackPre() 
{
    
SetHamReturnInteger(0)
    return 
HAM_SUPERCEDE 



meTaLiCroSS 01-05-2014 18:45

Re: Efficent way to block secondary Attack of knife
 
Set m_flNextSecondaryAttack offset to get_gametime() + 9999.9

Kia 01-06-2014 03:46

Re: Efficent way to block secondary Attack of knife
 
Quote:

Originally Posted by Bos93 (Post 2081673)
try this:
PHP Code:

public Ham_KnifeSecondaryAttackPre() 
{
    
SetHamReturnInteger(0)
    return 
HAM_SUPERCEDE 



Quote:

[HAMSANDWICH] Data pointer is NULL!
Quote:

Originally Posted by meTaLiCroSS (Post 2081728)
Set m_flNextSecondaryAttack offset to get_gametime() + 9999.9

Does not work.

Black Rose 01-06-2014 07:22

Re: Efficent way to block secondary Attack of knife
 
Weapon_SecondaryAttack to stop animation and TraceAttack to stop the damage i think.
At least that's what I did to block the damage here. But the animation is never blocked in my code.
If you can't block the animation maybe you can force idle.

yokomo 01-06-2014 09:01

Re: Efficent way to block secondary Attack of knife
 
This will block stab and replace animation to idle.
You need New Hamsandwich module.
PHP Code:

#include <amxmodx>
#include <hamsandwich>

public plugin_init()
{
    
register_plugin("No Stab""0.0.1""wbyokomo")
    
RegisterHam(Ham_Weapon_SecondaryAttack"weapon_knife""OnKnifeSecAtk")
}

public 
OnKnifeSecAtk(ent)
{
    
ExecuteHamB(Ham_CS_Weapon_SendWeaponAniment00)
    return 
HAM_SUPERCEDE;



Kia 01-06-2014 10:34

Re: Efficent way to block secondary Attack of knife
 
Thanks, working like a charm. :)

PRoSToTeM@ 01-07-2014 10:55

Re: Efficent way to block secondary Attack of knife
 
Try this:
PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define XO_CBASEPLAYERWEAPON    4
#define m_flNextSecondaryAttack    47

public plugin_init() {
    
RegisterHam(Ham_Item_GetWeaponPtr"weapon_knife""Knife_GetWeaponPtr");
    
RegisterHam(Ham_Weapon_SecondaryAttack"weapon_knife""Knife_SecondaryAttack_Pre"false);
}

public 
Knife_GetWeaponPtr(const iEntity) {
    
set_pdata_float(iEntitym_flNextSecondaryAttack1.0XO_CBASEPLAYERWEAPON);
}

public 
Knife_SecondaryAttack_Pre(const iEntity) {
    return 
HAM_SUPERCEDE;



meTaLiCroSS 01-07-2014 13:01

Re: Efficent way to block secondary Attack of knife
 
Quote:

Originally Posted by Kia (Post 2081862)
Does not work.

Sure? lol, I've been using that code since years for blocking secondary attack on certain weapons and it works perfect :)

https://forums.alliedmods.net/showpo...34&postcount=9

please..

Quote:

Originally Posted by yokomo (Post 2081967)
This will block stab and replace animation to idle.
You need New Hamsandwich module.
PHP Code:

#include <amxmodx>
#include <hamsandwich>

public plugin_init()
{
    
register_plugin("No Stab""0.0.1""wbyokomo")
    
RegisterHam(Ham_Weapon_SecondaryAttack"weapon_knife""OnKnifeSecAtk")
}

public 
OnKnifeSecAtk(ent)
{
    
ExecuteHamB(Ham_CS_Weapon_SendWeaponAniment00)
    return 
HAM_SUPERCEDE;



That code will be called every frame if you press the +attack2 button, it's not recommended and it's ugly also.

ConnorMcLeod 01-07-2014 16:07

Re: Efficent way to block secondary Attack of knife
 
Quote:

Originally Posted by yokomo (Post 2081967)
This will block stab and replace animation to idle.
You need New Hamsandwich module.
PHP Code:

#include <amxmodx>
#include <hamsandwich>

public plugin_init()
{
    
register_plugin("No Stab""0.0.1""wbyokomo")
    
RegisterHam(Ham_Weapon_SecondaryAttack"weapon_knife""OnKnifeSecAtk")
}

public 
OnKnifeSecAtk(ent)
{
    
ExecuteHamB(Ham_CS_Weapon_SendWeaponAniment00)
    return 
HAM_SUPERCEDE;



Nice, but as it has be stated, code gonna be executed on every player frame if holding +attack2, you should set m_flNextSecondaryAttack there.

PHP Code:

public OnKnifeSecAtk(ent)
{
    
ExecuteHamB(Ham_CS_Weapon_SendWeaponAniment00)
    
set_pdata_float(entm_flNextSecondaryAttack9999.94)
    return 
HAM_SUPERCEDE


9999 if you don't bother about delays, else few seconds.


All times are GMT -4. The time now is 10:06.

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