How to find a vehicle

From OPU Wiki

Question: How can i find a vehicle the same way i can find a building (using PlayerBuildingEnum) ?

Since the OP2 SDK does not have a PlayerVehicleEnum procedure that will let you give a map_id as a param, you need to write your own routine to find a specific vehicle type:

void FindVehicle(map_id type)
{
  Unit u;
  PlayerVehicleEnum enum1(Player[1]);

  while (enum1.GetNext(u))
  {
    if (u.GetType()==type)
    {
      // put stuff here

      break;
    }
  }
}

Using the break; will only perform the "// put stuff here" code for the first unit found. If you want the code to be performed for every unit of the correct type, just leave out the break;

Personal tools