Example #1
0
void CNetSends::SpawnVehicleForPlayer( unsigned char uc, unsigned char ucVehicle )
{
	CPlayerPool* pPlayer = CPlayerPoolManager::Find( uc );
	if ( pPlayer )
	{
		CVehiclePool* pVehicle = CVehiclePoolManager::Find( ucVehicle );
		if ( pVehicle )
		{
			RakNet::BitStream bsSend;

			bsSend.Write( ucVehicle );
			bsSend.Write( pVehicle->GetModel() );
			bsSend.Write( pVehicle->GetX() );
			bsSend.Write( pVehicle->GetY() );
			bsSend.Write( pVehicle->GetZ() );
			bsSend.Write( pVehicle->GetRotation() );
			bsSend.Write( (int)pVehicle->GetColour1() );
			bsSend.Write( (int)pVehicle->GetColour2() );
			bsSend.Write( pVehicle->GetHealth() );

			// Spawn stuff
			bsSend.Write( pVehicle->GetSpawnX() );
			bsSend.Write( pVehicle->GetSpawnY() );
			bsSend.Write( pVehicle->GetSpawnZ() );
			bsSend.Write( pVehicle->GetSpawnRotation() );

			NetInterface->RPC( "VehicleSpawn", &bsSend, HIGH_PRIORITY, RELIABLE_ORDERED, 0, pPlayer->GetPlayerID(), FALSE, FALSE );
		}
	}
}
Example #2
0
void CNetSends::SetVehiclePosition( unsigned char uc )
{
	CVehiclePool* pVehicle = CVehiclePoolManager::Find( uc );
	if ( pVehicle )
	{
		RakNet::BitStream bsSend;
		char szText[ 256 ] = { NULL };
		BYTE byteTextLen = 0;

		sprintf( szText, "8 %i %f %f %f", uc, pVehicle->GetX(), pVehicle->GetY(), pVehicle->GetZ());

		byteTextLen = strlen( szText );

		bsSend.Write( byteTextLen );
		bsSend.Write( szText, byteTextLen );

		NetInterface->RPC( "Set", &bsSend, HIGH_PRIORITY, RELIABLE, 0, UNASSIGNED_PLAYER_ID, TRUE, FALSE );
	}
}