本文整理汇总了C++中CVehicle::GetOccupant方法的典型用法代码示例。如果您正苦于以下问题:C++ CVehicle::GetOccupant方法的具体用法?C++ CVehicle::GetOccupant怎么用?C++ CVehicle::GetOccupant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVehicle
的用法示例。
在下文中一共展示了CVehicle::GetOccupant方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
int * CVehicleModuleNatives::GetOccupants(EntityId vehicleId)
{
CVehicle * pVehicle = g_pVehicleManager->GetAt(vehicleId);
if(pVehicle)
{
int * occupants = new int[MAX_VEHICLE_PASSENGERS+1];
for(int i = 0; i <= MAX_VEHICLE_PASSENGERS; i++)
{
CPlayer * pPlayer = pVehicle->GetOccupant(i);
if(pPlayer)
occupants[0] = pPlayer->GetPlayerId();
else
occupants[i] = INVALID_ENTITY_ID;
}
return occupants;
}
return false;
}
示例2: SpawnPlayer
void CMapManager::SpawnPlayer ( CPlayer& Player, const CVector& vecPosition, float fRotation, unsigned short usModel, unsigned char ucInterior, unsigned short usDimension, CTeam* pTeam )
{
// Don't force them off their team if the spawnpoint doesn't have one
if ( pTeam == NULL )
pTeam = Player.GetTeam ();
ElementID TeamID = ( pTeam ) ? pTeam->GetID () : INVALID_ELEMENT_ID;
// Change the time context to avoid old sync packets arriving causing players
// to slide from previous location to the new one.
unsigned char ucTimeContext = Player.GenerateSyncTimeContext ();
// Tell everyone where he spawns
m_pPlayerManager->BroadcastOnlyJoined ( CPlayerSpawnPacket ( Player.GetID (), vecPosition, fRotation, usModel, ucInterior, usDimension, TeamID, ucTimeContext ) );
// Remove him from any occupied vehicle
CVehicle* pVehicle = Player.GetOccupiedVehicle ();
if ( pVehicle )
{
pVehicle->SetOccupant ( NULL, Player.GetOccupiedVehicleSeat () );
Player.SetOccupiedVehicle ( NULL, 0 );
}
// If this guy was jacking someone, make sure its aborted
pVehicle = Player.GetJackingVehicle ();
if ( pVehicle )
{
if ( Player.GetVehicleAction () == CPlayer::VEHICLEACTION_JACKING )
{
CPed * pOccupant = pVehicle->GetOccupant ( 0 );
if ( pOccupant )
{
pOccupant->SetVehicleAction ( CPlayer::VEHICLEACTION_NONE );
// Tell everyone
CVehicleInOutPacket Reply ( pVehicle->GetID (), 0, CGame::VEHICLE_NOTIFY_JACK_RETURN, pOccupant->GetID (), Player.GetID () );
Reply.SetSourceElement ( &Player );
m_pPlayerManager->BroadcastOnlyJoined ( Reply );
}
}
if ( pVehicle->GetJackingPlayer () == &Player )
pVehicle->SetJackingPlayer ( NULL );
}
// Update the player data
Player.SetSpawned ( true );
Player.SetHealth ( Player.GetMaxHealth () );
Player.SetIsDead ( false );
Player.SetWearingGoggles ( false );
Player.SetHasJetPack ( false );
Player.SetPosition ( vecPosition );
Player.SetRotation ( fRotation );
Player.SetModel ( usModel );
Player.SetVehicleAction ( CPlayer::VEHICLEACTION_NONE );
Player.SetTeam ( pTeam, true );
Player.SetInterior ( ucInterior );
Player.SetDimension ( usDimension );
Player.AttachTo ( NULL );
// Call onPlayerSpawn
CLuaArguments OnPlayerSpawnArguments;
OnPlayerSpawnArguments.PushNumber ( vecPosition.fX );
OnPlayerSpawnArguments.PushNumber ( vecPosition.fY );
OnPlayerSpawnArguments.PushNumber ( vecPosition.fZ );
OnPlayerSpawnArguments.PushNumber ( fRotation );
OnPlayerSpawnArguments.PushElement ( pTeam );
OnPlayerSpawnArguments.PushNumber ( usModel );
OnPlayerSpawnArguments.PushNumber ( ucInterior );
OnPlayerSpawnArguments.PushNumber ( usDimension );
Player.CallEvent ( "onPlayerSpawn", OnPlayerSpawnArguments );
}