/*
File: fn_spawnVehicle.sqf
Author: Bryan "Tonic" Boardwine
Description:
Spawns the selected vehicle, if a vehicle is already on the spawn point
then it deletes the vehicle from the spawn point.
*/
disableSerialization;
private["_position","_direction","_className","_displayName","_spCheck","_cfgInfo"];
if(lnbCurSelRow 38101 == -1) exitWith {hint "You did not select a vehicle to spawn!"};
_className = lnbData[38101,[(lnbCurSelRow 38101),0]];
_displayName = lnbData[38101,[(lnbCurSelRow 38101),1]];
_position = getMarkerPos VVS_SP;
// Check if we are over water (and assume we are on the USS Freedom).
if ( surfaceIsWater _position ) then {
_position = getPosATL Nimitz_Spawn;
};
_direction = markerDir VVS_SP;
//Make sure the marker exists in a way.
if(isNil "_position") exitWith {hint "The spawn point marker doesn't exist?";};
_cfgInfo = [_className] call VVS_fnc_cfgInfo;
//Check to make sure the spawn point doesn't have a vehicle on it, if it does then delete it.
_spCheck = nearestObjects[_position,["landVehicle","Air","Ship"],12] select 0;
if(!isNil "_spCheck") then {deleteVehicle _spCheck;};
//_vehicle = _className createVehicle _position;
_vehicle = createVehicle [_className,_position, [], 0, "NONE"];
_vehicle allowDamage false;
//Make sure it gets set onto the position.
//_vehicle setPos _position;
_vehicle setposatl [(_position select 0) , (_position select 1) , (_position select 2)];
_vehicle setDir _direction; //Set the vehicles direction the same as the marker.
//Make sure it gets sets upright.
//_vehicle setVectorUP (surfaceNormal [(getPosatl _vehicle) select 0,(getPosatl _vehicle) select 1]);
[_vehicle] spawn DEVAS_AutoPilot;
[_vehicle] spawn DEVAS_Loiter;
if((_cfgInfo select 4) == "Autonomous") then
{
createVehicleCrew _vehicle;
};
if(VVS_Checkbox) then
{
clearWeaponCargoGlobal _vehicle;
clearMagazineCargoGlobal _vehicle;
clearItemCargoGlobal _vehicle;
};
_vehicle allowDamage true;
hint format["You have spawned a %1",_displayName];
closeDialog 0;
Yo this is a life saver for placing planes! Thanks to this thread. I am using Nimitz Carrier and this work splendid. The only issue I'm having is a error message pop-up on screen (Error seen here: https://pasteboard.co/JSbXDgT.png). Also is there a way so that when I spawn I second vehicle it will place next to the one I spawn previously? (and if not how do I get rid the first one I spawned deleted because if I spawn 2 vehicles on one spawn it blows up and kills me) https://pasteboard.co/JSbXDgT.png