Jump to content

Sign in to follow this  
combat-agent

nearestobject array not working with isnull command

Recommended Posts

I'm trying to make a full heal script with ace 3. Basically, an injured player has to be near a treating facility (building or ambulance). I've made decent progress until it was time to determine the distance from the units to the facility. I can't get a good logical exit if the nearestobjects command returns empty. So the _hospital variable is returned null when it is farther than 10 meters. But i cant get the line if (isNull _hospital) exitwith {hint "You are not at hospital."}; to return anything. I'm sure im missing something smalle. I would greatly appreciate the help.

params ["_target", "_caller", "_actionId", "_arguments"];

_hospital = (nearestObjects [_target, ["C_Van_02_medevac_F"], 10] select 0);
//,"I_E_Truck_02_Medical_F","I_Truck_02_medical_F","O_T_Truck_02_Medical_F","O_T_Truck_03_medical_ghex_F","Land_Pod_Heli_Transport_04_medevac_F","O_Heli_Transport_04_medevac_F","O_Truck_03_medical_F","O_Truck_02_medical_F","B_T_Truck_01_medical_F","B_Truck_01_medical_F","FSGm_ItemMedicBag","FSGm_ItemMedicBagMil"

hint format ["%1", _hospital];
sleep 10;

if (isNull _hospital) exitwith {hint "You are not at hospital."};
sleep 15;
if (_target == _caller) exitwith {Hint "You can not treat yourself."};
if (healing == 1) exitwith {Hint "Someone is currently being treated, please wait."};
if !(alive _target) exitwith {Hint "The Doctor is deceased."};
if (isNull _target) exitwith {hint "No Doctor is not present."};
if (_target distance _hospital > 5) exitwith {Hint "No Doctor is not present."};
if (_caller distance _target > 2) exitwith {Hint "You must be closer to the Doctor."};

hint format ["The hospital is %1, the patient is %2, the doctor is %3", _hospital, _caller, _target];
sleep 1;


hint "healing";

healing = 1;
sleep 5;
call ace_medical_treatment_fnc_fullHeal;
healing =0;
hint "healing complete"; 

 

Share this post


Link to post
Share on other sites
_hospitals = (nearestObjects [_target, ["C_Van_02_medevac_F"], 10] );
if (count _hospitals < 1) exitwith {hint "You are not at hospital."};
_hospital = _hospitals select 0;
hint format ["%1", _hospital]; sleep 10; if (isNull _hospital) exitwith {hint "You are not at hospital."};

Something like this might work?  Untested

Share this post


Link to post
Share on other sites

So that makes sense. I gave er a rip, but that didn't work. That returned a "error invalid number in expression" (which also does not make sense) with this line of code "_hospitals = (nearestObjects [_target, ["C_Van_02_medevac_F"], 10]);"

 

params ["_target", "_caller", "_actionId", "_arguments"];

_hospitals = (nearestObjects [_target, ["C_Van_02_medevac_F"], 10]);

hint format ["%1", _hospitals];

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×