当前位置: 首页>>代码示例>>C++>>正文


C++ CClientPlayer::GetOccupiedVehicle方法代码示例

本文整理汇总了C++中CClientPlayer::GetOccupiedVehicle方法的典型用法代码示例。如果您正苦于以下问题:C++ CClientPlayer::GetOccupiedVehicle方法的具体用法?C++ CClientPlayer::GetOccupiedVehicle怎么用?C++ CClientPlayer::GetOccupiedVehicle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CClientPlayer的用法示例。


在下文中一共展示了CClientPlayer::GetOccupiedVehicle方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ReadLocalData

void CClientPacketRecorder::ReadLocalData(FILE* pFile)
{
    // Grab the local player
    CClientPlayer* pPlayer = m_pManager->GetPlayerManager()->GetLocalPlayer();
    if (pPlayer)
    {
        // Grab the vehicle
        CClientVehicle* pVehicle = pPlayer->GetOccupiedVehicle();
        if (pVehicle)
        {
            // Temp vars
            CMatrix matVehicle;
            CVector vecMoveSpeed;
            CVector vecTurnSpeed;
            float   fHealth;

            // Read it out
            fread(&matVehicle.vRight.fX, sizeof(float), 1, pFile);
            fread(&matVehicle.vRight.fY, sizeof(float), 1, pFile);
            fread(&matVehicle.vRight.fZ, sizeof(float), 1, pFile);

            fread(&matVehicle.vFront.fX, sizeof(float), 1, pFile);
            fread(&matVehicle.vFront.fY, sizeof(float), 1, pFile);
            fread(&matVehicle.vFront.fZ, sizeof(float), 1, pFile);

            fread(&matVehicle.vUp.fX, sizeof(float), 1, pFile);
            fread(&matVehicle.vUp.fY, sizeof(float), 1, pFile);
            fread(&matVehicle.vUp.fZ, sizeof(float), 1, pFile);

            fread(&matVehicle.vPos.fX, sizeof(float), 1, pFile);
            fread(&matVehicle.vPos.fY, sizeof(float), 1, pFile);
            fread(&matVehicle.vPos.fZ, sizeof(float), 1, pFile);

            fread(&vecMoveSpeed.fX, sizeof(float), 1, pFile);
            fread(&vecMoveSpeed.fY, sizeof(float), 1, pFile);
            fread(&vecMoveSpeed.fZ, sizeof(float), 1, pFile);

            fread(&vecTurnSpeed.fX, sizeof(float), 1, pFile);
            fread(&vecTurnSpeed.fY, sizeof(float), 1, pFile);
            fread(&vecTurnSpeed.fZ, sizeof(float), 1, pFile);
            fread(&fHealth, sizeof(float), 1, pFile);

            CControllerState cs;
            fread(&cs, sizeof(CControllerState), 1, pFile);

            // Set the data
            pVehicle->SetMatrix(matVehicle);
            pVehicle->SetMoveSpeed(vecMoveSpeed);
            pVehicle->SetTurnSpeed(vecTurnSpeed);
            pVehicle->SetHealth(fHealth);

            // Set the controller state
            CControllerState csLast;
            g_pGame->GetPad()->Disable(true);
            g_pGame->GetPad()->GetCurrentControllerState(&csLast);
            g_pGame->GetPad()->SetLastControllerState(&csLast);
            g_pGame->GetPad()->SetCurrentControllerState(&cs);
        }
    }
}
开发者ID:ccw808,项目名称:mtasa-blue,代码行数:60,代码来源:CClientPacketRecorder.cpp

示例2: DoPulse

