Raised This Month: $222 Target: $400
 55% 

Remote Knife v1.1


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Gameplay       
WATCH_DOGS UNITED
Member
Join Date: Nov 2020
Location: Matrix
Old 11-08-2020 , 13:01   Remote Knife v1.1
Reply With Quote #1

For Counter-Strike 1.6 and Condition-Zero.

What's new in version 1.1:

Optimized code, now reduced and futile codes have been removed.

Credits:
VEN - base code / get target distance
Bugsy - command automation
hellmonja - target players
Natsheh - code optimization

Description:

This plugin allows your knife to hit your targets at any distance.

You can choose whether anything will be hit, or just players, or just the world ( world = anything except players ).

Commands ( just type and press enter ):

rk_enabled - Activates the plugin. Default value: 1 ( on )

rk_anything - Will hit anything.
rk_players - Will hit only players.
rk_world - Will hit only the world.

Notes:

When you apply one command the others will be automatically disabled.

Flashbangs will only take effect with the function that hits only players ( rk_players ).

Software used:

Sublime Text v3.2

Code:

Code:
/*
	Remote Knife - AMX Mod X script. Copyright  2020, WATCH_DOGS UNITED

	This plugin is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	If you do not know the terms of the GPLv3 you can consult
	it at <https://www.gnu.org/licenses/gpl-3.0.html>

	Description:

	For Counter-Strike 1.6 and Condition-Zero.

	Credits:
	VEN - base code / get target distance
	Bugsy - command automation
	hellmonja - target players
	Natsheh - code optimization

	This plugin allows your knife to hit your targets at any distance.

	You can choose whether anything will be hit, or just players, 
	or just the world ( world = anything except players ).

	Commands ( just type and press enter ):

	rk_enabled - Activates the plugin. Default value: 1 ( on )
	rk_anything - Will hit anything.
	rk_players - Will hit only players.
	rk_world - Will hit only the world.

	Notes:

	When you apply one command the others will be automatically disabled.

	Flashbangs will only take effect with the function that hits only players ( rk_players ).

	Software used:

	Sublime Text v3.2
*/

#include <amxmodx>
#include <fakemeta>
#include <xs>

#define MAX_CLIENTS 32
new g_normal_trace[MAX_CLIENTS + 1]
new bool:g_fix_punchangle[MAX_CLIENTS + 1]

new g_fwid
new g_max_clients
new g_pcvar_rk_enabled

new bool:g_brk_anything, bool:g_brk_players , bool:g_brk_world

new g_guns_eventids_bitsum

public plugin_precache(  ) {
	g_fwid = register_forward( FM_PrecacheEvent , "fwPrecacheEvent" , 1 )
}

public plugin_init(  ) {
	register_plugin(  "Remote Knife"  , "1.1"  , "WATCH_DOGS UNITED"  );

	unregister_forward( FM_PrecacheEvent , g_fwid , 1 )
	g_pcvar_rk_enabled = register_cvar( "rk_enabled" , "1" );

	register_forward( FM_PlaybackEvent , "fwPlaybackEvent" )
	register_forward( FM_TraceLine , "fwTraceLine" )
	g_max_clients = global_get( glb_maxClients )

	register_concmd( "rk_anything" , "enable_rk_anything" );
	register_concmd( "rk_players" , "enable_rk_players" );
	register_concmd( "rk_world" , "enable_rk_world" );
}

public enable_rk_anything()
{
	g_brk_anything = true;
	g_brk_players = false;
	g_brk_world = false;
}

public enable_rk_players()
{
	g_brk_anything = false;
	g_brk_players = true;
	g_brk_world = false;
}

public enable_rk_world()
{
	g_brk_anything = false;
	g_brk_players = false;
	g_brk_world = true;
}

public fwPlaybackEvent( flags , invoker , eventid ) {

	if ( !( g_guns_eventids_bitsum & ( 1<<eventid ) ) || !( 1 <= invoker <= g_max_clients ) )
		return FMRES_IGNORED

	g_fix_punchangle[invoker] = true

	return FMRES_HANDLED
}

public fwTraceLine( const Float:start[3] , const Float:dest[3] , ignore_monsters , id , ptr ) {

	if ( !get_pcvar_num( g_pcvar_rk_enabled ) )
		return FMRES_HANDLED
		
	if ( !( 1 <= id <= g_max_clients ) || !is_user_alive( id ) )
		return FMRES_IGNORED

	if ( !g_normal_trace[id] ) {
		g_normal_trace[id] = ptr
		return FMRES_HANDLED
	}

	static dummy
	if ( ptr == g_normal_trace[id] || ignore_monsters != DONT_IGNORE_MONSTERS || get_user_weapon( id , dummy , dummy ) != CSW_KNIFE )

		return FMRES_IGNORED

	remote_knife_anything( id , start , ptr )
	remote_knife_players( id , start , ptr )
	remote_knife_world( id , start , ptr )

	return FMRES_SUPERCEDE
}

