I have tested and so MODIFIED my previous post. Now the script acts upon entering as driver ONLY - I had used "||" which works as "or", instead of the "and" which is there now.
And I have also removed the "sleep", which is not allowed in such cases.
But it still does NOT avoid players entering in other seats and then changing to driver, whether the vehicle allowed to do so - that requires another kind of "switchSeat" eventHandler.
Whether you want it avoid access for every seat in the vehicle, just change the "if" line into this:
if (_unit isKindOf 'SoldierWB')
You also have the probably more simple option to just lock the driver seat at some point by using
_this lockDriver true;
Tried it, no error but craters are way smaller especially on hardened surface.
Edit: Okay it seems to take projectile into account now. I can make a fairly deep crater by firing an HE tank shell into the ground but the GBU blown up the debug doesn't do much anymore.