Hello, i need some help. I've copied scripts that Persian MO pasted on page 5, and modified them a little bit to my needs. The problem is... that the crates save the equipment but for example if i put a weapon in one crate it appears in the second one too. I want them to work separately, that means if i put something in one of them it won't appear in the other one.
Ammobox init:
null = [this] execVM "load_box.sqf";null = [this] execVM "save_box.sqf"
load_box.sqf
_object = _this select 0;
_inidbi = ["new", "crates"] call OO_INIDBI;
_items = ["read", ["box", "locker"]] call _inidbi;
clearItemCargoGlobal _object;
clearWeaponCargoGlobal _object;
clearBackpackCargoGlobal _object;
clearMagazineCargoGlobal _object;
if(!(_items isEqualTo [])) then
{
{
_subArr = _items select _forEachIndex;
_weps = _subArr select 0;
_wepsCount = _subArr select 1;
_mags = _subArr select 2;
_magsCount = _subArr select 3;
_itemss = _subArr select 4;
_itemsCount = _subArr select 5;
_backpacks = _subArr select 6;
_backpacksCount = _subArr select 7;
{
_object addWeaponCargoGlobal[_x,_wepsCount select _forEachIndex];
} forEach _weps;
{
_object addMagazineCargoGlobal[_x,_magsCount select _forEachIndex];
} forEach _mags;
{
_object addItemCargoGlobal[_x,_itemsCount select _forEachIndex];
} forEach _itemss;
{
_object addBackpackCargoGlobal[_x,_backpacksCount select _forEachIndex];
} forEach _backpacks;
} forEach _items;
};
hint "Loading completed";
save_box.sqf
_object = _this select 0;
Sleep 1;
while {true} do {
Sleep 5;
_saveArray = [];
_guns = getWeaponCargo _object;
_mags = getMagazineCargo _object;
_items = getItemCargo _object;
_backpacks = getBackpackCargo _object;
_subArray = _guns + _mags + _items + _backpacks;
_saveArray set [count _saveArray,_subArray];
_inidbi = ["new", "crates"] call OO_INIDBI;
_bool=["write", ["box", "locker", _saveArray]] call _inidbi;
hint format ["Status: %1",_bool];
};
Edit:
Never mind i found alternative.
https://forums.bistudio.com/topic/173785-save-ammobox-contents-after-restart/