Raised This Month: $319 Target: $400
 79%   Almost there!

Solved pev_body problem in knife model


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ZombieTheMan01
Senior Member
Join Date: Aug 2015
Location: Turkey
Old 12-04-2020 , 16:10   pev_body problem in knife model
Reply With Quote #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(PLUGINVERSIONAUTHOR)
    
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(ent414)
    
    if(!
is_user_alive(id) || get_user_weapon(id) != CSW_KNIFE)
        return 
HAM_IGNORED;
    
    if(
get_pdata_float(ent484) <= 0.25)
    {
        
UTIL_Anim(ident0)
        
set_pev(entpev_skinVskin[id])
        
entity_set_int(entEV_INT_bodyVskin[id])
        
set_pdata_float(ent4820.04)
        return 
HAM_SUPERCEDE;
    }
    return 
HAM_IGNORED;
}

public 
OnDeployKnifePost(ent)
{
    static 
idid get_weapon_ent_owner(ent)
    
set_pev(idpev_viewmodel2ModelKnife)
    
set_pev(entpev_skinVskin[id])
    
entity_set_int(entEV_INT_bodyVskin[id])
    
UTIL_Anim(ident3)
}

public 
CmdViewSkin(id)
{
    
Vskin[id] = random_num(0,2)
    
client_print(idprint_chat"Current knife skin [%i]"Vskin[id])
}

public 
Event_CurWeaponid )
{
    if(
get_user_weapon(id)==CSW_KNIFE)
    {
        
set_pev(idpev_viewmodelengfunc(EngFunc_AllocStringModelKnife))
        new class[
32];
        
get_weaponname(CSW_KNIFE, class, sizeof class - 1);
        new 
weapon fm_find_ent_by_owner(-1, class, id);
        
entity_set_int(weaponEV_INT_body1)
        
set_pev(weaponpev_body1)
    }
}

public 
fwd_Item_PostFrame(ent)
{
    new 
id get_pdata_cbase(ent414)
    if(
get_pdata_float(ent484) <= 0.25)
    {
        
UTIL_Anim(ident0)
        
set_pev(entpev_skinVskin[id])
        
entity_set_int(entEV_INT_bodyVskin[id])
        
set_pdata_float(ent4820.04)
        return 
HAM_SUPERCEDE;
    }
    return 
HAM_IGNORED
    
}

public 
fwd_Weapon_PrimaryAttack(ent)
{
    new 
id get_pdata_cbase(ent414)
    
entity_set_int(entEV_INT_bodyVskin[id])
    
    
UTIL_Anim(identrandom_num(12))
}


public 
fwd_Weapon_SecondaryAttack(ent)
{
    new 
id get_pdata_cbase(ent414)
    
entity_set_int(entEV_INT_bodyVskin[id])
    
    
UTIL_Anim(ident4)
}

