Try this :
PHP Code:
/* Copyright © 2009, ConnorMcLeod
Knife KnockBack 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.
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.
You should have received a copy of the GNU General Public License
along with Knife KnockBack; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <xs>
#define PLUGIN "Knife KnockBack"
#define AUTHOR "ConnorMcLeod"
#define VERSION "0.0.1"
new g_pCvarKnockBack
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
g_pCvarKnockBack = register_cvar("amx_knife_knockback", "10")
RegisterHam(Ham_TakeDamage, "player", "Player_TakeDamage", 1)
}
public Player_TakeDamage(id, idinflictor, idattacker, Float:flDamage, damagebits)
{
if( !idattacker
|| id == idattacker
|| idinflictor != idattacker// )
|| get_user_weapon(idattacker) != CSW_KNIFE )
{
return
}
new Float:fDir[3], Float:fOrigin[3], Float:fVelocity[3]
pev(id, pev_origin, fDir)
pev(idattacker, pev_origin, fOrigin)
xs_vec_sub(fDir, fOrigin, fDir)
xs_vec_normalize(fDir, fDir)
flDamage *= get_pcvar_num(g_pCvarKnockBack)
if( flDamage > 1500.0 )
flDamage = 1500.0
pev(id, pev_velocity, fVelocity)
xs_vec_mul_scalar(fDir, flDamage, fDir)
xs_vec_add(fVelocity, fDir, fVelocity)
set_pev(id, pev_velocity, fVelocity)
}
__________________