Beispiel #1
0
void CPedRPCs::SetPedAnimation ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    // Read out the player and vehicle id
    char szBlockName [ 64 ], szAnimName [ 64 ];
    unsigned char ucBlockSize, ucAnimSize;
    int iTime;
    bool bLoop, bUpdatePosition, bInterruptable, bFreezeLastFrame;

    if ( bitStream.Read ( ucBlockSize ) )
    {
        // Grab the ped
        CClientPed * pPed = m_pPedManager->Get ( pSource->GetID (), true );
        if ( pPed )
        {
            if ( ucBlockSize > 0 )
            {
                if ( bitStream.Read ( szBlockName, ucBlockSize ) &&
                    bitStream.Read ( ucAnimSize ) )
                {
                    szBlockName [ ucBlockSize ] = 0;
                    if ( bitStream.Read ( szAnimName, ucAnimSize ) &&
                         bitStream.Read ( iTime ) &&
                         bitStream.ReadBit ( bLoop ) &&
                         bitStream.ReadBit ( bUpdatePosition ) &&
                         bitStream.ReadBit ( bInterruptable ) &&
                         bitStream.ReadBit ( bFreezeLastFrame ) )
                    {
                        szAnimName [ ucAnimSize ] = 0;

                        CAnimBlock * pBlock = g_pGame->GetAnimManager ()->GetAnimationBlock ( szBlockName );
                        if ( pBlock )
                        {
                            pPed->RunNamedAnimation ( pBlock, szAnimName, iTime, bLoop, bUpdatePosition, bInterruptable, bFreezeLastFrame );
                        }
                    }
                }
            }
            else
            {
                pPed->KillAnimation ();
            }
        }
    }
}