I am trying to create a script so that when a tank is destroyed it is replaced by another one at the position of a fire "fire1".
Currently I am trying two different methods
1. Using a trigger called 'trigger1' with condition "!alive tank1" and on act. "[] exec "tankdead.sqs""
tankdead.sqs:
?(!alive tank1):goto "dead"
?(alive tank1):goto "end"
#dead
_vcl= tank1
_vclname = name _vcl;
_dir= getdir fire1;
_pos= getpos fire1;
_type= typeof _vcl;
deletevehicle _vcl;
deletevehicle trigger1;
_vcl = _type createVehicle getpos fire1;
_vcl setVehicleVarName "tank1";
_vcl setDir _dir;
_vcl setPos _pos;
_vcl setVelocity [0,0,0];
deletevehicle trigger1;
trigger1 = createTrigger ["EmptyDetector", getpos fire1];
trigger1 setTriggerActivation ["NONE","PRESENT", true];
trigger1 setTriggerStatements ["!alive tank1","[] exec ""tankdead.sqs""",""];
exit
#end
exit
2. The second method is to put tank = [this, "fire1"] execVM "vehiclespawn.sqf" into the tanks init field
vehiclespawn.sqf
_vcl = _this select 0;
_fire = _this select 1;
_type = typeOf _vcl;
_pos = getPos _vcl;
_dir = getDir _vcl;
waitUntil (not alive _vcl) then
{
deleteVehicle _vcl;
sleep 20;
_vcl = nil;
_vcl = _type createVehicle _pos;
_vcl setPos _pos;
_vcl setDir _dir;
_vcl setVehicleInit "tank = [this, "fire1"] execVM "vehiclespawn.sqf""
};
exit;
Is either way correct currently with the first method it respawns once but will not do it a second time and method two seems to not find the sqf file after double checking everything. Help greatly appreciated (a small delay would be nice aswell)