void CClientPlayerManager::DoPulse ( void )
{
    unsigned long ulCurrentTime = CClientTime::GetTime ();
    CClientPlayer * pPlayer = NULL;
    vector < CClientPlayer* > ::const_iterator iter = m_Players.begin ();
    for ( ; iter != m_Players.end (); ++iter )
    {
        pPlayer = *iter;

        if ( !pPlayer->IsLocalPlayer () )
        {
            // Pulse voice data if voice is enabled
            if ( g_pClientGame->GetVoiceRecorder()->IsEnabled() && pPlayer->GetVoice() )
                pPlayer->GetVoice()->DoPulse();

            // Flag him with connection error if its been too long since last puresync and force his position
            unsigned long ulLastPuresyncTime = pPlayer->GetLastPuresyncTime ();
            bool bHasConnectionTrouble = ( ulLastPuresyncTime != 0 && ulCurrentTime >= ulLastPuresyncTime + REMOTE_PLAYER_CONNECTION_TROUBLE_TIME );
            if ( bHasConnectionTrouble && !g_pClientGame->IsDownloadingBigPacket () && !pPlayer->IsDeadOnNetwork () )
            {
                pPlayer->SetHasConnectionTrouble ( true );

                // Reset his controller so he doesn't get stuck shooting or something
                CControllerState State;
                memset ( &State, 0, sizeof ( CControllerState ) );
                pPlayer->SetControllerState ( State );

                // Grab his vehicle if any and force the position to where he was last sync
                CClientVehicle* pVehicle = pPlayer->GetOccupiedVehicle ();
                if ( pVehicle )
                {
                    // Is he driving the vehicle?
                    if ( pPlayer->GetOccupiedVehicleSeat () == 0 )
                    {
                        // Force his position to where he was last sync
                        pVehicle->SetPosition ( pPlayer->GetLastPuresyncPosition () );
                        pVehicle->SetMoveSpeed ( CVector ( 0, 0, 0 ) );
                        pVehicle->SetTurnSpeed ( CVector ( 0, 0, 0 ) );
                        pPlayer->ResetInterpolation ();
                    }
                }
                else
                {
                    // Force his position to where he was last sync
                    pPlayer->SetPosition ( pPlayer->GetLastPuresyncPosition () );
                    pPlayer->ResetInterpolation ();
                    pPlayer->SetMoveSpeed ( CVector ( 0, 0, 0 ) );
                    pPlayer->ResetInterpolation ();
                }
            }
            else
            {
                pPlayer->SetHasConnectionTrouble ( false );
            }
        }
    }
}
开发者ID:StarSoftwareBuilder,项目名称:mtasa-blue,代码行数:57,代码来源:CClientPlayerManager.cpp

示例3: Hook_ExplosionCreation

bool CClientExplosionManager::Hook_ExplosionCreation ( CEntity* pGameExplodingEntity, CEntity* pGameCreator, const CVector& vecPosition, eExplosionType explosionType )
{
    CClientPlayer * pLocalPlayer = m_pManager->GetPlayerManager ()->GetLocalPlayer ();

    // Grab the entity responsible
    CClientEntity * pResponsible = NULL;
    CEntity* pResponsibleGameEntity = ( pGameExplodingEntity ) ? pGameExplodingEntity : pGameCreator;
    if ( pResponsibleGameEntity )
        pResponsible = m_pManager->FindEntity ( pResponsibleGameEntity, false );

    eWeaponType explosionWeaponType;
    switch ( explosionType )
    {
        case EXP_TYPE_GRENADE:
        {
            // Grenade type explosions from vehicles should only be freefall bombs
            // TODO: need a way to check if its a freefall bomb if creator is a ped
            if ( pGameCreator && pGameCreator->GetEntityType () == ENTITY_TYPE_VEHICLE )
                explosionWeaponType = WEAPONTYPE_FREEFALL_BOMB;
            else
                explosionWeaponType = WEAPONTYPE_GRENADE;
            break;
        }
        case EXP_TYPE_MOLOTOV:
            explosionWeaponType = WEAPONTYPE_MOLOTOV;
            break;
        case EXP_TYPE_ROCKET:
        case EXP_TYPE_ROCKET_WEAK:
            explosionWeaponType = WEAPONTYPE_ROCKET;
            break;
        case EXP_TYPE_TANK_GRENADE:
            explosionWeaponType = WEAPONTYPE_TANK_GRENADE;
            break;
        default:
            explosionWeaponType = WEAPONTYPE_EXPLOSION;
            break;
    }

    // Got a responsible entity?
    if ( pResponsible )
    {
        // Is the local player responsible for this?
        bool bLocal = ( ( pResponsible == pLocalPlayer ) ||
                      ( pResponsible == pLocalPlayer->GetOccupiedVehicle () ) ||
                      ( g_pClientGame->GetUnoccupiedVehicleSync ()->Exists ( static_cast < CDeathmatchVehicle * > ( pResponsible ) ) ) );

        if ( bLocal )
        {
            CClientEntity * pOriginSource = NULL;

            // Is this an exploding vehicle?
            if ( pGameExplodingEntity && pGameExplodingEntity->GetEntityType () == ENTITY_TYPE_VEHICLE )
            {
                // Set our origin-source to the vehicle
                pOriginSource = m_pManager->FindEntity ( pGameExplodingEntity, false );
            }                
            // If theres other players, sync it relative to the closest (lag compensation)
            else if ( m_pManager->GetPlayerManager ()->Count () > 1 )
            {
                switch ( explosionWeaponType )
                {
                    case WEAPONTYPE_ROCKET:
                    case WEAPONTYPE_ROCKET_HS:
                    {
                        CClientPlayer * pPlayer = g_pClientGame->GetClosestRemotePlayer ( vecPosition, 200.0f );
                        if ( pPlayer )
                        {
                            pOriginSource = pPlayer;
                        }
                        break;
                    }
                }                                   
            }
            // Request a new explosion
            g_pClientGame->SendExplosionSync ( vecPosition, explosionType, pOriginSource );
        }
    }

    // All explosions are handled server side
    return false;
}
开发者ID:divine,项目名称:multitheftauto,代码行数:81,代码来源:CClientExplosionManager.cpp

