//how to call it
[for who it is supposed to open, where the garage is supposed to be] call bis_fnc_garageNew;
//example usage (adds the Virtual Garage as an interaction to an object)
this addaction ["Open Virtual Garage", {[_this select 1, getPos spawn_pad_1] call BIS_fnc_garageNew;}];
//(spawn_pad_1 is the variable name of a helipad)
//put this into init.sqf
bis_fnc_garageNew = {
_caller = _this select 0;
_pos = _this select 1;
//Deletes all vehicle in a 15 meter radius of the spawn location
{deleteVehicle _x;}foreach nearestObjects [_pos, ["AllVehicles"], 15];
sleep(0.1);
//Creates a temporary invisible helipad on the location of the _pos marker
BIS_fnc_garage_center = createVehicle [ "Land_HelipadEmpty_F", _pos, [], 0, "CAN_COLLIDE" ];
//Opens the garage
[ "Open", true ] call BIS_fnc_garage;
sleep(2);
//Wait until garage is closed
waitUntil{isNull (uinamespace getvariable ["BIS_fnc_arsenal_cam",objnull])};
sleep(0.1);
//Teleport _caller into driver of newly spawned (local) vehicle
{_caller moveInDriver _x}foreach nearestObjects [_pos, ["AllVehicles"], 10];
//Spawns the new vehicle
[_caller, _pos] spawn {
_caller = _this select 0;
_pos = _this select 1;
//Wait until _caller is inside a vehicle
waitUntil{(vehicle _caller) != _caller};
//Figure out which type of (local) vehicle was spawned
_vehType = typeOf Vehicle _caller;
//Delete old (local) vehicle
deleteVehicle (Vehicle _caller);
sleep 0.1;
//Spawn the new (global) vehicle
_veh = createVehicle [_vehType, _pos, [], 0, "CAN_COLLIDE"];
//Teleport _caller into driver
_caller moveInDriver _veh;
};
}
Comments