Code
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#pragma tabsize 0
#define PLUGIN "KNIFE AXE"
#define VERSION "1.0"
#define AUTHOR "daywer"
new const c_sounds[][] =
{
"skullaxe/_deploy1.wav",
"skullaxe/1.wav",
"skullaxe/2.wav",
"skullaxe/_hwall.wav",
"skullaxe/_slash1.wav",
"skullaxe/_stab.wav"
}
new const oldknife_sounds[][] =
{
"weapons/knife_deploy1.wav",
"weapons/knife_hit1.wav",
"weapons/knife_hit2.wav",
"weapons/knife_hitwall1.wav",
"weapons/knife_slash1.wav",
"weapons/knife_stab.wav"
}
new KNIFE_V_MODEL[] = "models/v_skullaxe.mdl"
new KNIFE_P_MODEL[] = "models/p_skullaxe.mdl"
public plugin_init()
{
register_plugin(PLUGIN , VERSION , AUTHOR);
RegisterHam(Ham_Item_Deploy, "weapon_knife", "Ham_Item_Deploy_post", -1)
register_forward(FM_EmitSound, "fw_EmitSound");
RegisterHam(Ham_Weapon_SecondaryAttack ,"weapon_knife","f_knife_attack_sec")
RegisterHam(Ham_Weapon_PrimaryAttack ,"weapon_knife","f_knife_attack_prim")
}
public fw_EmitSound(id, channel, const sound[])
{
if(!is_user_alive(id))
return FMRES_IGNORED
for(new i = 0; i < sizeof c_sounds; i++)
{
if(equal(sound, oldknife_sounds[i]))
{
emit_sound(id, channel, c_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
return FMRES_SUPERCEDE
}
}
return FMRES_IGNORED
}
public f_knife_attack_prim(weapon)
{
set_pdata_float(weapon, 46, 0.1, 5)
}
public f_knife_attack_sec(weapon)
{
set_pdata_float(weapon, 46, 0.5, 5)
}
public plugin_precache()
{
precache_model(KNIFE_V_MODEL)
precache_model(KNIFE_P_MODEL)
for(new i = 0; i < sizeof c_sounds; i++)
precache_sound(c_sounds[i])
}
public Ham_Item_Deploy_post(weapon_ent)
{
static id; id = get_pdata_cbase(weapon_ent, 41, 4)
set_pev(id, pev_viewmodel2, KNIFE_V_MODEL)
set_pev(id, pev_weaponmodel2, KNIFE_P_MODEL)
}