Raised This Month: $ Target: $400
 0% 

Knife hit knockback


Post New Thread Reply   
 
Thread Tools Display Modes
SaraAki
Member
Join Date: Nov 2022
Old 04-25-2024 , 15:02   Re: Knife hit knockback
Reply With Quote #11

Hello.Thanks for helping me.

L 04/25/2024 - 20:58:00: Invalid event (name "PlayerAttack") (plugin "amx_knife_knockback.amxx")
L 04/25/2024 - 20:58:00: [AMXX] Displaying debug trace (plugin "amx_knife_knockback.amxx")
L 04/25/2024 - 20:58:00: [AMXX] Run time error 10: native error (native "register_event")
L 04/25/2024 - 20:58:00: [AMXX] [0] amx_knife_knockback.txt::plugin_init (line 14)
SaraAki is offline
Ace67
Senior Member
Join Date: Sep 2020
Location: France
Old 04-25-2024 , 17:13   Re: Knife hit knockback
Reply With Quote #12

Quote:
Originally Posted by SaraAki View Post
Hello.Thanks for helping me.

L 04/25/2024 - 20:58:00: Invalid event (name "PlayerAttack") (plugin "amx_knife_knockback.amxx")
L 04/25/2024 - 20:58:00: [AMXX] Displaying debug trace (plugin "amx_knife_knockback.amxx")
L 04/25/2024 - 20:58:00: [AMXX] Run time error 10: native error (native "register_event")
L 04/25/2024 - 20:58:00: [AMXX] [0] amx_knife_knockback.txt::plugin_init (line 14)
I will check it
__________________
CS:CZ > CS 1.6

Last edited by Ace67; 04-25-2024 at 17:18.
Ace67 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-26-2024 , 04:05   Re: Knife hit knockback
Reply With Quote #13

The best way and the proper way to do it is to check player's knife attack animation in event traceattack/takedamage.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 04-26-2024 at 04:06.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 04-26-2024 , 10:21   Re: Knife hit knockback
Reply With Quote #14

Tell me if this work.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <xs>
#include <cstrike>
#include <engine>
#include <fun>

#define VERSION "1.0"

new cvar_knock_force

public plugin_init() 
{
    
register_plugin("Knife Stab KB"VERSION"Krtola")    
    
RegisterHam(Ham_TraceAttack"player""fw_TraceAttack_Post"1)
        
cvar_knock_force register_cvar("knife_force""10");
}

public 
fw_TraceAttack_Post(victim_idattacker_idFloatdamageFloatdirection[3], tracedamagebits)
{
       if(
get_user_weapon(attacker_id) == CSW_KNIFE)
       {
           static 
buttons
       buttons 
pev(attacker_idpev_button)    
                
              if(
buttons IN_ATTACK2)
           {
                new 
Float:vec[3];
                new 
Float:oldvelo[3];
                
get_user_velocity(victim_idoldvelo);
                
create_velocity_vector(victim_id attacker_id vec);
                
vec[0] += oldvelo[0];
                
vec[1] += oldvelo[1];
                
set_user_velocity(victim_id vec);
           } 
       }  


// Stock by the one and only, Chronic :P
stock create_velocity_vector(victim,attacker,Float:velocity[3])
{
    if(!
is_user_alive(victim) || !is_user_alive(attacker))
        return 
0;

    new 
Float:vicorigin[3];
    new 
Float:attorigin[3];
    
entity_get_vector(victim   EV_VEC_origin vicorigin);
    
entity_get_vector(attacker EV_VEC_origin attorigin);

    new 
Float:origin2[3]
    
origin2[0] = vicorigin[0] - attorigin[0];
    
origin2[1] = vicorigin[1] - attorigin[1];

    new 
Float:largestnum 0.0;

    if(
floatabs(origin2[0])>largestnumlargestnum floatabs(origin2[0]);
    if(
floatabs(origin2[1])>largestnumlargestnum floatabs(origin2[1]);

    
origin2[0] /= largestnum;
    
origin2[1] /= largestnum;

    
velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_knock_force) * 3000) ) / get_entity_distance(victim attacker);
    
velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knock_force) * 3000) ) / get_entity_distance(victim attacker);
    if(
velocity[0] <= 20.0 || velocity[1] <= 20.0)
        
velocity[2] = random_float(200.0 275.0);

    return 
1;

__________________
Check my original plugins for cs 1.6 and subscribe on channel
Look at the video bellow to see zombie frost grenade

https://youtu.be/j0zspNfN-AM?si=_1IiGPETN-GQY9Ua

Look at the video below to see Zombie blind grenade

