Ok, you use the 'createvehicle' command. To keep track of how many have been made, a variable is created. Once this variable reaches a certain amount (in this instance, 3) then the script will then exit. That's essentially what you want.
So, let's begin with the 'addaction':
player addaction ["Create Tank","Assemble.sqs"]
You can put that in a trigger near where you want the tanks to be created.
So, now for 'assemble.sqs':
;this is a global variable. 'createtank' is defined in the init.sqs. More about that further down
createtank = createtank + 1
;this is the complicated part
;max_tanks is the global variable which determines how many tanks you can create
;this too is defined in the init.sqs
? createtank >= max_tanks: hint "No more tanks available"; exit
;now to create a tank
;'tankspawn' is the marker where you want the tanks to spawn
_tank = "M1Abrams" createVehicle getmarkerpos "tankspawn"
;the line below is optional, you can put the marker where you want and leave it at that if you want
;you input the x,y,z yourself
_tank setpos [x,y,z]
;this is optional:
hint format["Number of tanks left: - %1", (max_tanks - createtank)]
;that will tell the player how many tanks left he can create
exit
The script will end if the player has created all that he can create. The addaction will still be there, but no more tanks can be created. I've put a hint stating that no more tanks can be created. You could try removing the action but I'm not 100% sure how to do that for this one.
Now about those global variables:
In init.sqs...
createtank = 0
max_tanks = 3
Now, I'm afraid I'm not sure how to keep track of whether a createvehicle'd vehicle has been destroyed or not. But, it uses the same principal of checking whether a globalvariable has decreased at all. I hate leaving a question unanswered, but hopefully what I've put here will put you on the right track
Hope this helps
Gruntage