Exemplo n.º 1
0
void CRemotePlayer::HandleVehicleEntryExit()
{
	CVehiclePool *pVehiclePool = pNetGame->GetVehiclePool();
	MATRIX4X4 mat;

	if(!m_pPlayerPed) return;

	if(GetState() == PLAYER_STATE_ONFOOT) {
		if(m_pPlayerPed->IsInVehicle()) {
			m_pPlayerPed->GetMatrix(&mat);
			m_pPlayerPed->RemoveFromVehicleAndPutAt(mat.pos.X,mat.pos.Y,mat.pos.Z);
		}
		return;
	}

	if( GetState() == PLAYER_STATE_DRIVER || GetState() == PLAYER_STATE_PASSENGER )
	{
		if(!m_pPlayerPed->IsInVehicle()) {
			// if they're onfoot, put them in the vehicle.
			CVehicle *pVehicle = pVehiclePool->GetAt(m_VehicleID);
			if(pVehicle) {
				int iCarID = pVehiclePool->FindGtaIDFromID(m_VehicleID);
				m_pPlayerPed->PutDirectlyInVehicle(iCarID,m_byteSeatID);
			}
		} else {
			// validate the vehicle they're driving is the one they're
			// reporting to be in.
			int iCurrentVehicle = m_pPlayerPed->GetCurrentVehicleID();
			int iReportedVehicle = pVehiclePool->FindGtaIDFromID(m_VehicleID);
			if(iCurrentVehicle != iReportedVehicle) {
				m_pPlayerPed->PutDirectlyInVehicle(iReportedVehicle,m_byteSeatID);
			}
		}
	}
}
Exemplo n.º 2
0
void CRemotePlayer::EnterVehicle(VEHICLEID VehicleID, BOOL bPassenger)
{
	CVehiclePool *pVehiclePool = pNetGame->GetVehiclePool();

	if(m_pPlayerPed && !m_pPlayerPed->IsInVehicle()) {

		if(bPassenger) {
			SetState(PLAYER_STATE_ENTER_VEHICLE_PASSENGER);
		} else {
			SetState(PLAYER_STATE_ENTER_VEHICLE_DRIVER);
		}
		
		m_pPlayerPed->SetKeys(0,0,0);
		if(m_pPlayerPed->GetDistanceFromLocalPlayerPed() < 120.0f) {
			int iGtaVehicleID = pVehiclePool->FindGtaIDFromID(VehicleID);
			if(iGtaVehicleID && iGtaVehicleID != INVALID_VEHICLE_ID) {	
				m_pPlayerPed->EnterVehicle(iGtaVehicleID,bPassenger);
			}
		}
	}
	m_dwWaitForEntryExitAnims = GetTickCount() + 500;
}