Jump to content
iV - Ghost

Check if objects from array are inArea

Recommended Posts

I wanna check if a listed object is inArea of a marker.

But I'm not sure how to do this. Maybe something like this?

 

 

private _radioObjects = [

    "blabla1",
    "blabla2",
    "blabla3"

];


if ({alive _x && _x inArea "myMarker" && _x in _radioObjects} count _x > 0) then {

    execVM "task/task1.sqf";
  
};

 

 

Share this post


Link to post
Share on other sites

Personally I would sync the object with the trigger or if multiple objects were in question I would use this in the condition of a trigger:

 

 

obj1 inArea trig1 && obj2 inArea trig1 && obj3 inArea trig1 && obj4 inArea trig1 

 

Share this post


Link to post
Share on other sites
private _radioObjects = [blabla1, blabla2, blabla3]; 

if ( count (_radioObjects inAreaArray "myMarker" select { alive _x } ) > 0 ) then 
{
	[] execVM "task/task1.sqf";
};

 

Share this post


Link to post
Share on other sites

Wow, strings are objects? really?

private _radioObjects = [ blabla1,blabla2, blabla3 ]; // as far as they are objects, not triggers.

 

if ({alive _x && _x inArea "myMarker"} count _radioObjects > 0) then { execVM "task/task1.sqf"; };

Share this post


Link to post
Share on other sites

This is my list with the classnames I am looking for:

iV_radioObjects = [

    "Land_Communication_F",
    "Land_TTowerSmall_2_F",
    "Land_TTowerSmall_1_F",
    "Land_TTowerBig_2_F",
    "Land_TTowerBig_1_F"
	
];

 

I think I have to use typeOf but I don't get it working.

Share this post


Link to post
Share on other sites
0 = [] spawn {
  _radioObjects = ["Land_Communication_F","Land_TTowerSmall_2_F","Land_TTowerSmall_1_F","Land_TTowerBig_2_F","Land_TTowerBig_1_F"];
  if (count nearestObjects [getMarkerPos "myMarker",_radioObjects, getMarkerSize "myMarker" select 0] > 0) then {
    execVM "task/task1.sqf";
  };
};

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

OK thx. But my areas has a 300-800m radius.

Is using nearestObjects not bad for permorfance?

Share this post


Link to post
Share on other sites
2 minutes ago, iV - Ghost said:

OK thx. But my areas has a 300-800m radius.

Is using nearestObjects not bad for permorfance?

You don't have choice.. Use the 2D mode for this command. Your loop doesn't need to be checked every sec. 5 seconds is probably fine .

  • Thanks 1

Share this post


Link to post
Share on other sites

The finding works fine but if I destroy all of the radiotowers the task didn't end.

Seems that the dead radiotowers are still there. I have tried to work with nearEntities but then he can't find the radiotowers.

Any other ideas?

 

 

That's my Task_G1_CS.sqf which get loaded in my area:

// RUN ON DEDICATED SERVER OR PLAYER HOST
if (!isServer) exitWith {};



// VARIABLES
params ["_taskMarker", "_parentTask", "_radius"];
private _taskID = "Task_G1_CS";
private _taskTitle = localize "STR_iV_TaskTitle_ComSystems";
private _taskDescription = localize "STR_iV_TaskDesc_ComSystems";
private _taskMarkerType = "destroy";



// CHECK FOR TASK
if ((count (getMarkerPos _taskMarker nearEntities [iV_radioObjects, _radius])) == 0) exitWith {};



// CREATE PARENT AND CHILD TASK
["Task"] call iV_fnc_taskCreate;



// TIMEOUT & TRIGGER END
sleep 30;

waitUntil {

    sleep 5;
    (count (getMarkerPos _taskMarker nearEntities [iV_radioObjects, _radius])) == 0;
    //count nearestObjects [getMarkerPos _taskMarker, iV_radioObjects, _radius, true] == 0;
	
};



// TASK SUCCEEDED
if ((count (getMarkerPos _taskMarker nearEntities [iV_radioObjects, _radius])) == 0) then {

    ["Succeeded"] call iV_fnc_taskState;
	
    iV_Tasks pushBack "scripts\taskmanager\tasks\Task_G1_CS.sqf";
    publicVariable "iV_Tasks";
	
};

 

Share this post


Link to post
Share on other sites
2 hours ago, iV - Ghost said:

The finding works fine but if I destroy all of the radiotowers the task didn't end.

Seems that the dead radiotowers are still there. I have tried to work with nearEntities but then he can't find the radiotowers.

Any other ideas?

Use nearestObjects and alive comands.

  • Thanks 1

Share this post


Link to post
Share on other sites

Thx. Probably too long in this square box looked.^^

 

if ({alive _x} count (nearestObjects [getMarkerPos _taskMarker, iV_radioObjects, _radius, true]) == 0) exitWith {};

 

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

×