Drak
04-30-2008, 18:55
I'm trying to make the scope on Half-Life's 357 weapon. (It's in the model, second body)
Setting "pev_body" doesn't work, alone atleast. This is how I'm doing it:
UTIL_SetModel(id,bool:OnOff)
{
new ent = fm_get_user_weapon_entity(id);
if(ent)
{
if(OnOff)
{
set_pev(ent,pev_body,1);
_UTIL_SendWpnAnination(id,5,1,ent);
}
else
{
set_pev(ent,pev_body,0);
_UTIL_SendWpnAnination(id,0,0,ent);
}
}
}
_UTIL_SendWpnAnination(id,anim,body,ent)
{
set_pev(id,pev_viewmodel2,"models/v_357.mdl");
message_begin(MSG_ONE,SVC_WEAPONANIM,{0,0,0}, id);
write_byte(anim);
write_byte(pev(ent,pev_body))
message_end();
}
// Below code is copied from fakemeta_util.inc by VEN
// if weapon index isn't passed then assuming that it's the current weapon
stock fm_get_user_weapon_entity(id, wid = 0)
{
new weap = wid, clip, ammo
if (!weap && !(weap = get_user_weapon(id, clip, ammo)))
return 0
new class[32]
get_weaponname(weap, class, sizeof class - 1)
return fm_find_ent_by_owner(-1, class, id)
}
stock fm_find_ent_by_owner(index, const classname[], owner, jghgtype = 0)
{
new strtype[11] = "classname", ent = index
switch (jghgtype) {
case 1: strtype = "target"
case 2: strtype = "targetname"
}
while ((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner) {}
return ent
}
When setting the model "UTIL_SetModel(id,true)" works. Soon as the weapon plays an animation, the body is set back to zero. Putting "UTIL_SetModel" in prethink, doesn't seem like a good idea. Even though it works. Is there anyway other way I can get this to work?
Setting "pev_body" doesn't work, alone atleast. This is how I'm doing it:
UTIL_SetModel(id,bool:OnOff)
{
new ent = fm_get_user_weapon_entity(id);
if(ent)
{
if(OnOff)
{
set_pev(ent,pev_body,1);
_UTIL_SendWpnAnination(id,5,1,ent);
}
else
{
set_pev(ent,pev_body,0);
_UTIL_SendWpnAnination(id,0,0,ent);
}
}
}
_UTIL_SendWpnAnination(id,anim,body,ent)
{
set_pev(id,pev_viewmodel2,"models/v_357.mdl");
message_begin(MSG_ONE,SVC_WEAPONANIM,{0,0,0}, id);
write_byte(anim);
write_byte(pev(ent,pev_body))
message_end();
}
// Below code is copied from fakemeta_util.inc by VEN
// if weapon index isn't passed then assuming that it's the current weapon
stock fm_get_user_weapon_entity(id, wid = 0)
{
new weap = wid, clip, ammo
if (!weap && !(weap = get_user_weapon(id, clip, ammo)))
return 0
new class[32]
get_weaponname(weap, class, sizeof class - 1)
return fm_find_ent_by_owner(-1, class, id)
}
stock fm_find_ent_by_owner(index, const classname[], owner, jghgtype = 0)
{
new strtype[11] = "classname", ent = index
switch (jghgtype) {
case 1: strtype = "target"
case 2: strtype = "targetname"
}
while ((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner) {}
return ent
}
When setting the model "UTIL_SetModel(id,true)" works. Soon as the weapon plays an animation, the body is set back to zero. Putting "UTIL_SetModel" in prethink, doesn't seem like a good idea. Even though it works. Is there anyway other way I can get this to work?