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


C++ CVehicle::GetParamsEx方法代码示例

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


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

示例1: showVehicleForPlayer

void CVehiclePool::showVehicleForPlayer( _VehicleID vehicleid, _PlayerID playerid )
{
	RakNet::BitStream bStream;
	CVehicle* vehicle = GetVehicle( vehicleid );
	if( vehicle == 0 ) return;

	float angle = 0.0f;
	if( vehicle->vehMatrix.up.X == 0.0f && vehicle->vehMatrix.up.Y == 0.0f || vehicle->GetSpawnInfo()->vehType == 0x219 || vehicle->GetSpawnInfo()->vehType == 0x21A )
	{
		angle = vehicle->GetSpawnInfo()->vehRot;
	}
	else
	{
		angle = atan2( -vehicle->vehMatrix.up.X, vehicle->vehMatrix.up.Y ) * 57.2957763671875f;
		if( angle >= 360.0 ) angle -= 360.0f;
		else if( angle < 0.0f ) angle += 360.0f;
	}

	bStream.Write( ( _VehicleID ) vehicleid );
	bStream.Write( ( uint32_t ) vehicle->GetSpawnInfo( )->vehType );
#ifdef _BIG_ENDIAN_SYSTEM
	bStream.Write(vehicle->vehMatrix.pos.X);
	bStream.Write(vehicle->vehMatrix.pos.Y);
	bStream.Write(vehicle->vehMatrix.pos.Z);
#else
	bStream.Write( (char*)&vehicle->vehMatrix.pos, sizeof( tVector ) );
#endif
	bStream.Write( ( float ) angle );
	bStream.Write( ( uint8_t )vehicle->GetSpawnInfo()->vehColor1 );
	bStream.Write( ( uint8_t )vehicle->GetSpawnInfo()->vehColor2 );
	bStream.Write( ( float ) vehicle->vehHealth );
	bStream.Write( ( uint8_t ) vehicle->GetSpawnInfo()->vehInterior );
	bStream.Write( ( uint32_t ) vehicle->vehDoorStatus );
	bStream.Write( ( uint32_t ) vehicle->vehPanelStatus );
	bStream.Write( ( uint8_t ) vehicle->vehLightStatus );
	bStream.Write( ( uint8_t ) vehicle->vehTireStatus );
#ifdef _BIG_ENDIAN_SYSTEM
	bStream.Write( (char*)&vehicle->vehModInfo.vehModSlots, sizeof(vehicle->vehModInfo.vehModSlots));
	bStream.Write(vehicle->vehModInfo.vehPaintJob);
	bStream.Write(vehicle->vehModInfo.vehColor1);
	bStream.Write(vehicle->vehModInfo.vehColor2);
#else
	bStream.Write( (char*)&vehicle->vehModInfo, sizeof( VEHMOD_INFO ) );
#endif
	__NetGame->PlayerRPC( RPC_ShowVehicleToPlayer, &bStream, playerid, 2 );

	if( strlen( vehicle->vehNumberPlate ) > 0 )
	{
		bStream.Reset( );
		bStream.Write( ( _VehicleID ) vehicleid );
		bStream.Write( ( uint8_t )strlen( vehicle->vehNumberPlate ) );
		bStream.Write( (char*)vehicle->vehNumberPlate, strlen( vehicle->vehNumberPlate ) );
		char* RPC_SetVehicleNumberPlate = 0;
		__NetGame->PlayerRPC( RPC_SetVehicleNumberPlate, &bStream, playerid, 2);
	}

	if ( vehicle->hasParamExModified() )
	{
		bStream.Reset( );
		VEHPARAM_EX* params = vehicle->GetParamsEx();
		bStream.Write( vehicleid );
		bStream.Write( (char*)params, sizeof( VEHPARAM_EX ) );
		__NetGame->PlayerRPC( RPC_SetVehicleParamsEx, &bStream, playerid, 2 );
	}

	uint8_t paramsFlags = vehicle->GetParamsForPlayer( playerid );
	vehicle->SetParamsForPlayer( playerid, paramsFlags & 1, ( paramsFlags & 2 ) ? 1 : 0 ); // Prevent lock/unlocking bug

	vehicle->UpdateVehicleColorForPlayer( playerid ); // prevent unsynced color


}
开发者ID:trisz404,项目名称:OpenSAMP-WIP,代码行数:72,代码来源:class_vehiclepool.cpp


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