UTIL_Anim(identanim)
{
    
set_pev(idpev_weaponanimanim)
    
set_pev(entpev_skinVskin[id])
    
//message_begin(MSG_ONE, SVC_WEAPONANIM, _, id)
    
message_begin(MSG_ONE_UNRELIABLESVC_WEAPONANIM, {000}, id)
    
write_byte(anim)
    
write_byte(pev(entpev_body)) // entity_get_int(ent, EV_INT_body)
    
message_end()

Attached Files
File Type: zip model.zip (676.6 KB, 23 views)
__________________

Last edited by ZombieTheMan01; 01-11-2021 at 04:01.
ZombieTheMan01 is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 12-05-2020 , 05:52   Re: pev_body problem in knife model
Reply With Quote #2

Could you perhaps share some debug/console logs? Also comment every other function you're not using at the moment. That could also hold the plugin from working...
__________________
My Plugins:


Accepting private projects.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-05-2020 , 08:23   Re: pev_body problem in knife model
Reply With Quote #3

well, what you're trying to do is not that simple. The only method that "seems" to work is blocking client-side prediction but then you would have to remake the entire weapon, see https://forums.alliedmods.net/showthread.php?t=287260 and https://forums.alliedmods.net/showthread.php?t=287754

By the way, there is a request in valve github about adding a new client message called "ViewModel". You can see the topic here https://github.com/ValveSoftware/halflife/issues/199, but basically the message would allow developers to do exactly what you're trying, yet set_rendering in viewmodels. It's quite a cool feature but the topic is open since 2013 so yea, I doubt it's ever going to be released.

Otherwise, you'll have to stick with the "fill your server with a bunch of models and set EV_SZ_viewmodel" method.
__________________




CrazY. is offline
ZombieTheMan01
Senior Member
Join Date: Aug 2015
Location: Turkey
Old 12-05-2020 , 17:05   Re: pev_body problem in knife model
Reply With Quote #4

Quote:
Originally Posted by CrazY. View Post
well, what you're trying to do is not that simple. The only method that "seems" to work is blocking client-side prediction but then you would have to remake the entire weapon, see https://forums.alliedmods.net/showthread.php?t=287260 and https://forums.alliedmods.net/showthread.php?t=287754

By the way, there is a request in valve github about adding a new client message called "ViewModel". You can see the topic here https://github.com/ValveSoftware/halflife/issues/199, but basically the message would allow developers to do exactly what you're trying, yet set_rendering in viewmodels. It's quite a cool feature but the topic is open since 2013 so yea, I doubt it's ever going to be released.

Otherwise, you'll have to stick with the "fill your server with a bunch of models and set EV_SZ_viewmodel" method.

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
/*#include <zombieplague>
#include <zombiemode3_extrainc>
*/
// CBasePlayerItem
stock m_pPlayer 41 // CBasePlayer *
// CBasePlayerWeapon
stock m_flNextPrimaryAttack 46 // float
stock m_flNextSecondaryAttack 47 // float
stock m_flTimeWeaponIdle 48 // float
// CBaseMonster
stock m_flNextAttack 83 // float
// CBasePlayer
stock m_pActiveItem 373 // CBasePlayerItem *
#define WPN_KNIFE 1500 // Weapon
#define WEAPON_KNIFE(%0) (pev(%0, pev_impulse) == WPN_KNIFE)
new const V_GIRL_KNIFE[] = "models/v_knife_chinazombi_karma.mdl";
new 
cvar_switch_sexg_iKnife_w;
new 
Vskin[33]
public 
plugin_init() {
    
register_plugin("weapon_knife""1.3""Hanna");
    
register_forward(FM_UpdateClientData"Forward_UpdateClientData_Post"1);
    
RegisterHam(Ham_Item_AddToPlayer"weapon_knife""HamF_Item_AddToPlayer_Post"1);
    
RegisterHam(Ham_Item_Deploy"weapon_knife""HamF_Item_Deploy_Post"1);
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_knife""HamF_Weapon_PrimaryAttack");
    
RegisterHam(Ham_Weapon_SecondaryAttack"weapon_knife""HamF_Weapon_SecondaryAttack");
    
RegisterHam(Ham_Weapon_WeaponIdle"weapon_knife""HamF_Weapon_WeaponIdle");
    
register_clcmd("say /skin""CmdViewSkin")
    
g_iKnife_w engfunc(EngFunc_AllocStringV_GIRL_KNIFE);
    
//cvar_switch_sex = register_cvar("switch_sex", "1");
}
public 
plugin_precache()    engfunc(EngFunc_PrecacheModelV_GIRL_KNIFE);    
public 
Forward_UpdateClientData_Post(idiWeaponsiCD) {
    if(
iWeapons) {
        static 
iEntiEnt get_pdata_cbase(idm_pActiveItem5);
        if(!
is_user_alive(id) || !WEAPON_KNIFE(iEnt))    return FMRES_IGNORED;
        
set_cd(iCDCD_ID0);
    }
    return 
FMRES_HANDLED;    
}
public 
HamF_Item_AddToPlayer_Post(iEntpPlayer)    set_pev(iEntpev_impulseWPN_KNIFE);    //Checkout
public HamF_Item_Deploy_Post(iEnt) {
    if(!
WEAPON_KNIFE(iEnt))    return HAM_IGNORED;    
    static 
idid get_pdata_cbase(iEntm_pPlayer4);
    
set_pdata_float(idm_flNextAttack1.05);
    
set_pdata_float(iEntm_flTimeWeaponIdle2.54);
    
set_pev(idpev_viewmodelg_iKnife_w);
    
UTIL_SendWeaponAnim(id3);
    return 
HAM_IGNORED;        
}
public 
HamF_Weapon_PrimaryAttack(iEnt) {
    if(!
WEAPON_KNIFE(iEnt))    return HAM_IGNORED;
    static 
idid get_pdata_cbase(iEntm_pPlayer4);    
    
ExecuteHam(Ham_Weapon_PrimaryAttackiEnt);
    
set_pdata_float(idm_flNextAttack0.55);
    
set_pdata_float(iEntm_flTimeWeaponIdle1.24);
    if(
pev(idpev_weaponanim) == 6)    UTIL_SendWeaponAnim(id6);
    else    
UTIL_SendWeaponAnim(id7);
    return 
HAM_SUPERCEDE;    
}
public 
HamF_Weapon_SecondaryAttack(iEnt)    {
    if(!
WEAPON_KNIFE(iEnt))    return HAM_IGNORED;
    static 
idid get_pdata_cbase(iEntm_pPlayer4);    
    
ExecuteHam(Ham_Weapon_PrimaryAttackiEnt);
    
set_pdata_float(idm_flNextAttack1.55);
    
set_pdata_float(iEntm_flTimeWeaponIdle2.54);
    if(
pev(idpev_weaponanim) == 5)    UTIL_SendWeaponAnim(id5);
    else    
UTIL_SendWeaponAnim(id4);
    return 
HAM_SUPERCEDE;    
}
public 
HamF_Weapon_WeaponIdle(iEnt) {
    if(!
WEAPON_KNIFE(iEnt))    return HAM_IGNORED;
    static 
idid get_pdata_cbase(iEntm_pPlayer4);    
    if(
get_pdata_float(iEntm_flTimeWeaponIdle4) > 0.0)    return HAM_IGNORED;
    
UTIL_SendWeaponAnim(id0);
    
set_pdata_float(iEntm_flTimeWeaponIdle13.04);    
    return 
HAM_SUPERCEDE;    
}
UTIL_SendWeaponAnim(pPlayeriAnim) {
    
set_pev(pPlayerpev_weaponanimiAnim);
    
message_begin(MSG_ONE_UNRELIABLESVC_WEAPONANIM_pPlayer);
    
write_byte(iAnim);    
    
//write_byte(zb3_get_zombie_evolution_level(pPlayer));
    
write_byte(Vskin[pPlayer])
    
message_end();    
}

public 
CmdViewSkin(id)
{
    
Vskin[id] = random_num(0,2)
    
client_print(idprint_chat"Current knife skin [%i]"Vskin[id])

everything is ok until here. It makes me a little bit of trouble after that. because by the problem I mean CD_ID. Even when making this model "cl_lw 0", it becomes a different one anyway, and this command causes problems in some models. I wonder if I go to other plugins via CD_ID? Or are we going to execute commands from another set_cd?
__________________

Last edited by ZombieTheMan01; 12-05-2020 at 17:06.
ZombieTheMan01 is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-06-2020 , 07:40   Re: pev_body problem in knife model
Reply With Quote #5

I made something similar to what you're trying .I couldn't remember the title but luckily I found it, there you go https://forums.alliedmods.net/showpo...51&postcount=5

Quote:
I wonder if I go to other plugins via CD_ID? Or are we going to execute commands from another set_cd?
Maybe I misunderstood you, but I would say no. There is only one data per client and it's shared across all the plugins
__________________




CrazY. is offline
ZombieTheMan01
Senior Member
Join Date: Aug 2015
Location: Turkey
Old 12-07-2020 , 04:18   Re: pev_body problem in knife model
Reply With Quote #6

Quote:
Originally Posted by CrazY. View Post
I made something similar to what you're trying .I couldn't remember the title but luckily I found it, there you go https://forums.alliedmods.net/showpo...51&postcount=5



Maybe I misunderstood you, but I would say no. There is only one data per client and it's shared across all the plugins
No. Something else I mean. In knife models, it should be in the place where it should be adjusted normally, but the opposite happens (so, when setting cl_lw to 0, the knife model is on the left if it is on the right).. That's why I said. I only got the cd_weaponanim part from the code you provided, but it does not work only in draw animation.
__________________

Last edited by ZombieTheMan01; 12-07-2020 at 04:19.
ZombieTheMan01 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:07.


Powered by vBulletin®
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Theme made by Freecode