https://youtu.be/ORC7ZmoaipQ?si=QC8Bul96QGitUwX4
Krtola is offline
Send a message via Skype™ to Krtola
Tote
Senior Member
Join Date: Jul 2023
Old 04-26-2024 , 10:44   Re: Knife hit knockback
Reply With Quote #15

Quote:
Originally Posted by Krtola View Post
Tell me if this work.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <xs>
#include <cstrike>
#include <engine>
#include <fun>

#define VERSION "1.0"

new cvar_knock_force

public plugin_init() 
{
    
register_plugin("Knife Stab KB"VERSION"Krtola")    
    
RegisterHam(Ham_TraceAttack"player""fw_TraceAttack_Post"1)
        
cvar_knock_force register_cvar("knife_force""10");
}

public 
fw_TraceAttack_Post(victim_idattacker_idFloatdamageFloatdirection[3], tracedamagebits)
{
       if(
get_user_weapon(attacker_id) == CSW_KNIFE)
       {
           static 
buttons
       buttons 
pev(attacker_idpev_button)    
                
              if(
buttons IN_ATTACK2)
           {
                new 
Float:vec[3];
                new 
Float:oldvelo[3];
                
get_user_velocity(victim_idoldvelo);
                
create_velocity_vector(victim_id attacker_id vec);
                
vec[0] += oldvelo[0];
                
vec[1] += oldvelo[1];
                
set_user_velocity(victim_id vec);
           } 
       }  


// Stock by the one and only, Chronic :P
stock create_velocity_vector(victim,attacker,Float:velocity[3])
{
    if(!
is_user_alive(victim) || !is_user_alive(attacker))
        return 
0;

    new 
Float:vicorigin[3];
    new 
Float:attorigin[3];
    
entity_get_vector(victim   EV_VEC_origin vicorigin);
    
entity_get_vector(attacker EV_VEC_origin attorigin);

    new 
Float:origin2[3]
    
origin2[0] = vicorigin[0] - attorigin[0];
    
origin2[1] = vicorigin[1] - attorigin[1];

    new 
Float:largestnum 0.0;

    if(
floatabs(origin2[0])>largestnumlargestnum floatabs(origin2[0]);
    if(
floatabs(origin2[1])>largestnumlargestnum floatabs(origin2[1]);

    
origin2[0] /= largestnum;
    
origin2[1] /= largestnum;

    
velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_knock_force) * 3000) ) / get_entity_distance(victim attacker);
    
velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knock_force) * 3000) ) / get_entity_distance(victim attacker);
    if(
velocity[0] <= 20.0 || velocity[1] <= 20.0)
        
velocity[2] = random_float(200.0 275.0);

    return 
1;

it will work. i just saw that i put

buttons = pev(id, pev_button)
instead of
buttons = pev(attacker, pev_button)

was not working cuz was getting button of the victim not attacker.

EDIT: this plugin is not urs you know-)
EDIT2: no need of those extra includes nd params.

Code:
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#include <fakemeta>
#include <engine>

#define VERSION "1.0"

new cvar_knock_force

public plugin_init() 
{
	register_plugin("Knife Stab KB", VERSION, "v3x & chronic/ edit tote")    
	RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack_Post", 1)
	cvar_knock_force = register_cvar("knife_force", "10");
}

public fw_TraceAttack_Post(victim_id, attacker_id)
{
	if(get_user_weapon(attacker_id) == CSW_KNIFE)
	{
		static buttons
		buttons = pev(attacker_id, pev_button)    
		
		if(buttons & IN_ATTACK2)
		{
			new Float:vec[3];
			new Float:oldvelo[3];
			get_user_velocity(victim_id, oldvelo);
			create_velocity_vector(victim_id , attacker_id , vec);
			vec[0] += oldvelo[0];
			vec[1] += oldvelo[1];
			set_user_velocity(victim_id , vec);
		} 
	}  
} 

// Stock by the one and only, Chronic :P
stock create_velocity_vector(victim,attacker,Float:velocity[3])
{
	if(!is_user_alive(victim) || !is_user_alive(attacker))
		return 0;
	
	new Float:vicorigin[3];
	new Float:attorigin[3];
	entity_get_vector(victim   , EV_VEC_origin , vicorigin);
	entity_get_vector(attacker , EV_VEC_origin , attorigin);
	
	new Float:origin2[3]
	origin2[0] = vicorigin[0] - attorigin[0];
	origin2[1] = vicorigin[1] - attorigin[1];
	
	new Float:largestnum = 0.0;
	
	if(floatabs(origin2[0])>largestnum) largestnum = floatabs(origin2[0]);
	if(floatabs(origin2[1])>largestnum) largestnum = floatabs(origin2[1]);
	
	origin2[0] /= largestnum;
	origin2[1] /= largestnum;
	
	velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_knock_force) * 3000) ) / get_entity_distance(victim , attacker);
	velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knock_force) * 3000) ) / get_entity_distance(victim , attacker);
	if(velocity[0] <= 20.0 || velocity[1] <= 20.0)
		velocity[2] = random_float(200.0 , 275.0);
	
	return 1;
}

