Jump to content
Sign in to follow this  
S.Newbould

RE: Stopping createVehicle spawning where it shouldnt be

Recommended Posts

Hi guys newbie to coding here :confused:

Just playing around trying to teach myself a few things and reading materials and what not and decided I would try to make a vehicle spawner with a simple addAction command on a AI unit. I have noticed when I click on the action to spawn in my vehicle it spawns it however say I wanted to spawn another one it would spawn it next to the previous vehicle I spawned. Essentially what I am trying to find out is how to stop say another vehicle spawning if one is already on the spawn point so when its moved another one can be spawned in the same position without being spawned next to it...

Thanks in advanced for your help!

Code so far:

_newPlane = "I_Plane_Fighter_03_CAS_F" createVehicle (position planeSpawn);

_newPlane setDir 205;

Share this post


Link to post
Share on other sites

You could use this:

_vehCheck= nearestObjects[position planeSpawn,["landVehicle","Air","Ship"],radius] select 0; //Checks for vehicles at the given Position with inside the radius

if(!isNil "_vehCheck") then {
deleteVehicle _vehCheck;
} else {
_newPlane = "I_Plane_Fighter_03_CAS_F" createVehicle (position planeSpawn); 
_newPlane setDir 205;
};

Share this post


Link to post
Share on other sites

Rather than deleting the vehicle that's in the way, could warn the player of its presence and not allow the spawn by just replacing the deleteVehicle line in the above code with a hint or chat message.

Share this post


Link to post
Share on other sites

Thanks to both it got me what I wanted! Grimes thats what I wanted in the first place! haha...

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  

×