Jump to content

Recommended Posts

So, I am trying to make a script that deletes all empty vehicles in an area defined by a marker every 5 minutes

 

That works fine at the moment, however, I'm struggling on how to make it so if a player is within 10 meters of any vehicle then it won't delete it.

 

Spoiler

while {true} do {

            

        

_og = getMarkerPos "myMarker";

_vehicles = _og nearEntities [["Car","Tank","Air"], 50];    

 

    {

 

        if ((count (vehicles inAreaArray "myMarker") > 0) && {!(count crew _x > 0)}) then {

            deleteVehicle _x;

        };

    } forEach _vehicles

 

    uiSleep 300 ;

 

};

 

Share this post


Link to post
Share on other sites
{
	private _veh = _x;
	if (!((getPos _veh) inAreaArray "myMarker")) then {continue;};
	if (count crew _veh > 0) then {continue;};
	if (({_x distance2d _veh < 10} count allPlayers) != 0) then {continue;};
  	deleteVehicle _x;
} forEach _vehicles 

Something like that?  Untested

  • Like 1

Share this post


Link to post
Share on other sites

If your marker is circular, you don't need test for marker area, just apply the radius!


 

0 = [] spawn {
  _og = getMarkerPos "myMarker";
  while {true} do {
    {
      private _veh = _x;
      if (count crew _veh == 0 && {allPlayers findIf {_veh distance2D _x < 10} == -1}) then {
        deleteVehicle _veh;
      };
    } forEach ( _og nearEntities ["allVehicles", 50]);
    sleep 300;
  };
};

 

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

×