How can I use a driver for multiple objects?
If your driver is: max(0, min(pi/2, 2-abs(v1))), where v1 variable points to the car's location component of the axis perpendicular to the gate, then you already use max which is the method to take the bigger out of two (or more) values.
So you can calculate the bar's rotation for all cars on the scene, and pass each to the max function so the bar is always as low as the closest object in the equation allows it to be. Therefore, the driver becomes max(max(0, min(pi/2, 2-abs(v1))), max(0, min(pi/2, 2-abs(v2))))

In your case you have to add distance2 to have a distance of the second car to the gate. Then you apply the above advice with max:
max(pi / 2 + (abs(distance/15) &lt; 0.8) * (pi * 3/4 - abs(distance / 5)), pi / 2 + (abs(distance2/15) &lt; 0.8) * (pi * 3/4 - abs(distance2 / 5)))