Jump to content
Sign in to follow this  
AfrographX

_vehicle = nearestObject [_heli, "_array"]

Recommended Posts

Hi,

I want to check if the nearestobject to the helicopter is of a certain type defined in an array:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">veharray = ["UKF_WMIK","UKF_WMIKG","UKF_WMIKM","UKF_WMIKDES","UKF_WMIKGDES","UKF_WMIKMDES"]

_vehicle = nearestObject [_heli, "_veharray"]

But somehow it doesn't work, I don't even get an error message.

Does somebody know what I did wrong?

Share this post


Link to post
Share on other sites
Does somebody know what I did wrong?

Quite a lot.

First of all, at least in your example you used two different variable names: variable and _variable (global/local). Secondly, it doesn't make any sense to pass a variable enquoted as string. Third, nearestObject doesn't work with passed arrays. You can only pass a vehicle type (string) at once.

Thus, you need a function to get the nearest object selected out of a list of vehicle names.

fNearestObjectList.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private ["_o","_a","_d","_no","_r"];

_o=_this select 0;

_a=_this select 1;

_d=200;

{

_no=nearestObject[_o,_x];

if((_o distance _no)<_d)then

{

_r=_no;

_d=_o distance _r;

};

}

forEach _a;

_r

Syntax:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">nearestObject = [object, array_types] call fNearestObjectList

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  

×