示例4: Test


//.........这里部分代码省略.........
            pVehicle->GetRotationDegrees ( vecT );
            vecT.fZ = atof ( szString + 7 );
            pVehicle->SetTargetRotation ( vecT, TICK_RATE );

            g_pCore->ChatPrintf ( "Done %f", false, atof ( szString + 7 ) );

            static_cast < CDeathmatchVehicle* > ( pVehicle )->SetIsSyncing ( false );
        }
    }


    else if ( stricmp ( szString, "choke" ) == 0 )
    {
        g_pClientGame->GetLocalPlayer ()->SetChoking ( true );
    }


    // 
    else if ( strnicmp ( szString, "static", 6 ) == 0 )
    {
        if ( pVehicleManager->Count () > 0 )
        {
            CClientVehicle* pVehicle = *pVehicleManager->IterBegin ();

            pVehicle->GetGameVehicle ()->SetRemap ( atoi ( szString + 7 ) );
            g_pCore->ChatPrintf ( "Set %i", false, atoi ( szString + 7 ) );
        }
    }


    // 
    else if ( strnicmp ( szString, "getmass", 7 ) == 0 )
    {
        CClientVehicle* pVehicle = pLocal->GetOccupiedVehicle ();
        if ( pVehicle )
        {
            g_pCore->ChatPrintf ( "Mass == %f", false, pVehicle->GetGameVehicle ()->GetMass () );
        }
    }

    else if ( strnicmp ( szString, "setmass", 7 ) == 0 )
    {
        CClientVehicle* pVehicle = pLocal->GetOccupiedVehicle ();
        if ( pVehicle )
        {
            pVehicle->GetGameVehicle ()->SetMass ( atof ( szString + 8 ) );
            g_pCore->ChatPrintf ( "Set mass to %f", false, pVehicle->GetGameVehicle ()->GetMass () );
        }
    }


    // 
    /*
    else if ( strnicmp ( szString, "setmm", 5 ) == 0 )
    {
        CClientVehicle* pVehicle = pLocal->GetOccupiedVehicle ();
        if ( pVehicle )
        {
            float fVal = atof ( szString + 6);
            szString += 4;
            float* fMass = (float*) atoi ( szString + 6 );
            *fMass = fVal;
            g_pCore->ChatPrintf ( "Set %X to %f", false, fMass, fVal );
        }
    }
    */
开发者ID:50p,项目名称:multitheftauto,代码行数:67,代码来源:CFoo.cpp

示例5: DrawFromAim


