there's the crew command which returns an array with all the units in a vehicle.
from the comref
crew vehicle
Operand types:
vehicle: Object
Type of returned value:
Array
Description:
All units mounted in given vehicle. If vehicle is not vehicle, but person, list containing only person is returned.
Example:
crew vehicle player
All you have to do than is count the crew
_number = count crew car1