Raised This Month: $ Target: $400
 0% 

Efficent way to block secondary Attack of knife


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 01-05-2014 , 13:20   Efficent way to block secondary Attack of knife
Reply With Quote #1

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?
__________________
Kia is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 01-05-2014 , 16:00   Re: Efficent way to block secondary Attack of knife
Reply With Quote #2

try this:
PHP Code:
public Ham_KnifeSecondaryAttackPre() 
{
    
SetHamReturnInteger(0)
    return 
HAM_SUPERCEDE 

__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 01-05-2014 , 18:45   Re: Efficent way to block secondary Attack of knife
Reply With Quote #3

Set m_flNextSecondaryAttack offset to get_gametime() + 9999.9
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 01-06-2014 , 03:46   Re: Efficent way to block secondary Attack of knife
Reply With Quote #4

Quote:
Originally Posted by Bos93 View Post
try this:
PHP Code:
public Ham_KnifeSecondaryAttackPre() 
{
    
SetHamReturnInteger(0)
    return 
HAM_SUPERCEDE 

Quote:
[HAMSANDWICH] Data pointer is NULL!
Quote:
Originally Posted by meTaLiCroSS View Post
Set m_flNextSecondaryAttack offset to get_gametime() + 9999.9
Does not work.
__________________
Kia is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 01-07-2014 , 13:01   Re: Efficent way to block secondary Attack of knife
Reply With Quote #5

Quote:
Originally Posted by Kia View Post
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 View Post
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.
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross

Last edited by meTaLiCroSS; 01-07-2014 at 13:02.
meTaLiCroSS is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 01-06-2014 , 07:22   Re: Efficent way to block secondary Attack of knife
Reply With Quote #6

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.
__________________
Black Rose is offline
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 01-06-2014 , 09:01   Re: Efficent way to block secondary Attack of knife
Reply With Quote #7

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;

yokomo is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-07-2014 , 16:07   Re: Efficent way to block secondary Attack of knife
Reply With Quote #8

Quote:
Originally Posted by yokomo View Post
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.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 01-07-2014 at 16:07.
ConnorMcLeod is offline
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 01-08-2014 , 03:14   Re: Efficent way to block secondary Attack of knife
Reply With Quote #9

Okay use this 1 then, no longer need New Hamsandwich module:

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

public plugin_init() 

    
register_plugin("No Stab""0.0.1""wbyokomo")
    
RegisterHam(Ham_Item_Deploy"weapon_knife""OnBlockStab"1)
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_knife""OnBlockStab"1


public 
OnBlockStab(ent)
{
    
set_pdata_float(ent479999.94)

Still ugly? then i have no idea..

Last edited by yokomo; 01-08-2014 at 03:19.
yokomo is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 01-06-2014 , 10:34   Re: Efficent way to block secondary Attack of knife
Reply With Quote #10

Thanks, working like a charm.
__________________
Kia is offline
Reply


Thread Tools
Display Modes

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:06.


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