View Single Post
hekaUA
Junior Member
Join Date: Mar 2014
Old 11-09-2014 , 11:22   Re: Changing Sub-Model of v_ model
Reply With Quote #21

Quote:
Originally Posted by meTaLiCroSS View Post
Problem is that client predicts animations. That's handled by the cl_lw cvar, and it was made for saving bandwidth. Server will know about cl_lw value of every client. And mod gets that value with CanSkipPlayer function.

SendWeaponAnim function it's the one who """sends""" animations to client. But they are never sent. Source code from CS:

PHP Code:
void CBasePlayerWeapon::SendWeaponAnim(int animationint skiplocal)
{
  
m_pPlayer->pev->weaponanim animation;
  if ( !
skiplocal || !ENGINE_CANSKIPm_pPlayer->edict() ) )
  {
    
MESSAGE_BEGINMSG_ONESVC_WEAPONANIMNULLm_pPlayer->pev );
    
WRITE_BYTEiAnim );                        // sequence number
    
WRITE_BYTEpev->body );                    // weaponmodel bodygroup.
    
MESSAGE_END();
  }

On CS, SendWeaponAnim is present on every specific event that animation should be sent (idle, reload, grenade/c4 specific, etc). But SVC_WEAPONANIM msg is never send because skiplocal param is always true and ENGINE_CANSKIP will return 1 if client has cl_lw cvar enabled. So, guessing, this would be never called.

If you want to force animation send to client, just hook FM_CanSkipPlayer, make it return false, and recode weapon fire animation because CS didn't implement that thing on PrimaryAttack functions. (hook PlaybackEvent as a method described on a tutorial, forget which one)

By following this logic, you'll just need to edit weapon entity's pev_body value to the correct handgroup you want to show to player.

Also, I haven't tested this because I don't know if client predicts first and gets a response then, because in that case animations will screw up and this will go hell
public UTIL_SendWeaponAnim(iPlayer, iAnim)
{
set_pev(iPlayer, pev_weaponanim, iAnim)
message_begin(MSG_ONE, SVC_WEAPONANIM, _, iPlayer)
write_byte(iAnim)
if(engfunc(EngFunc_CanSkipPlayer(iPlayer)) write_byte(1)
message_end()
}
Attached Images
File Type: jpg 51241.jpg (83.0 KB, 330 views)
hekaUA is offline