Senior Member
Join Date: Aug 2015
Location: Turkey
|
12-04-2020
, 16:10
pev_body problem in knife model
|
#1
|
Ladies and gentleman, my problem this time is really important. I somehow passed it off even if I said it was important to others but I really need it. My problem is that my friends, Whatever I do, it doesn't work, even if I try to set the code with the model "pev_body" I set in viewmodel. What should I do for this, my friends. This code is here (can you do it from scratch? How many times have I tried its prototype before. failed, this time I tried to take it from someone and add it to it, but it didn't work.)
PHP Code:
#include <amxmodx>
#include <engine>
#include <hamsandwich>
#include <fakemeta>
#include <fakemeta_util>
#define PLUGIN "CS Weapon Skin"
#define VERSION "0.0.1"
#define AUTHOR "wbyokomo"
#define get_weapon_ent_owner(%1) get_pdata_cbase(%1, 41, 4)
new const ModelKnife[] = "models/zombie_plague/v_knife_chinazombi_karma.mdl"
new Vskin[33]
enum
{
idle = 0,
reload,
draw,
shoot1,
shoot2,
shoot3
}
public plugin_precache()
{
precache_model(ModelKnife)
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event( "CurWeapon","Event_CurWeapon","be", "1=1" );
/*RegisterHam(Ham_Item_Deploy, "weapon_knife", "OnDeployKnifePost", 1)
RegisterHam(Ham_Item_PostFrame, "weapon_knife", "fwd_Item_PostFrame")
RegisterHam(Ham_Weapon_WeaponIdle, "weapon_knife", "IdleAnim", 1)
*//*RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_knife", "fwd_Weapon_PrimaryAttack", 0)
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_knife", "fwd_Weapon_PrimaryAttack", 1)
RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_knife", "fwd_Weapon_SecondaryAttack", 0)
RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_knife", "fwd_Weapon_SecondaryAttack", 1)
*/
register_clcmd("say /skin", "CmdViewSkin")
}
public IdleAnim(ent)
{
new id = get_pdata_cbase(ent, 41, 4)
if(!is_user_alive(id) || get_user_weapon(id) != CSW_KNIFE)
return HAM_IGNORED;
if(get_pdata_float(ent, 48, 4) <= 0.25)
{
UTIL_Anim(id, ent, 0)
set_pev(ent, pev_skin, Vskin[id])
entity_set_int(ent, EV_INT_body, Vskin[id])
set_pdata_float(ent, 48, 20.0, 4)
return HAM_SUPERCEDE;
}
return HAM_IGNORED;
}
public OnDeployKnifePost(ent)
{
static id; id = get_weapon_ent_owner(ent)
set_pev(id, pev_viewmodel2, ModelKnife)
set_pev(ent, pev_skin, Vskin[id])
entity_set_int(ent, EV_INT_body, Vskin[id])
UTIL_Anim(id, ent, 3)
}
public CmdViewSkin(id)
{
Vskin[id] = random_num(0,2)
client_print(id, print_chat, "Current knife skin [%i]", Vskin[id])
}
public Event_CurWeapon( id )
{
if(get_user_weapon(id)==CSW_KNIFE)
{
set_pev(id, pev_viewmodel, engfunc(EngFunc_AllocString, ModelKnife))
new class[32];
get_weaponname(CSW_KNIFE, class, sizeof class - 1);
new weapon = fm_find_ent_by_owner(-1, class, id);
entity_set_int(weapon, EV_INT_body, 1)
set_pev(weapon, pev_body, 1)
}
}
public fwd_Item_PostFrame(ent)
{
new id = get_pdata_cbase(ent, 41, 4)
if(get_pdata_float(ent, 48, 4) <= 0.25)
{
UTIL_Anim(id, ent, 0)
set_pev(ent, pev_skin, Vskin[id])
entity_set_int(ent, EV_INT_body, Vskin[id])
set_pdata_float(ent, 48, 20.0, 4)
return HAM_SUPERCEDE;
}
return HAM_IGNORED
}
public fwd_Weapon_PrimaryAttack(ent)
{
new id = get_pdata_cbase(ent, 41, 4)
entity_set_int(ent, EV_INT_body, Vskin[id])
UTIL_Anim(id, ent, random_num(1, 2))
}
public fwd_Weapon_SecondaryAttack(ent)
{
new id = get_pdata_cbase(ent, 41, 4)
entity_set_int(ent, EV_INT_body, Vskin[id])
UTIL_Anim(id, ent, 4)
}
UTIL_Anim(id, ent, anim)
{
set_pev(id, pev_weaponanim, anim)
set_pev(ent, pev_skin, Vskin[id])
//message_begin(MSG_ONE, SVC_WEAPONANIM, _, id)
message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id)
write_byte(anim)
write_byte(pev(ent, pev_body)) // entity_get_int(ent, EV_INT_body)
message_end()
}
__________________
Last edited by ZombieTheMan01; 01-11-2021 at 04:01.
|
|