//.........这里部分代码省略.........
            flags.bCheckDummies = true;
            flags.bSeeThroughStuff = true;
            flags.bIgnoreSomeObjectsForCamera = false;
            flags.bShootThroughStuff = true;
            g_pGame->GetWorld()->ProcessLineOfSight(&vecStart, &vecTarget, &pColPoint, &pEntity, flags);
            if (pColPoint)
                pColPoint->Destroy();

            // Un-ignore the local player
            pLocalPlayer->WorldIgnore(false);

            // Did we find an entity?
            if (pEntity)
            {
                // Grab the CClientEntity belonging to this game_sa entity
                CClientEntity* pClientEntity = reinterpret_cast<CClientEntity*>(pEntity->GetStoredPointer());
                if (pClientEntity)
                {
                    // Is it a vehicle? Is it a ped?
                    eClientEntityType EntityType = pClientEntity->GetType();
                    if (EntityType == CCLIENTVEHICLE)
                    {
                        CClientVehicle* pClientVehicle = static_cast<CClientVehicle*>(pClientEntity);

                        // Set the current time as the last draw time for all players inside
                        CClientPed* pPed;
                        int         i;
                        for (i = 0; i < 8; i++)
                        {
                            // Grab this seat's occupant and set its last nametag show time to now
                            pPed = pClientVehicle->GetOccupant(i);
                            if (pPed && pPed->GetType() == CCLIENTPLAYER)
                            {
                                static_cast<CClientPlayer*>(pPed)->SetLastNametagShow(ulCurrentTime);
                            }
                        }
                    }
                    else if (EntityType == CCLIENTPLAYER)
                    {
                        // Grab the player this entity is
                        CClientPlayer* pClientPlayer = static_cast<CClientPlayer*>(pClientEntity);
                        if (pClientPlayer)
                        {
                            // Set now as the last time we had the cursor above him
                            pClientPlayer->SetLastNametagShow(ulCurrentTime);
                        }
                    }
                }
            }

            // Grab the local player vehicle
            CClientVehicle* pLocalVehicle = pLocalPlayer->GetOccupiedVehicle();

            // Draw the nametags we need to
            CClientPlayer*                              pPlayer;
            CClientStreamElement*                       pElement;
            list<CClientStreamElement*>::const_iterator iter = m_pPlayerStreamer->ActiveElementsBegin();
            for (; iter != m_pPlayerStreamer->ActiveElementsEnd(); ++iter)
            {
                pElement = *iter;
                if (!pElement->IsStreamedIn())
                    continue;
                if (pElement->GetType() != CCLIENTPLAYER)
                    continue;
                pPlayer = static_cast<CClientPlayer*>(pElement);
                if (pPlayer->IsLocalPlayer())
                    continue;

                // Is he in the same vehicle as the local player?
                if (pLocalVehicle && pPlayer->GetOccupiedVehicle() == pLocalVehicle)
                {
                    pPlayer->SetLastNametagShow(ulCurrentTime);
                }

                // Can we show this player's nametag
                unsigned long ulLastNametagShow = pPlayer->GetLastNametagShow();
                if (ulLastNametagShow != 0 && ulCurrentTime <= ulLastNametagShow + NAMETAG_END_FADE_TIME)
                {
                    unsigned long ulLastNametagShow = pPlayer->GetLastNametagShow();
                    // Calculate the alpha modifier
                    float fAlphaTimeModifier;
                    if (ulCurrentTime < ulLastNametagShow + NAMETAG_BEGIN_FADE_TIME)
                    {
                        fAlphaTimeModifier = 1.0f;
                    }
                    else
                    {
                        fAlphaTimeModifier = 1.0f - (ulCurrentTime - ulLastNametagShow - NAMETAG_BEGIN_FADE_TIME) / 1000.0f;
                    }

                    // Calculate the alpha for the nametag
                    unsigned char ucAlpha = static_cast<unsigned char>(180.0f * fAlphaTimeModifier);

                    // Draw it
                    DrawTagForPlayer(pPlayer, ucAlpha);
                }
            }
        }
    }
}
开发者ID:ccw808,项目名称:mtasa-blue,代码行数:101,代码来源:CNametags.cpp

示例6: DrawDefault

