View Single Post
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?
__________________
FREE PLUGINS:

2021 and before -> ALL PLUGIN LINK IS HERE <-

2022:
Zombie: The Original [%70 Completed]

Last edited by ZombieTheMan01; 12-05-2020 at 17:06.
ZombieTheMan01 is offline