2. You will need to make very short time delay to make it seem as it never opens - can cause lag
The lag.. Yes, but you can usually have a few of fast-looping scripts running before they cause lag, and you could run the script by a trigger only when the player (or his loons) are close enough.
Blanco's script will do it, with a 0.01 sec delay, and the script run by a trigger with:
radius=5
player side present
repeated
on activation: [gate] exec "lockdoors.sqs"
on deactivation: alarm=true
That should do it.
Other course of action would be placing (speculating here) your own variant of the "open gate"- action's script to your mission folder,as if I'm correct OFP will check first the mission folder for scripts, then addons folder and the game's global folders..
As I said that's only speculating and you'd have to rummage the FDF's addon folders for the script name and path...
But it should work.
Of course you could use the first way, but it'd be to easy, wouldn't it? ;D