예제 #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 );
		}
	}
}
예제 #2
0
void CNetSends::SetVehicleHealth( unsigned char uc )
{
	CVehiclePool* pVehicle = CVehiclePoolManager::Find( uc );
	if ( pVehicle )
	{
		RakNet::BitStream bsSend;
		char szText[ 256 ] = { NULL };
		BYTE byteTextLen = 0;

		sprintf( szText, "2 %i %f", uc, pVehicle->GetHealth() );

		byteTextLen = strlen( szText );

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

		NetInterface->RPC( "Set", &bsSend, HIGH_PRIORITY, RELIABLE, 0, UNASSIGNED_PLAYER_ID, TRUE, FALSE );
	}
}
예제 #3
0
void CNetSends::PutPlayerInVehicle( unsigned char uc1, unsigned char uc2 )
{
	CPlayerPool* pPlayer = CPlayerPoolManager::Find( uc1 );
	if ( pPlayer )
	{
		CVehiclePool* pVehicle = CVehiclePoolManager::Find( uc2 );
		if ( pVehicle )
		{
			RakNet::BitStream bsSend;
			char szText[ 256 ] = { NULL };
			BYTE byteTextLen = 0;

			sprintf(szText, "9 %i %i", uc1, uc2);

			byteTextLen = strlen( szText );

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

			pPlayer->SetEnterVehicleTime( RakNet::GetTime() );
			pPlayer->SetVehicle( uc2 );
			pPlayer->SetVehiclePassenger( 18 );

			CPlayerSendPackets::EnterVehicle( pPlayer->GetID(), pVehicle->GetID(), pVehicle->GetModel(), pVehicle->GetHealth(), 0 );
				
			CScripting::PushFunction( "onPlayerEnterVehicle" );
			CScripting::PushPlayerPointer( pPlayer );
			CScripting::PushVehiclePointer( pVehicle );
			CScripting::PushBool( false );
			CScripting::CallFunction();

			pVehicle->SetLastUsedTime( RakNet::GetTime() );
			pVehicle->SetBeenUsed( true );
			pVehicle->SetDriver( uc1 );

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