Doesn't keep track of the damage level so shooting your own empty damaged tank will give you a tank with zero damage. The problem with keeping track of the damage level is that the damage value must be read before your empty tank has been hit, if you want to maintain the damage level of the moment when the crew got out. So you'll end up having something not so simple as this as a solution.
Possible solution, once the tanks crew is out, lock the tank. Maybe not the best idea, if your planning to get back into it, but it might prove a quick fix to the problem?
Oh yeah you mean that once you get out of a vehicle, then you can't enter it never again in the mission. Well that's a solution of some kind, and simple
@Seven
You don't need
_tank = _this in your script, you can use
_this in the whole script if you pass the tank for your script like
this exec "script.sqs" from the initialization field. If you do
_tank = _this in your script, you will be creating another variable for the same thing.
_this is already pointing at your tank and then you go and make
_tank point at it too, which is not needed.
In a simple script like this where you are only passing one argument for your script, you don't need to use the brackets [] when you pass arguments. The brackets mean that you are creating an array and giving that array to your script. Then in your script you would need to pick items from that array by using
select. As you can understand for sure, that is a bit pointless if you only have one argument to pick from.
As to your question, if you pass the tank for your script with
this exec "script.sqs" from the initialization field, then in the script you can use
_this all the time to point to the tank. This means that if you want to start a new script and pass the tank to that script, then
_this exec "anotherscript.sqs" will do it. Then again, if you had multiple arguments for the first script like
[this, "boogie", 700] exec "script.sqs" now you would start the new script from the first script by writing
_this select 0 exec "anotherscript.sqs" and that should work ok too.
I suggest you try to do what are you trying to achieve without looping scripts and go for the event handler idea, that way you would get better performance especially if you need this functionality for alot of vehicles in a mission.