Svartalfheim 2 Posted March 27, 2020 When i add an unit and then play the scenario, die and then respawn, the loadout that i created returns to default. is there any way to create a unit with my loadout or solving this thing? i tried creating a custom composition but it didn't worked out for me. 2 Share this post Link to post Share on other sites
JohnKalo 657 Posted March 27, 2020 I used the one posted here by @GEORGE FLOROS GR And after so much time I now discovered that it has to be in the initPlayerLocal.sqf !!! Might have to change this for all our missions. Now going crazy 🤪 2 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4206 Posted March 28, 2020 (edited) On 3/27/2020 at 2:49 PM, Svartalfheim said: die and then respawn, the loadout that i created returns to default. On 3/27/2020 at 5:53 PM, JohnKalo said: initPlayerLocal.sqf Hello there Guys ! Welcome also @Svartalfheim to BI Forums ! It's good to take a look always here : https://community.bistudio.com/wiki/Initialization_Order https://community.bistudio.com/wiki/Event_Scripts Since the certain code is about all the units , players and ai , you can add this in the init.sqf : addMissionEventHandler ["EntityKilled", { params ["_unit", "_killer", "_instigator", "_useEffects"]; if(isPlayer _unit)then{ [_unit, [profileNamespace, "inventory_var"]] call BIS_fnc_saveInventory; }else{ [_unit, [missionNamespace, "inventory_var"]] call BIS_fnc_saveInventory; }; }]; addMissionEventHandler ["EntityRespawned", { params ["_entity", "_corpse"]; if(isPlayer _entity)then{ if ( profileNamespace getVariable[ "bis_fnc_saveInventory_data", [] ] find "inventory_var" > -1 ) then { [_entity, [profileNamespace, "inventory_var"]] call BIS_fnc_loadInventory; }; }else{ [_entity, [missionNamespace, "inventory_var"]] call BIS_fnc_loadInventory; }; }]; Edited March 31, 2020 by GEORGE FLOROS GR updated ( from Larrow's post ) 2 Share this post Link to post Share on other sites
JohnKalo 657 Posted March 29, 2020 But for init.sqf it says it applies for Single Player. The method I used so far worked only for host as it seems although the two files were execVM through the init.sqf. execVM "Scripts\onPlayerKilled.sqf"; execVM "Scripts\onPlayerRespawn.sqf"; EDIT: Found it. The EventHandlers work for all. Thanks 👍 2 Share this post Link to post Share on other sites
JohnKalo 657 Posted March 29, 2020 Update: Updated all my missions The above method works although it does show an error at the editor in the beggining of the mission stating: [BIS_fnc_loadInventory] Inventory "inventory_var" not found Hope it is nothing cause I spent about an hour and a half updating all missions. 2 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4206 Posted March 29, 2020 10 hours ago, JohnKalo said: [BIS_fnc_loadInventory] Inventory "inventory_var" not found NO idea ! 2 Share this post Link to post Share on other sites
JohnKalo 657 Posted March 30, 2020 Well since it works all good 👌 If anything happens at MP further testing we will check it again. 2 Share this post Link to post Share on other sites
Larrow 2779 Posted March 30, 2020 On 3/29/2020 at 1:29 PM, JohnKalo said: [BIS_fnc_loadInventory] Inventory "inventory_var" not found addMissionEventHandler ["EntityRespawned", { params ["_entity", "_corpse"]; if(isPlayer _entity)then{ if ( profileNamespace getVariable[ "bis_fnc_saveInventory_data", [] ] find "inventory_var" > -1 ) then { [_entity, [profileNamespace, "inventory_var"]] call BIS_fnc_loadInventory; }; }else //snip I'm guessing players are respawn on start, so the inventory var does not exist yet. 2 1 Share this post Link to post Share on other sites
JohnKalo 657 Posted April 1, 2020 @Larrow Thanks but is it ok if I leave it as it was? Because it did work one time that I tested it and I do have it in all missions now Also does the above work for players and AI too? I suspect it does but just to be 200% sure. Share this post Link to post Share on other sites