Jump to content
Sign in to follow this  
Mike4010

Simple Garage System

Recommended Posts

Hello there, scripting beginner here.

I've been trying to script a simple "spawn system" in the editor  and i am having a hard time with it.

So what i want to achieve is if i execute an action (attached to an object per addAction which leads to my script), i want the script to check if area A (a helipad)  is free. If it is, a MH900 should spawn at area A, if not it should spawn at area B which is next to area A.

So my script (which is most likely riddled with nonsense and errors) looks like that:

loc = createLocation ["NameLocal",[8422.922,18207.314,0],10,10]; 
veh = nearestObject [[8423.22,18207.4,0.00146484],"LandVehicle"];
pos = getPos veh;
if (pos in loc) then
{
createVehicle ["C_Heli_Light_01_civil_F" ,[8431.15,18223.9,0.00164795], [], 0, "CAN_COLLIDE"]; //Area A
}
else
{
createVehicle ["C_Heli_Light_01_civil_F" ,[8423.22,18207.4,0.00146484], [], 0, "CAN_COLLIDE"]; // Area B
};

 It is sort of working but is there any better way to achieve the same effect without creating a location, checking if the nearest object is in the location etc.?

If the vehicle blocking the spawn area is anything but a land vehicle it obviously doesn't work. Is there any way to search for all sorts of vehicles with nearestObject?

How would you script that in order to work with all sorts of vehicles blocking the spawn? If there are any other improvements and/or expansions you would like to suggest, feel free to add it, always happy to learn new Things!

 

Thank you in advance and sorry for bothering with my noobie-errors! :thanx:

Share this post


Link to post
Share on other sites

To check if an object is inside a location, use inAreaArray command.

 

Anyway, you should place some invisible helipads (Land_helipadEmpty_F), far better than location. Name them.

Then use the neatEntities (preferable ) or the  nearestObjectS commands.

 

_arrayObjects = getPos yourHelipad1 nearEntities [["landVehicle","air"], 20];

// or _arrayObjects = nearestObjects [getPos yourHelipad1, ["landVehicle","air"], 20];

if (count _arrayObjets > 0) then {hint "this place is not vacant"};

Share this post


Link to post
Share on other sites

Thank you very much! I have even extended the script to work with even three helipads now. Appreciate the help!

 

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  

×