const ANIM_IMPULSE = 100 // flashlight
const INSPECT_ANIM_NUM = 8
const Float:INSPECT_ANIM_TIME = 6.0
#include <amxmodx>
#include <engine>
#include <hamsandwich>
#include <fakemeta>
#include <cstrike>
// offsets
const m_iId = 43
const m_pActiveItem = 373
const m_flTimeWeaponIdle = 48
const XO_WEAPON = 4
const PDATA_SAFE = 2
public plugin_init()
{
register_plugin("KNIFE Inspect", "0.0.3", "Vaqtincha")
register_impulse(ANIM_IMPULSE, "ClCmd_Impulse")
}
public ClCmd_Impulse(const pPlayer)
{
if(!is_user_alive(pPlayer))
return PLUGIN_CONTINUE
new pActiveItem = get_pdata_cbase(pPlayer, m_pActiveItem)
if(pev_valid(pActiveItem)== PDATA_SAFE && get_pdata_int(pActiveItem, m_iId, XO_WEAPON) == CSW_AK47)
{
SendWeaponAnim(pPlayer, pActiveItem, INSPECT_ANIM_NUM, INSPECT_ANIM_TIME)
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
stock SendWeaponAnim(const pPlayer, const pWeapon, const iAnim, const Float:flAnimTime)
{
if(pev(pPlayer, pev_weaponanim) == iAnim)
return
set_pev(pPlayer, pev_weaponanim, iAnim)
message_begin(MSG_ONE, SVC_WEAPONANIM, .player = pPlayer)
write_byte(iAnim)
write_byte(0) // pev(pWeapon, pev_body)
message_end()
set_pdata_float(pWeapon, m_flTimeWeaponIdle, flAnimTime, XO_WEAPON)
}