public client_connect( id ) {
	g_normal_trace[id] = 0
}

remote_knife_anything( id , const Float:start[] , ptr ) {

	if ( g_brk_anything )
	{

		static Float:dest[3]
		pev( id , pev_v_angle , dest )
		engfunc( EngFunc_MakeVectors , dest )
		global_get( glb_v_forward , dest )
		xs_vec_mul_scalar( dest , 999999.0 , dest )
		xs_vec_add( start , dest , dest )
		engfunc( EngFunc_TraceLine , start , dest , DONT_IGNORE_MONSTERS , id , ptr )
	}
}

remote_knife_players( id , const Float:start[] , ptr ) {

	if ( g_brk_players )
	{

		new target, body;
		get_user_aiming(id, target, body, 9999);
	
		if(0 < target < 33)
		{
	
			static Float:dest[3]
			pev( id , pev_v_angle , dest )
			engfunc( EngFunc_MakeVectors , dest )
			global_get( glb_v_forward , dest )
			xs_vec_mul_scalar( dest , 999999.0 , dest )
			xs_vec_add( start , dest , dest )
			engfunc( EngFunc_TraceLine , start , dest , DONT_IGNORE_MONSTERS , id , ptr )
		}
	}
}

remote_knife_world( id , const Float:start[] , ptr ) {

	if ( g_brk_world )
	{

		static Float:dest[3]
		pev( id , pev_v_angle , dest )
		engfunc( EngFunc_MakeVectors , dest )
		global_get( glb_v_forward , dest )
		xs_vec_mul_scalar( dest , 999999.0 , dest )
		xs_vec_add( start , dest , dest )
		engfunc( EngFunc_TraceLine , start , dest , IGNORE_MONSTERS , id , ptr )
	}
}
Attached Files
File Type: sma Get Plugin or Get Source (remote_knife.sma - 56 views - 5.0 KB)
__________________
Copyright 2020-2021, WATCH_DOGS UNITED All Rights Reversed

Last edited by WATCH_DOGS UNITED; 11-14-2020 at 22:06. Reason: Updated to v1.1
WATCH_DOGS UNITED is offline
karaulov
Senior Member
Join Date: Jul 2018
Old 11-09-2020 , 03:24   Re: Remote Knife v1.0
Reply With Quote #2

This plugin replace default knife attack to throwing a knives?
karaulov is offline
WATCH_DOGS UNITED
Member
Join Date: Nov 2020
Location: Matrix
Old 11-09-2020 , 08:27   Re: Remote Knife v1.0
Reply With Quote #3

Quote:
Originally Posted by karaulov View Post
This plugin replace default knife attack to throwing a knives?
The knife will not be thrown, it will hit targets at any distance as if you are close to the target
__________________
Copyright 2020-2021, WATCH_DOGS UNITED All Rights Reversed
WATCH_DOGS UNITED is offline
tarsisd2
Veteran Member
Join Date: Feb 2016
Location: brazil
Old 11-09-2020 , 11:47   Re: Remote Knife v1.0
Reply With Quote #4

this seems a bit strange, so if i aim at a player from other side of the map and just hit knife attack i will hit him?
tarsisd2 is offline
WATCH_DOGS UNITED
Member
Join Date: Nov 2020
Location: Matrix
Old 11-09-2020 , 13:19   Re: Remote Knife v1.0
Reply With Quote #5

Quote:
Originally Posted by tarsisd2 View Post
this seems a bit strange, so if i aim at a player from other side of the map and just hit knife attack i will hit him?
Exactly.
__________________
Copyright 2020-2021, WATCH_DOGS UNITED All Rights Reversed
WATCH_DOGS UNITED is offline
rrduna
Member
Join Date: Nov 2010
Location: Brazil
Old 11-11-2020 , 09:30   Re: Remote Knife v1.0
Reply With Quote #6

looks pretty cool
rrduna is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 11-14-2020 , 10:55   Re: Remote Knife v1.0
Reply With Quote #7

An optimisation instead of calling get_user_weapon multiple times in the traceline forward at the check save it in a static variable.

Edit: i added some comments in the script, i just spotted some mistakes you currently have.

Spoiler
__________________
@Jailbreak Main Mod v2.6.5 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Last edited by Natsheh; 11-14-2020 at 20:51.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
WATCH_DOGS UNITED
Member
Join Date: Nov 2020
Location: Matrix
Old 11-14-2020 , 21:41   Re: Remote Knife v1.0
Reply With Quote #8

Thank you very much for your help Natsheh, the plugin has been updated.
__________________
Copyright 2020-2021, WATCH_DOGS UNITED All Rights Reversed
WATCH_DOGS UNITED 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 06:33.


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