PHP 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
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.0" , "WATCH_DOGS UNITED" );
unregister_forward( FM_PrecacheEvent , g_fwid , 1 )
g_pcvar_rk_enabled = register_cvar( "rk_enabled" , "1" );
register_forward( FM_PlaybackEvent , "fwPlaybackEvent" )
// in what reason you're registering player post think post ? there're no "fwPlayerPostThink" function.
// --------> register_forward( FM_PlayerPostThink , "fwPlayerPostThink" , 1 )
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
}
// why just not check if he isn't holding a knife?
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 )
}
}