Jump to content
Hairy Potter

Automatic inventory saving when VA is closed

Recommended Posts

I found a variant where the contents of the inventory are automatically saved when they die.

onPlayerKilled.sqf

[player, [missionNamespace, "inventory_var"]] call BIS_fnc_saveInventory;

onPlayerRespawn.sqf

[player, [missionNamespace, "inventory_var"]] call BIS_fnc_loadInventory;

The option is simple and works fine, but in my case it's not entirely practical.
Is it possible to change the process of saving from death, for example, to when you close the virtual arsenal?
Like closing VA through "Esc" or "Close" button and the equipment selected by you is stored and loaded after death.

  • Like 1

Share this post


Link to post
Share on other sites

initPlayerLocal.sqf

[missionNamespace, "arsenalClosed", {
	player setVariable ["Saved_Loadout",getUnitLoadout player];
	hint "Selected gear saved!"
	}] call BIS_fnc_addScriptedEventHandler;
player addEventHandler ["Respawn",{

		0 = [_this select 0] spawn {
		
			params [["_player",objNull,[objNull]]];
				waitUntil {sleep .2; alive _player};
				_player setUnitLoadout (_player getVariable ["Saved_Loadout",[]]);
				
		};
}];

 

  • Like 2

Share this post


Link to post
Share on other sites
2 hours ago, davidoss said:

initPlayerLocal.sqf


[missionNamespace, "arsenalClosed", {
	player setVariable ["Saved_Loadout",getUnitLoadout player];
	hint "Selected gear saved!"
	}] call BIS_fnc_addScriptedEventHandler;
player addEventHandler ["Respawn",{

		0 = [_this select 0] spawn {
		
			params [["_player",objNull,[objNull]]];
				waitUntil {sleep .2; alive _player};
				_player setUnitLoadout (_player getVariable ["Saved_Loadout",[]]);
				
		};
}];

 

 

Already checked. Works great. Thank you so much

 

1 hour ago, GEORGE FLOROS GR said:

Hello there Hairy Potter!

 

Check also this:

 

 

It looks very interesting. Thank you! I'll try

  • Like 1

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

×