Hi im working on a script so that i can transport units around the map via a airlift script i have the airlift working 100% if i have it set to a preplaced chopper called transportchop1 my problem is that once this chopper is killed and respawns its no longer called transportchop1 therefor the script it always returning chopper is dead how would i rename the spawned chopper back to transportchop1?
CarryOn.sqf
_Unit = _this select 0;
_id = _this select 2;
_Unit removeAction _id;
incargo = _Unit;
endCargoSession = false;
publicVariable "endCargoSession";
publicVariable "incargo";
CarryOff.sqf
_Unit = _this select 0;
_id = _this select 2;
_Unit removeAction _id;
endCargoSession= false;
if(_Unit == transportchop1)then
{
}else{
_unit addAction ["Call Pickup","carry.sqf"];
};
incargo = _Unit;
publicVariable "incargo";
publicVariable "endCargoSession";
Carry.sqf
_Vehicle = transportchop1;
_Unit=_this select 0;
_id = _this select 2;
_Unit removeAction _id;
_StrComp = compile LoadFile "functions\StrComp.sqf";
_dirtoobj = compile LoadFile "functions\DirToObj.sqf";
_xa = 0.5;
_ya = 8;
_za = 8;
_Offset = [0,0,-8.26];
_engaged = false;
if(endCargoSession)ExitWith
{
Hint "Chopper in use"
};
_Display =
{
private ["_distocargopre","_distocargo","_realposssz","_zz1","_zz","_dirtoobjcal","_dirfromcargo","_message","_messagechopper","_compdirchopper","_compdir"];
_distocargopre= (_this select 1) Distance (position (_this select 0));
_distocargo = round _distocargopre;
_realposssz = getpos (_this select 1);
_zz1 = (_realposssz select 2);
_zz = round _zz1;
_dirtoobjcal = [(_this select 0),(_this select 1)] call _dirtoobj;
_dirfromcargo = [(_this select 1),(_this select 0)] call _dirtoobj;
_compdir = [_dirtoobjcal,.1,7] call _StrComp;
_compdirchopper = [_dirfromcargo,.1,7] call _StrComp;
_message = format["Distance:%1 Height:%2 Headding:%3",_distocargo,_zz,_compdir];
_messagechopper = format["Distance:%1 Headding:%2",_distocargo,_compdirchopper];
(_this select 1) vehicleChat _messagechopper;
(_this select 0) vehicleChat _message;
};
_Alive =
{
if(not alive (_this select 0))ExitWith
{
hint "Carryed is dead";
endCargoSession = false;
publicVariable "endCargoSession";
};
if(not alive (_this select 1))ExitWith
{
hint "Transport is dead";
endCargoSession = false;
publicVariable "endCargoSession";
};
};
_vectors =
{
(_this select 0) SetVelocity (Velocity (_this select 1));
(_this select 0) SetPos ((_this select 1) ModelToWorld _Offset);
_VUp=VectorUp (_this select 1);
_VDir=VectorDir (_this select 1);
(_this select 0) SetvectorDir _VDir;
(_this select 0) SetvectorUp _VUp;
};
[_unit,_Vehicle] call _Alive;
_act1 = _unit addAction ["Cancel Airlift","CarryOff.sqf"];
endCargoSession = true;
publicVariable "endCargoSession";
while {endCargoSession} do
{
sleep 0.001;
[_unit,_Vehicle] call _Alive;
[_unit,_Vehicle] call _Display;
_realposss = getpos _Vehicle;
_z = _realposss select 2;
_distocargopre= _Vehicle Distance (position _unit);
_distocargo = round _distocargopre;
if((_z <= 10) && (_distocargo <= 10))then
{
_Vehicle vehicleChat "Engaged";
_unit vehicleChat "Lock Engaged";
_act2 = _Vehicle addAction ["Uncouple Cargo","CarryOff.sqf"];
while{endCargoSession} do
{
_realposss = getpos _Vehicle;
_z = _realposss select 2;
if(_z > 15)then{_engaged = true};
if((_z <= 6)&& (_engaged))then {endCargoSession = flase};
sleep 0.001;
[_unit,_Vehicle] call _Alive;
[_unit,_Vehicle] call _vectors;
[_unit,_Vehicle] call _Display;
if(not endCargoSession)ExitWith
{
_Vehicle vehicleChat "Disengaged";
_unit vehicleChat "Lock Disengaged";
_Unit removeAction _act1;
_Vehicle removeAction _act2;
};
};
};
};