The first thing is that you have got to understand the basics of scripts. This is very easy. If you haven't done so already, look in the Editors Depot and read
A basic introduction to script snippets by snYpir
Johan Gustafsson's Scripting Guide
It's also worth studying Devilchaser's Mission/Scripting Guide and several other tutes.
Anyway, I can't write your script for you because I'm not handy enough with scripts to do it correctly and quickly .... I'd spend a whole evening on it, which is your job ;D
I'm only going to do this for one tank, you can easily expand it for more.
Let's say you want the crew to run back to their base. Create a marker in the base and call it "base". Create a tank and call it "tank1"
We want the crew to bail if the tank is nearly destroyed, so create a trigger.
size: whole map
condition: tank1 getdammage > 0.9
on activation: [] exec "CrewFlee.sqs"
Now create a script file called you've guessed it CrewFlee.sqs. If you're not sure how to do this read the tutes.
Now, the crew of the tank are automatically named if the tank is named. So here we go ...
; this is a script to make the crew of the tank jump out and run home if the tank is hit
tank1D unAssign tank1 (hmmm ... this may change the loon's name ... hope not!)
tank1G unAssign tank1
tank1C unAssign tank1
#loop
? (tank1D distance "base" < 10) and (tank1G distance "base" < 10) and (tank1C distance "base" < 10): goto "end"
tank1D doMove getMarkerPos "base"
tank1G doMove getMarkerPos "base"
tank1C doMove getMarkerPos "base"
~1
goto "loop"
#end
exit
There will be mistakes in that so check the commands in the command ref guide in the Editors Depot - make sure the syntax is right. You'll probably need to play with the whole thing to make it work too. For instance I'm not sure how the script would cope if one of the loons was dead. If you need to check it use
not (alive tank1D)
etc
Good luck!
Anybody - if you spot any errors feel free to point them out.