Jump to content
Sign in to follow this  
deadlyfishes

Spawn empty vehicles using a trigger

Recommended Posts

I'm looking to spawn a vehicle only after a trigger is activated.

Basically, I want to spawn empty jets at the airport after a trigger is activated by defeating all enemy forces.

I've tried this script here:

http://forums.bistudio.com/showthread.php?154593-Is-it-possible-to-spawn-vehicles-on-a-trigger

But the issue with that is that the jets are spawning with men inside. I want them to be empty. Tried various things to no avail.

Is there any init/on act lines I could use or anything I could fix to get this to work the way I want?

Another solution I had was when they spawn in, have a trigger area that has the pilots inside the newly spawn jets to get out, but still could not find a simple init/onact line for this since I can't really find the unit and vehicle name of a newly spawned vehicle.

Any ideas? Thanks :D

Share this post


Link to post
Share on other sites
if (isServer) then {
_vehicleObject = createVehicle ["B_Plane_CAS_01_F", getMarkerPos "spawn", [], 0, ""];_vehicleObject setDir 150.524;
_vehicleName = "JET";

missionNamespace setVariable [_vehicleName,_vehicleObject];
publicVariable _vehicleName;
};

Share this post


Link to post
Share on other sites

Your syntax is wrong, you're using createVehicle (array) which spawns vehicles with units inside

_vehicleObject = createVehicle ["B_Plane_CAS_01_F", getMarkerPos "spawn", [], 0, ""]

//Change that to this:

_vehicleObject = "B_Plane_CAS_01_F" createVehicle (getMarkerPos "spawn");

I would also put that setDir on a new line, but that's just me.

Share this post


Link to post
Share on other sites
Your syntax is wrong, you're using createVehicle (array) which spawns vehicles with units inside

I think you're confusing it with BIS_fnc_spawnVehicle, createVehicle array does the same as createVehicle but with more options. And apparently some other differences, if you look at the notes of createVehicle:

Posted on March 27 2014 - 02:15

Floriangeyer

According to Code Optimisation, this function is considered deprecated and createVehicle array should be used instead.

I doubt it's critical in this case, though, so as long as it works. The reason why the first one doesn't might be because of the last parameter being "" instead of "NONE"?

Share this post


Link to post
Share on other sites

You're right, I was thinking of another function. Just did a quick test in the editor and can confirm createVehicle array works as intended. Somewhere along the way, units are being added to your vehicle. If I'm remembering correctly, if you spawn a vehicle, and then spawn some units in the same position the units will end up inside the vehicle somehow. Maybe I dreamt that, but it's something to watch out for. Also, you can stick this little code snippet somewhere to make sure there are no units in your spawned vehicles.

{
_vehicle deleteVehicleCrew _x;
} forEach _vehicle crew;

Share this post


Link to post
Share on other sites
I think you're confusing it with BIS_fnc_spawnVehicle, createVehicle array does the same as createVehicle but with more options. And apparently some other differences, if you look at the notes of createVehicle:

I removed that note, it was incorrect. "class" createVehicle pos is the same as createVehicle ["class", pos, [], 0, "NONE"] only faster, since it doesn't need to parse array of params

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  

×