ozdeadmeat 12 Posted December 23, 2017 Hi everyone, I have written a function that will allow people to configure an aircraft in the 3den editor and have it able to respawn with that exact loadout. I found that I was having very inconsistent results when the respawn module was set to delete or delete with explosion. It has been rock solid since setting the module to preserve. The function deletes the old vehicle once it has all the old data anyway. Instructions You will need two things for this function to work: You will need to create an init.sqf file in your mission folder and paste the code below into it. You will need a respawn module in your mission with the customized vehicles synced to it. Put this code into the Expression section:: [_this, 2] call RESPAWN_VEHICLE; Note: The number allows you to customize what happens with the cargo of the respawning vehicles (guns, medickits etc etc). It is all listed in the function below Optional If you want to be able to edit and move the vehicles as Zeus, you will need to add an "Add Editable Objects" module to your mission and name it ZEUS_EDITABLE and put the variable name of your zeus player unit in the owner section. In the script do a search for "ZEUS_EDITABLE" and uncomment it. Spoiler RESPAWN_VEHICLE = { /* Function by OzDeaDMeaT Date: 22/11/2017 Usage: [_this, <Keep Vehicle Cargo>] call RESPAWN_VEHICLE; //This is to be placed in a Vehicle Respawn Module <Keep Vehicle Cargo> Options: 0 = Do Nothing with Cargo 1 = ClearCargo 2 = Load Dead Vehicles Cargo Back into New Vehicle Example1: [_this, 2] call RESPAWN_VEHICLE; //This Example will retain the old vehicles cargo and place it in the newly respawned vehicle */ private ["_veh", "_OLDveh", "_KeepCargo", "_txtr", "_LoadStuff", "_CargoMAGS", "_CargoWEAP", "_CargoITEM", "_CargoBKP", "_syncedObjects", "_lockedArray", "_lockVeh", "_CurrentpylonMAGs", "_pylonPaths", "_i", "_j", "_k", "_nonPylonWeapons" ]; _veh = (_this select 0) select 0; _OLDveh = (_this select 0) select 1; _KeepCargo = _this select 1; _CurrentpylonMAGs = getPylonMagazines _OLDveh; //Get old vehicle pylon mags _syncedObjects = synchronizedObjects _OLDveh; //Get the old vehicles synced objects _txtr = getObjectTextures _OLDveh; //Get old vehicle textures _OLDveh setpos [0,0,-9999]; ///START SYNCED OBJECTS //ZEUS_EDITABLE synchronizeObjectsAdd [_veh]; //{_x synchronizeObjectsAdd [_veh]} foreach _syncedObjects; //_veh synchronizeObjectsAdd _syncedObjects; //This syncs the old objects to the new vehicle ///END SYNCED OBJECTS ///START VEHICLE LOCK _lockedArray = ["UNLOCKED","DEFAULT","LOCKED","LOCKEDPLAYER"]; //This is needed to reset the vehicle lock _lockVeh = locked _OLDveh; _veh setVehicleLock (_lockedArray select _lockVeh); ///END VEHICLE LOCK ///START BLACK MAGIC FOR VEHICLE PYLONS _pylonPaths = (configProperties [configFile >> "CfgVehicles" >> typeOf _veh >> "Components" >> "TransportPylonsComponent" >> "Pylons", "isClass _x"]) apply {getArray (_x >> "turret")}; //Gets pylon paths from Config _nonPylonWeapons = []; {_nonPylonWeapons append getArray (_x >> "weapons")} forEach ([_veh, configNull] call BIS_fnc_getTurrets); {_veh removeWeaponGlobal _x } forEach ((weapons _veh) - _nonPylonWeapons); if (count _pylonPaths != 0) then { for "_j" from 0 to ((count _pylonPaths) -1) do { _veh setPylonLoadOut [_j + 1, _CurrentpylonMAGs select _j, false, _pylonPaths select _j]; }; }; ///END BLACK MAGIC FOR VEHICLE PYLONS ///START VEHICLE TYPE SPECIFIC TWEAKS if(typeOf _veh == "B_Plane_Fighter_01_F") then {[_veh,"",["wing_fold_l",1]] call BIS_fnc_initVehicle}; //THIS WILL START THE JETS OFF WITH FOLDED WINGS if(typeOf _veh == "B_Plane_Fighter_01_Stealth_F") then {[_veh,"",["wing_fold_l",1]] call BIS_fnc_initVehicle}; //THIS WILL START THE JETS OFF WITH FOLDED WINGS ///END VEHICLE TYPE SPECIFIC TWEAKS ///START SET VEHICLE TEXTURE if !(isNil "_txtr") then { for "_k" from 0 to (count _txtr - 1) do { _veh setObjectTextureGlobal [_k, _txtr select _k]; }; }; ///END SET VEHICLE TEXTURE ///START VEHICLE CARGO _LoadStuff = { private["_crate","_array","_count","_i","_Job", "_arr1", "_arr2"]; //Usage [<object>, <Job>, <array>] call _LoadStuff _crate = _this select 0; //Object ClassNames are being loaded into _Job = _this select 1; //Options are "AMMO" , "WEAP" , "ITEM" , "BKP" _arr1 = (_this select 2) select 0; //ClassName _arr2 = (_this select 2) select 1; //Amount _count = count _arr1; if(_Job == "AMMO") then { for "_i" from 0 to (_count - 1) do { _crate addMagazineCargoGlobal [(_arr1 select _i),(_arr2 select _i)];};}; if(_Job == "WEAP") then { for "_i" from 0 to (_count - 1) do { _crate addWeaponCargoGlobal [(_arr1 select _i),(_arr2 select _i)];};}; if(_Job == "ITEM") then { for "_i" from 0 to (_count - 1) do { _crate addItemCargoGlobal [(_arr1 select _i),(_arr2 select _i)];};}; if(_Job == "BKP") then { for "_i" from 0 to (_count - 1) do { _crate addBackpackCargoGlobal [(_arr1 select _i),(_arr2 select _i)];};}; }; If (_KeepCargo != 0) then { clearMagazineCargoGlobal _veh; clearWeaponCargoGlobal _veh; clearItemCargoGlobal _veh; If (_KeepCargo == 2) then { _CargoMAGS = getMagazineCargo _OLDveh; [_veh,"AMMO",_CargoMAGS] call _LoadStuff; _CargoWEAP = getWeaponCargo _OLDveh; [_veh,"WEAP",_CargoWEAP] call _LoadStuff; _CargoITEM = getItemCargo _OLDveh; [_veh,"ITEM",_CargoITEM] call _LoadStuff; _CargoBKP = getBackpackCargo _OLDveh; [_veh,"BKP",_CargoBKP] call _LoadStuff; }; }; ///END VEHICLE CARGO deleteVehicle _OLDveh; }; Things I am trying to work out currently: - Why the sync commands don't work at all. My goal was the have it pick up all the objects the old vehicle was synced too. Alas I haven't worked that out yet. - Work out if its possible to get all the customizations like missing doors on vehicles from the old vehicle and pass them onto the new one. I have tested this in Multiplayer and it does work. DEMO MISSION AVAILABLE HERE 1 Share this post Link to post Share on other sites
pierremgi 4831 Posted December 23, 2017 You respawn everything you want: crew, appearance, pylons, even too often forgotten addAction on vehicles. Share this post Link to post Share on other sites
code34 248 Posted December 23, 2017 GG ! But I do not understand the interest of this type of script that has been already developed thousand of times in dynamic missions. There is probably something that will make the difference, but which one? Share this post Link to post Share on other sites
ozdeadmeat 12 Posted December 23, 2017 13 hours ago, pierremgi said: Ahh cool, I see a lot of these kinds of scripts that read more like hieroglyphics than code (that's just me, definitely not a coder here). No comments that explain what each bit does, looks very efficient but I just don't have the skills to write or understand that kind of stuff. My script is more aimed for people who don't want to pass multiple parameters to a script and don't have a coding background. Thanks for your comment though :) Share this post Link to post Share on other sites
ozdeadmeat 12 Posted December 23, 2017 10 hours ago, code34 said: GG ! But I do not understand the interest of this type of script that has been already developed thousand of times in dynamic missions. There is probably something that will make the difference, but which one? I couldn't find a script that inherited the vehicle loadout defined in 3den post respawn. This function has 1 job and that is it. I was more after a simple way to utilize the function rather than features that I wasn't interested in. It's good to chat to you again mate. We should have a few games of Arma 3 over the break if you are free. Share this post Link to post Share on other sites
code34 248 Posted December 23, 2017 i m always avalaible for everyone ;) just pm me but dont wait for me any advice on editor cause i m a script coder. Share this post Link to post Share on other sites
mrakos2005 4 Posted April 25, 2019 Hi gents, just tried this and can confirm is working great apart from not saving a chute that I added to one of sab's ww2 planes... the pylons are saved though. Many thanks for doing this! Share this post Link to post Share on other sites
pierremgi 4831 Posted April 25, 2019 On 12/23/2017 at 8:23 AM, ozdeadmeat said: Ahh cool, I see a lot of these kinds of scripts that read more like hieroglyphics than code (that's just me, definitely not a coder here). No comments that explain what each bit does, looks very efficient but I just don't have the skills to write or understand that kind of stuff. My script is more aimed for people who don't want to pass multiple parameters to a script and don't have a coding background. Thanks for your comment though 🙂 The reason why i did a module. Cheers Share this post Link to post Share on other sites
VedKay 2 Posted April 24, 2021 Hey there ozdeadmeat, Great little script mate. I just have one question. I'm having a bit of trouble with pylon ownership control. When the Heli re-spawns it reverts back to the Gunner owning/controlling the weapons. In the editor's Heli attributes, I've set pylon control to Pilot. Is there a way the script could also carry over the Pilot's pylon ownership? I did a bit of digging and the only thing I could find was the below quote, not sure if that means anything to you : Quote turret[] = {}; // default owner of pylon/weapon, empty for driver Anyway this is a fantastic little script mate, cheers. Share this post Link to post Share on other sites