Last edited by Tote; 04-26-2024 at 10:51.
Tote is offline
SaraAki
Member
Join Date: Nov 2022
Old 04-26-2024 , 11:01   Re: Knife hit knockback
Reply With Quote #16

I tested both versions,from Krtola and Tote last edit.What I noticed is that knockback work every time when i stab player from my team,but when i stab enemy,knockback doesn't always happen.It actually only happens when i kill the enemy player with knife right click,but not always.Is it possible to adjust that the effect does not affect my teammates?And to affect enemy player every time when i stab him?
SaraAki is offline
Tote
Senior Member
Join Date: Jul 2023
Old 04-26-2024 , 11:05   Re: Knife hit knockback
Reply With Quote #17

Quote:
Originally Posted by SaraAki View Post
I tested both versions,from Krtola and Tote last edit.What I noticed is that knockback work every time when i stab player from my team,but when i stab enemy,knockback doesn't always happen.It actually only happens when i kill the enemy player with knife right click,but not always.Is it possible to adjust that the effect does not affect my teammates?And to affect enemy player every time when i stab him?
Code:
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#include <fakemeta>
#include <engine>

#define VERSION "1.0"

new cvar_knock_force

public plugin_init() 
{
	register_plugin("Knife Stab KB", VERSION, "v3x & chronic/ edit tote")    
	RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack_Post", 1)
	cvar_knock_force = register_cvar("knife_force", "10");
}

public fw_TraceAttack_Post(victim_id, attacker_id)
{
	new victimteam; victimteam = get_user_team(victim_id)
	new attackerteam; attackerteam = get_user_team(attacker_id)
	
	if(get_user_weapon(attacker_id) == CSW_KNIFE && victimteam != attackerteam)
	{
		static buttons
		buttons = pev(attacker_id, pev_button)    
		
		if(buttons & IN_ATTACK2)
		{
			new Float:vec[3];
			new Float:oldvelo[3];
			get_user_velocity(victim_id, oldvelo);
			create_velocity_vector(victim_id , attacker_id , vec);
			vec[0] += oldvelo[0];
			vec[1] += oldvelo[1];
			set_user_velocity(victim_id , vec);
		} 
	}  
} 

// Stock by the one and only, Chronic :P
stock create_velocity_vector(victim,attacker,Float:velocity[3])
{
	if(!is_user_alive(victim) || !is_user_alive(attacker))
		return 0;
	
	new Float:vicorigin[3];
	new Float:attorigin[3];
	entity_get_vector(victim   , EV_VEC_origin , vicorigin);
	entity_get_vector(attacker , EV_VEC_origin , attorigin);
	
	new Float:origin2[3]
	origin2[0] = vicorigin[0] - attorigin[0];
	origin2[1] = vicorigin[1] - attorigin[1];
	
	new Float:largestnum = 0.0;
	
	if(floatabs(origin2[0])>largestnum) largestnum = floatabs(origin2[0]);
	if(floatabs(origin2[1])>largestnum) largestnum = floatabs(origin2[1]);
	
	origin2[0] /= largestnum;
	origin2[1] /= largestnum;
	
	velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_knock_force) * 3000) ) / get_entity_distance(victim , attacker);
	velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knock_force) * 3000) ) / get_entity_distance(victim , attacker);
	if(velocity[0] <= 20.0 || velocity[1] <= 20.0)
		velocity[2] = random_float(200.0 , 275.0);
	
	return 1;
}
Tote is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-26-2024 , 12:54   Re: Knife hit knockback
Reply With Quote #18

Quote:
Originally Posted by Natsheh View Post
The best way and the proper way to do it is to check player's knife attack animation in event traceattack/takedamage.

Bruh who even wrote it his crap ?

/ Stock by the one and only, Chronic
stock create_velocity_vector(victim,attacker,Float: velocity[3])
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 04-26-2024 at 13:35.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
SaraAki
Member
Join Date: Nov 2022
Old 04-27-2024 , 03:36   Re: Knife hit knockback
Reply With Quote #19

Tote,now work only when attack enemy players,but also only when i kill player,killed player get knockbacked.Maybe problem is in velocity stock?
SaraAki is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-27-2024 , 05:34   Re: Knife hit knockback
Reply With Quote #20

If you want an implementation within the plugin post in the plugin thread
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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 07:28.


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