本文整理汇总了C++中CNetworkVehicle::GetDriver方法的典型用法代码示例。如果您正苦于以下问题:C++ CNetworkVehicle::GetDriver方法的具体用法?C++ CNetworkVehicle::GetDriver怎么用?C++ CNetworkVehicle::GetDriver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CNetworkVehicle
的用法示例。
在下文中一共展示了CNetworkVehicle::GetDriver方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnEnterVehicle
void CLocalPlayer::OnEnterVehicle( void )
{
// Get the vehicle instance from the vehicle guid
CNetworkVehicle * pNetworkVehicle = pCore->GetVehicleManager()->GetFromGameGUID( GetPlayerPed()->GetCurrentVehicle()->m_dwGUID );
// Is the vehicle instance valid?
if( pNetworkVehicle )
{
#ifdef _DEBUG
M2Vehicle * pVehicle = pNetworkVehicle->GetVehicle()->GetVehicle();
DWORD dwVehicleData = (DWORD)(pVehicle) + 0xA8;
pCore->GetChat()->AddDebugMessage ( "Vehicle: 0x%p, VehicleData: 0x%p", pVehicle, dwVehicleData );
#endif
// Set the initial seat as the driver
EntityId seat = 0;
// Is the player in the passenger seat?
//if( GetState() == PLAYERSTATE_PASSENGER )
// seat = pNetworkVehicle->GetVehicle()->GetPedOccupiedSeat( GetPlayerPed()->GetPed() );
// Does the vehicle already have a driver?
if ( pNetworkVehicle->GetDriver () )
seat = pNetworkVehicle->GetVehicle()->GetPedOccupiedSeat( GetPlayerPed()->GetPed() );
// Are we getting in as the driver?
if( seat == 0 )
SetState( PLAYERSTATE_DRIVER );
else
SetState( PLAYERSTATE_PASSENGER );
#ifdef _DEBUG
pCore->GetChat()->AddDebugMessage( "Seat: %d, Driver: 0x%p, State: %d", seat, pNetworkVehicle->GetDriver (), GetState () );
#endif
// Construct a new bitstream
RakNet::BitStream pBitStream;
// Write the vehicle id
pBitStream.WriteCompressed( pNetworkVehicle->GetId() );
// Write the seat
pBitStream.WriteCompressed( seat );
// Send to the server
pCore->GetNetworkModule()->Call( RPC_ENTER_VEHICLE, &pBitStream, HIGH_PRIORITY, RELIABLE_ORDERED, true );
#ifdef _DEBUG
pCore->GetChat()->AddDebugMessage( "CLocalPlayer::OnEnterVehicle( %d, %d )", pNetworkVehicle->GetId(), seat );
#endif
// Handle this enter with the network vehicle
pNetworkVehicle->HandlePlayerEnter( this, seat );
// Set the vehicle
SetVehicle( pNetworkVehicle );
// Set the seat
SetSeat( seat );
// Set the target data
SetEnteringVehicle( pNetworkVehicle, seat );
}
}