void CNametags::DrawDefault()
{
    // Grab the resolution width and height
    static float fResWidth = static_cast<float>(g_pCore->GetGraphics()->GetViewportWidth());
    static float fResHeight = static_cast<float>(g_pCore->GetGraphics()->GetViewportHeight());

    // Got any players that are not local?
    if (m_pPlayerManager->Count() <= 1)
        return;

    list<CClientPlayer*> playerTags;

    // Grab the local player
    CClientPlayer* pLocalPlayer = m_pPlayerManager->GetLocalPlayer();
    if (!pLocalPlayer)
        return;

    CClientVehicle* pSniperTargetedVehicle = NULL;
    CClientPlayer*  pSniperTargetedPlayer = NULL;

    // Grab our current weapon slot. Use screen center if melee or none
    eWeaponSlot eSlot = pLocalPlayer->GetCurrentWeaponSlot();
    if (eSlot >= WEAPONSLOT_TYPE_HANDGUN && eSlot <= WEAPONSLOT_TYPE_RIFLE)
    {
        CVector vecOrigin, vecTarget;
        pLocalPlayer->GetShotData(&vecOrigin, &vecTarget);

        // Ignore the local player for this
        pLocalPlayer->WorldIgnore(true);

        // Do the raycast
        CColPoint*        pColPoint = NULL;
        CEntity*          pEntity = NULL;
        SLineOfSightFlags flags;
        flags.bCheckBuildings = true;
        flags.bCheckVehicles = true;
        flags.bCheckPeds = true;
        flags.bCheckObjects = true;
        flags.bCheckDummies = true;
        flags.bSeeThroughStuff = true;
        flags.bIgnoreSomeObjectsForCamera = false;
        flags.bShootThroughStuff = true;
        g_pGame->GetWorld()->ProcessLineOfSight(&vecOrigin, &vecTarget, &pColPoint, &pEntity, flags);
        if (pColPoint)
            pColPoint->Destroy();

        // Un-ignore the local player
        pLocalPlayer->WorldIgnore(false);

        // Did we find an entity?
        if (pEntity)
        {
            // Grab the CClientEntity belonging to this game_sa entity
            CClientEntity* pClientEntity = reinterpret_cast<CClientEntity*>(pEntity->GetStoredPointer());
            if (pClientEntity)
            {
                // Is it a vehicle? Is it a ped?
                eClientEntityType EntityType = pClientEntity->GetType();
                switch (EntityType)
                {
                    case CCLIENTVEHICLE:
                    {
                        pSniperTargetedVehicle = static_cast<CClientVehicle*>(pClientEntity);
                        break;
                    }
                    case CCLIENTPLAYER:
                    {
                        pSniperTargetedPlayer = static_cast<CClientPlayer*>(pClientEntity);
                        break;
                    }
                    default:
                        break;
                }
            }
        }
    }

    // Grab the local player vehicle
    CClientVehicle* pLocalVehicle = pLocalPlayer->GetOccupiedVehicle();
    CVehicle*       pLocalGameVehicle = NULL;
    if (pLocalVehicle)
        pLocalGameVehicle = pLocalVehicle->GetGameVehicle();

    CMatrix CameraMatrix;
    g_pGame->GetCamera()->GetMatrix(&CameraMatrix);

    // Remove collision from our local vehicle (if we have one)
    if (pLocalVehicle)
        pLocalVehicle->WorldIgnore(true);

    // Draw the nametags we need to
    CVector                                     vecPlayerPosition;
    CClientVehicle*                             pPlayerVehicle = NULL;
    float                                       fDistanceExp;
    bool                                        bCollision;
    CColPoint*                                  pColPoint = NULL;
    CEntity*                                    pGameEntity = NULL;
    CClientEntity*                              pEntity = NULL;
    CClientPlayer*                              pPlayer;
    CClientStreamElement*                       pElement;
//.........这里部分代码省略.........
开发者ID:ccw808,项目名称:mtasa-blue,代码行数:101,代码来源:CNametags.cpp

示例7: Hook_ProjectileAllow

bool CClientProjectileManager::Hook_ProjectileAllow ( CEntity * pGameCreator, eWeaponType weaponType, CVector * origin, float fForce, CVector * target, CEntity * targetEntity )
{
    // Called before projectile creation, we need to decide to allow or cancel it here

    // Is this a local projectile?
    CClientPlayer * pLocalPlayer = m_pManager->GetPlayerManager ()->GetLocalPlayer ();

    // Store the creator/local variables for the next stage
    m_pCreator = m_pManager->FindEntity ( pGameCreator, true );
    m_bIsLocal = ( m_pCreator == pLocalPlayer || ( pLocalPlayer->GetOccupiedVehicleSeat () == 0 && m_pCreator == pLocalPlayer->GetOccupiedVehicle () ) ); 

    return ( m_bCreating || m_bIsLocal );
}
开发者ID:EagleShen,项目名称:MTA,代码行数:13,代码来源:CClientProjectileManager.cpp

示例8: ProcessPlayerList

///////////////////////////////////////////////////////////////
//
// CClientModelCacheManagerImpl::ProcessPlayerList
//
///////////////////////////////////////////////////////////////
void CClientModelCacheManagerImpl::ProcessPlayerList(std::map<ushort, float>& outNeedCacheList, const std::vector<CClientPlayer*>& playerList,
                                                     float fMaxStreamDistanceSq)
{
    const ulong ulTimeNow = CClientTime::GetTime();
    for (std::vector<CClientPlayer*>::const_iterator iter = playerList.begin(); iter != playerList.end(); ++iter)
    {
        CClientPlayer* pPlayer = *iter;
        ushort         usModelId = (ushort)pPlayer->GetModel();

        if (usModelId < 7 || usModelId > 312)
            continue;

        // Check if currently within distance
        {
            // Check distance
            CVector vecPosition;
            pPlayer->GetPosition(vecPosition);
            float fDistSq = (m_vecCameraPos - vecPosition).LengthSquared();
            if (fDistSq < fMaxStreamDistanceSq)
            {
                // Add model to needed list
                InsertIntoNeedCacheList(outNeedCacheList, usModelId, fDistSq);
                AddProcessStat("p", true, PURESYNC_TYPE_NONE, usModelId, vecPosition, vecPosition);
                continue;
            }
        }

        // Check if will be within distance soon
        ePuresyncType syncType = pPlayer->GetLastPuresyncType();
        if (syncType == PURESYNC_TYPE_PURESYNC || syncType == PURESYNC_TYPE_LIGHTSYNC)
        {
            ulong ulSyncAge = ulTimeNow - pPlayer->GetLastPuresyncTime();
            if (ulSyncAge < 8000)
            {
                // Get velocity from somewhere
                CVector         vecVelocity;
                CClientVehicle* pVehicle = pPlayer->GetOccupiedVehicle();
                if (syncType == PURESYNC_TYPE_LIGHTSYNC)
                {
                    vecVelocity = pPlayer->GetLightsyncCalcedVelocity();
                }
                else
                {
                    if (pVehicle)
                        pVehicle->GetMoveSpeed(vecVelocity);
                    else
                        pPlayer->GetMoveSpeed(vecVelocity);
                    vecVelocity *= m_fGameFps;
                }

                // Extrapolate position
                float   fSecondsToAdd = std::min(6000UL, ulSyncAge + 2000) * 0.001f;
                CVector vecPosition;
                pPlayer->GetPosition(vecPosition);
                CVector vecNewPosition = vecPosition + vecVelocity * fSecondsToAdd;

                // Check distance
                float fDistSq = (m_vecCameraPos - vecNewPosition).LengthSquared();
                if (fDistSq < fMaxStreamDistanceSq)
                {
                    // Add model to needed list
                    InsertIntoNeedCacheList(outNeedCacheList, usModelId, fDistSq);
                    AddProcessStat("l", true, syncType, usModelId, vecPosition, vecNewPosition);
                    continue;
                }
                AddProcessStat("n", false, syncType, usModelId, vecPosition, vecNewPosition);
                continue;
            }
        }
    }
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:76,代码来源:CClientModelCacheManager.cpp


注:本文中的CClientPlayer::GetOccupiedVehicle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。