Use this sub-plugin:
Code:
#include <amxmodx>
#include <crxknives>
#include <fakemeta>
#include <hamsandwich>
const KNIFE_MIDATTACK1HIT = 6
const KNIFE_MIDATTACK2HIT = 7
#if !defined MAX_PLAYERS
const MAX_PLAYERS = 32
#endif
new const PLUGIN_VERSION[] = "0.1-alpha"
new const ATTRIBUTE_SLASH_DAMAGE[] = "SLASH_DAMAGE"
new const ATTRIBUTE_STAB_DAMAGE[] = "STAB_DAMAGE"
new g_szSlashDamage[MAX_PLAYERS + 1][8]
new g_szStabDamage[MAX_PLAYERS + 1][8]
public plugin_init()
{
register_plugin("CRXKnives: Slash/Stab Damage", PLUGIN_VERSION, "OciXCrom")
register_cvar("CRXKnivesSlashStab", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
RegisterHam(Ham_TakeDamage, "player", "PreTakeDamage", 0)
}
public crxknives_knife_updated(id, iKnife, bool:bOnConnect)
{
if(bOnConnect)
{
g_szSlashDamage[id][0] = EOS
g_szStabDamage[id][0] = EOS
}
if(!crxknives_get_attribute_str(id, ATTRIBUTE_SLASH_DAMAGE, g_szSlashDamage[id], charsmax(g_szSlashDamage[])))
{
g_szSlashDamage[id][0] = EOS
}
if(!crxknives_get_attribute_str(id, ATTRIBUTE_STAB_DAMAGE, g_szStabDamage[id], charsmax(g_szStabDamage[])))
{
g_szStabDamage[id][0] = EOS
}
}
public PreTakeDamage(iVictim, iInflictor, iAttacker, Float:fDamage)
{
if(is_user_connected(iInflictor) && get_user_weapon(iInflictor) == CSW_KNIFE && crxknives_can_use_skill(iInflictor))
{
if(KNIFE_MIDATTACK1HIT <= pev(iInflictor, pev_weaponanim) <= KNIFE_MIDATTACK2HIT)
{
if(g_szSlashDamage[iInflictor][0])
{
SetHamParamFloat(4, math_add_f(fDamage, g_szSlashDamage[iInflictor]))
}
}
else
{
if(g_szStabDamage[iInflictor][0])
{
SetHamParamFloat(4, math_add_f(fDamage, g_szStabDamage[iInflictor]))
}
}
}
}
Float:math_add_f(Float:fNum, const szMath[])
{
static szNewMath[16], Float:fMath, bool:bPercent, cOperator
copy(szNewMath, charsmax(szNewMath), szMath)
bPercent = szNewMath[strlen(szNewMath) - 1] == '%'
cOperator = szNewMath[0]
if(!isdigit(szNewMath[0]))
{
szNewMath[0] = ' '
}
if(bPercent)
{
replace(szNewMath, charsmax(szNewMath), "%", "")
}
trim(szNewMath)
fMath = str_to_float(szNewMath)
if(bPercent)
{
fMath *= fNum / 100
}
switch(cOperator)
{
case '+': fNum += fMath
case '-': fNum -= fMath
case '/': fNum /= fMath
case '*': fNum *= fMath
default: fNum = fMath
}
return fNum
}
Skills usage:
Code:
SLASH_DAMAGE = <left click damage>
STAB_DAMAGE = <right click damage
The format is same as the
DAMAGE skill from the default plugin.
__________________