PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>
const m_flNextPrimaryAttack = 46
const USE_ANIMATION = 0
new const model[] = "models/v_injectorX.mdl"
new const knife_model[] = "models/v_knife_r.mdl"
public plugin_init()
{
register_clcmd("say f", "clcmd_f")
RegisterHam(Ham_Item_Deploy, "weapon_knife", "weapon_knife", 1)
}
public plugin_precache()
{
precache_model(model)
precache_model(knife_model)
}
public clcmd_f(id)
{
new weapon_model[64]
pev(id, pev_viewmodel2, weapon_model, charsmax(weapon_model))
set_pev(id, pev_viewmodel2, model)
set_pev(id, pev_frame, 0)
UTIL_SenwWeaponAnim(id, USE_ANIMATION)
set_pdata_float(fm_get_user_weapon_entity(id, get_user_weapon(id)), m_flNextPrimaryAttack, 2.83, 4)
set_task(2.83, "end_animation", id, weapon_model, sizeof(weapon_model))
}
public weapon_knife(knife_entity)
{
new id = pev(knife_entity, pev_owner)
if (id)
{
if (get_user_team(id) == 2)
set_pev(id, pev_viewmodel2, knife_model)
}
}
public end_animation(weapon_model[64], id)
{
if (is_user_alive(id))
{
new weapon_entity = fm_get_user_weapon_entity(id, get_user_weapon(id))
ExecuteHam(Ham_Item_Deploy, weapon_entity)
set_pev(id, pev_viewmodel2, weapon_model)
}
}
// https://forums.alliedmods.net/showpost.php?p=2387036&postcount=2
stock UTIL_SenwWeaponAnim(const pPlayer, const Sequence)
{
set_pev(pPlayer, pev_weaponanim, Sequence)
message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = pPlayer)
write_byte(Sequence)
write_byte(pev(pPlayer, pev_body))
message_end()
}
__________________