Senior Member
Join Date: Aug 2015
Location: Turkey
|
12-05-2020
, 17:05
Re: pev_body problem in knife model
|
#4
|
Quote:
Originally Posted by CrazY.
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_sex, g_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_AllocString, V_GIRL_KNIFE); //cvar_switch_sex = register_cvar("switch_sex", "1"); } public plugin_precache() engfunc(EngFunc_PrecacheModel, V_GIRL_KNIFE); public Forward_UpdateClientData_Post(id, iWeapons, iCD) { if(iWeapons) { static iEnt; iEnt = get_pdata_cbase(id, m_pActiveItem, 5); if(!is_user_alive(id) || !WEAPON_KNIFE(iEnt)) return FMRES_IGNORED; set_cd(iCD, CD_ID, 0); } return FMRES_HANDLED; } public HamF_Item_AddToPlayer_Post(iEnt, pPlayer) set_pev(iEnt, pev_impulse, WPN_KNIFE); //Checkout public HamF_Item_Deploy_Post(iEnt) { if(!WEAPON_KNIFE(iEnt)) return HAM_IGNORED; static id; id = get_pdata_cbase(iEnt, m_pPlayer, 4); set_pdata_float(id, m_flNextAttack, 1.0, 5); set_pdata_float(iEnt, m_flTimeWeaponIdle, 2.5, 4); set_pev(id, pev_viewmodel, g_iKnife_w); UTIL_SendWeaponAnim(id, 3); return HAM_IGNORED; } public HamF_Weapon_PrimaryAttack(iEnt) { if(!WEAPON_KNIFE(iEnt)) return HAM_IGNORED; static id; id = get_pdata_cbase(iEnt, m_pPlayer, 4); ExecuteHam(Ham_Weapon_PrimaryAttack, iEnt); set_pdata_float(id, m_flNextAttack, 0.5, 5); set_pdata_float(iEnt, m_flTimeWeaponIdle, 1.2, 4); if(pev(id, pev_weaponanim) == 6) UTIL_SendWeaponAnim(id, 6); else UTIL_SendWeaponAnim(id, 7); return HAM_SUPERCEDE; } public HamF_Weapon_SecondaryAttack(iEnt) { if(!WEAPON_KNIFE(iEnt)) return HAM_IGNORED; static id; id = get_pdata_cbase(iEnt, m_pPlayer, 4); ExecuteHam(Ham_Weapon_PrimaryAttack, iEnt); set_pdata_float(id, m_flNextAttack, 1.5, 5); set_pdata_float(iEnt, m_flTimeWeaponIdle, 2.5, 4); if(pev(id, pev_weaponanim) == 5) UTIL_SendWeaponAnim(id, 5); else UTIL_SendWeaponAnim(id, 4); return HAM_SUPERCEDE; } public HamF_Weapon_WeaponIdle(iEnt) { if(!WEAPON_KNIFE(iEnt)) return HAM_IGNORED; static id; id = get_pdata_cbase(iEnt, m_pPlayer, 4); if(get_pdata_float(iEnt, m_flTimeWeaponIdle, 4) > 0.0) return HAM_IGNORED; UTIL_SendWeaponAnim(id, 0); set_pdata_float(iEnt, m_flTimeWeaponIdle, 13.0, 4); return HAM_SUPERCEDE; } UTIL_SendWeaponAnim(pPlayer, iAnim) { set_pev(pPlayer, pev_weaponanim, iAnim); message_begin(MSG_ONE_UNRELIABLE, SVC_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(id, print_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.
|
|