davidoss 552 Posted December 31, 2018 Hi i have this: private _fnc_getStack = { params [["_keys",[],[[]]], ["_values",[],[[]]]]; _merged = _keys apply {[_x,(_values select (_keys find _x))]}; _merged //[["10Rnd_9x21_Mag","FirstAidKit"],[1,2]] }; private _weapons = ((getWeaponCargo _vehicle) call _fnc_getStack); private _mags = ((getMagazineCargo _vehicle) call _fnc_getStack); private _items = ((getItemCargo _vehicle) call _fnc_getStack); private _bags = ((getBackpackCargo _vehicle) call _fnc_getStack); //[["10Rnd_9x21_Mag",1],["FirstAidKit",2]] private _vehicleItems = []; { for "_i" from 1 to (_x # 1) do { _vehicleItems pushBack (_x # 0); }; } forEach (_weapons+_mags+_items+_bags); //["10Rnd_9x21_Mag","FirstAidKit","FirstAidKit"] It looks pretty ugly for me. I wanna ask you guys if you have any idea how to write this better! Share this post Link to post Share on other sites
M1ke_SK 230 Posted December 31, 2018 private _vehicleItems = backpackCargo _vehicle + magazineCargo _vehicle + itemCargo _vehicle + weaponCargo _vehicle; 3 1 Share this post Link to post Share on other sites
davidoss 552 Posted December 31, 2018 Well i must say this, sometimes is better to go fishing... Do you have such solution for units inventory as well? 1 1 Share this post Link to post Share on other sites
M1ke_SK 230 Posted December 31, 2018 1 hour ago, davidoss said: Do you have such solution for units inventory as well? it works with units also, just replace _vehicle with _unit note: it return items that are stored inside uniform, vest, backpack. if you want also assigned items (nvg, weapon, handgun), you need additional check for that Share this post Link to post Share on other sites
johnnyboy 3789 Posted December 31, 2018 getUnitLoadout could help with this also. Share this post Link to post Share on other sites
davidoss 552 Posted December 31, 2018 @johnnyboy Yes i have started with getUnitLoadout , this give me all things nicely but again completely nested + [] and "" [ ["srifle_DMR_05_blk_F","muzzle_snds_93mmg_tan","acc_pointer_IR","optic_DMS",["10Rnd_93x64_DMR_05_Mag",10],[],"bipod_01_F_blk"], ["launch_MRAWS_olive_F","","acc_pointer_IR","",["MRAWS_HEAT_F",1],[],""], ["hgun_Pistol_heavy_01_F","","","",["11Rnd_45ACP_Mag",11],[],""], ["U_BG_Guerilla1_1",[["FirstAidKit",1],["10Rnd_50BW_Mag_F",1,10]]], ["V_PlateCarrier2_rgr",[["MineDetector",1],["FirstAidKit",1],["1Rnd_HE_Grenade_shell",4,1],["HandGrenade",3,1],["SmokeShell",3,1],["11Rnd_45ACP_Mag",2,11],["10Rnd_93x64_DMR_05_Mag",2,10],["Chemlight_green",1,1],["Laserbatteries",1,1]]], ["B_Carryall_mcamo",[["FirstAidKit",1],["Medikit",1],["1Rnd_HE_Grenade_shell",8,1],["APERSTripMine_Wire_Mag",3,1],["11Rnd_45ACP_Mag",1,11],["10Rnd_93x64_DMR_05_Mag",1,10],["MRAWS_HEAT_F",1,1],[["hgun_Pistol_heavy_01_F","muzzle_snds_acp","acc_flashlight_pistol","optic_MRD",["11Rnd_45ACP_Mag",11],[],""],1]]], "H_Booniehat_khk_hs", "L_shemagh_white", ["Laserdesignator_02","","","",["Laserbatteries",1],[],""], ["ItemMap","ItemGPS","ItemRadio","ItemCompass","ItemWatch","NVGogglesB_gry_F"] ] @M1ke_SK backpackCargo player + magazineCargo player + itemCargo player + weaponCargo player + weapons player + assignedItems player + [backpack player] + [vest player ] + [uniform player] is not give me all things and doubles weapons if stored in inventory [ "10Rnd_50BW_Mag_F","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","HandGrenade", "HandGrenade","HandGrenade","SmokeShell","SmokeShell","SmokeShell","11Rnd_45ACP_Mag","11Rnd_45ACP_Mag","10Rnd_93x64_DMR_05_Mag", "10Rnd_93x64_DMR_05_Mag","Chemlight_green","Laserbatteries","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell", "1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","APERSTripMine_Wire_Mag", "APERSTripMine_Wire_Mag","APERSTripMine_Wire_Mag","11Rnd_45ACP_Mag","10Rnd_93x64_DMR_05_Mag","MRAWS_HEAT_F","FirstAidKit","MineDetector","FirstAidKit", "FirstAidKit","Medikit","hgun_Pistol_heavy_01_F","srifle_DMR_05_blk_F","launch_MRAWS_olive_F","Laserdesignator_02","hgun_Pistol_heavy_01_F", "hgun_Pistol_heavy_01_F","ItemMap","ItemCompass","ItemWatch","ItemRadio","ItemGPS","NVGogglesB_gry_F","Laserdesignator_02","B_Carryall_mcamo", "V_PlateCarrier2_rgr","U_BG_Guerilla1_1" ] I need this straight to list things in dialog listbox control Share this post Link to post Share on other sites
pierremgi 4850 Posted December 31, 2018 For vehicles. If you don't want to use texture and all animations, pylons..., just focus on containers thing. These codes are working for backpacks,crates contents in vehicles. Share this post Link to post Share on other sites
davidoss 552 Posted December 31, 2018 Yes i already use your script for vehicle loadouts, unfortunately it has here no reference. We knew how to export array from inventory . The problem is that it is an nested array and i need normal array. I tried to handle with but i failed on this (low knowledge) || (perception capabilities). Share this post Link to post Share on other sites
pierremgi 4850 Posted December 31, 2018 Well. Units and vehicles works differently. Roughly, you have cargo for vehicles and specific containers like uniform,vest... for units + weapons and assigned items. So, for units, you can add a variable like: _unit setVariable ["unitLdout",getUnitLoadout _unit]; // at the right time (at start, when killed...) Then a simple: _newUnit setUnitLoadout (_unit getVariable ["unitLdout",getUnitLoadout _newUnit]); // should do the trick on respawn or else. Note that the get/setUnitLoadout is smart enough to reload half-used magazines or not. For vehicles (cargo spaces): MGI_fnc_getVehicleLoadout = { _veh = param [0,objNull, [objNull]]; _veh setVariable ["MGIallCont",[]]; (_veh getVariable "MGIallCont") pushBack [_veh,itemCargo _veh,magazineCargo _veh,weaponCargo _veh,backpackCargo _veh]; {(_veh getVariable "MGIallCont") pushBack [_x select 0,itemCargo (_x select 1),magazineCargo (_x select 1),weaponCargo (_x select 1),[]]} forEach everyContainer _veh; }; _vehicle1 call MGI_fnc_getVehicleLoadout; MGI_fnc_setVehicleLoadout = { params [["_newVeh",objNull,[objNull]], ["_oldVeh",objNull,[objNull]]]; if ( {_x isKindOf "CAManBase"} count [_newVeh,_oldVeh] >0 or isnil {_oldVeh getVariable "MGIallCont"}) exitWith {}; { _x params ["_cont","_it","_mag","_wp",["_bpk",[]]]; if (_cont isEqualType "") then { _cont = everyContainer _newVeh select (_foreachindex -1) select 1 } else { _cont = _newVeh; }; clearItemCargoGlobal _cont; clearMagazineCargoGlobal _cont; clearWeaponCargoGlobal _cont; clearBackpackCargoGlobal _cont; {_cont addItemCargoGlobal [_x,1];true} count _it; {_cont addMagazineCargoGlobal [_x,1]; nil} count _mag; {_cont addWeaponCargoGlobal [_x,1]; nil} count _wp; {_cont addBackpackCargoGlobal [_x,1]; nil} count _bpk; } forEach (_oldVeh getVariable ["MGIallCont",[]]); }; [_newCar,_oldCar] call MGI_fnc_setVehicleLoadout; This way, you will find any uniform, vest, backpack put in cargo of a vehicle (_vehicle1 as reference, then _oldcar in 2nd script), with their own inventory, inside the second vehicle (_newCar). The former loadout of _newCar is cleared and replaced by the reference one. 1 Share this post Link to post Share on other sites
davidoss 552 Posted December 31, 2018 Sorry but we both are talking about something completely different. I do not want remove or add units inventory only iterate inventory items and store into normal not nested array in a way that every item will be listed event current magazine. No more no less. I have searched config for any function BIS or CBA that could help with but i found nothing useful. Anyway Happy New Year for all of you guys.!! 3 Share this post Link to post Share on other sites
davidoss 552 Posted January 1, 2019 Ok it almost break my mind but i sorted this out. Thanks for your suggestions. Here is this function if someone would need such thing: /* file: fnc_gearTosimpleArray Author: DaVidoSS Description: Unpacks associative multi-dimensional getUnitLoadout output to a single-dimensional array param: 0 - ARRAY Usage: _playerInvItems = getUnitLoadout player; _items = [_playerInvItems] call fnc_gearTosimpleArray; _items */ params [["_playerInvItems",[],[[]]]]; _playerInvItems params ["_rifle","_launcher","_pistol","_uniform","_vest","_backpack","_helmet","_goggles","_lWeapon", "_assignItems"]; private _items = []; { if !(_x isEqualTo []) then { _x params ["_weapon","_muzzle","_pointer","_scope","_mag","_mag2","_bipod"]; { if !(_x == "") then {_items pushBack _x}; } forEach [_weapon,_muzzle,_pointer,_scope,_bipod]; { if !(_x isEqualTo []) then {_items pushBack (_x # 0)}; } forEach [_mag,_mag2]; }; } forEach [_rifle,_launcher,_pistol,_lWeapon]; { if !(_x isEqualTo []) then { _x params ["_container", "_itemsinside"]; if !(_container == "") then { _items pushBack _container; { _array = _x; _array params ["_item","_itsCnt"]; if (_item isEqualType "") then { for "_i" from 1 to _itsCnt do { _items pushBack _item; }; } else { _array params ["_weaponArray","_weaponCnt"]; for "_i" from 1 to _weaponCnt do { _weaponArray params ["_weapon","_muzzle","_pointer","_scope","_mag","_mag2","_bipod"]; { if !(_x == "") then {_items pushBack _x}; } forEach [_weapon,_muzzle,_pointer,_scope,_bipod]; { if !(_x isEqualTo []) then {_items pushBack (_x # 0)}; } forEach [_mag,_mag2]; }; }; } forEach _itemsinside; }; }; } forEach [_uniform,_vest,_backpack]; {if !(_x == "") then {_items pushBack _x}} forEach [_helmet,_goggles]; {if !(_x == "") then {_items pushBack _x}} forEach _assignItems; (_items) 1 Share this post Link to post Share on other sites
davidoss 552 Posted January 2, 2019 Does this needs to be such complicated? I am now on scripting my dialog EH and with the flows this is getting bigger and bigger. There are moments i barely can fallow my code. Are this is always such complicated? Are there some schematics or ways how this can be done easily? Spoiler params ["_control","_index"]; #define IDD_TRADER_MENU 38475 #define IDC_SELECTED_ITEM_PRICE_BOX 1009 #define IDC_OVERALL_PRICE_BOX 1012 #define IDC_PLAYER_NAME_BOX 1013 #define IDC_PLAYER_VEHICLE_NAME_BOX 1014 #define IDC_PLAYER_MONEY_BOX 1016 #define IDC_TRADER_WEAPONS_LSTBOX 1500 #define IDC_TRADER_WEAPON_MAGAZINES_LSTBOX 1501 #define IDC_TRADER_WEAPON_ATACHMENTS_LSTBOX 1502 #define IDC_TRADER_EQUIPMENTS_LSTBOX 1503 #define IDC_PLAYER_VEHICLE_ITEMS_LSTBOX 1504 #define IDC_TRADER_TRADE_FIELD_LSTBOX 1505 #define IDC_PLAYER_INVENTORY_ITEMS_LSTBOX 1506 #define IDC_PLAYER_TRADE_FIELD_LSTBOX 1507 #define IDC_BUTTON_BUY_BTN 1600 #define IDC_BUTTON_SELL_BTN 1601 #define IDC_BUTTON_EXIT_BTN 1602 disableSerialization; private _array = _control getVariable ["stuff",[]]; if (_array isEqualTo []) exitWith {}; private _display = findDisplay IDD_TRADER_MENU; private _playerTradeCtrl = _display displayCtrl IDC_PLAYER_TRADE_FIELD_LSTBOX; private _traderTradeCtrl = _display displayCtrl IDC_TRADER_TRADE_FIELD_LSTBOX; private _overallPriceCtrl = _display displayCtrl IDC_OVERALL_PRICE_BOX; private _itemPriceCtrl = _display displayCtrl IDC_SELECTED_ITEM_PRICE_BOX; private _playerInventoryCtrl = _display displayCtrl IDC_PLAYER_INVENTORY_ITEMS_LSTBOX; private _playerVehicleInventoryCtrl = _display displayCtrl IDC_PLAYER_VEHICLE_ITEMS_LSTBOX; sleep 0.5;//wait for onLBSelChanged EH adds price just for sure private _currentSumm = call (compile (ctrlText _overallPriceCtrl)); private _itemPrice = call (compile (ctrlText _itemPriceCtrl)); if (_control isEqualTo _playerInventoryCtrl || _control isEqualTo _playerVehicleInventoryCtrl) then { if (_control isEqualTo _playerInventoryCtrl) then { // sell from player inv // add selected row to player trade lb , add _itemPrice to _overallPriceCtrl , remove index from player inventory control private _playerInvItems = _playerInventoryCtrl getVariable ["stuff",[]]; private _playerTradeFieldItems = _playerTradeCtrl getVariable ["stuff",[]]; if (_playerInvItems isEqualTo []) exitWith {}; private _selectedItem = _playerInvItems # _index; private _cfg = [_selectedItem] call fnc_getConfigPath; private _size = (lbSize _playerTradeCtrl); systemchat str (lbSize _playerTradeCtrl); _playerTradeCtrl lbAdd (getText (_cfg >> "displayName")); _playerTradeCtrl lbSetPicture [_size, getText (_cfg >> "picture")]; _playerTradeCtrl setVariable ["stuff",(_playerTradeFieldItems + [_selectedItem])]; private _price = _currentSumm + _itemPrice; _overallPriceCtrl ctrlSetText str _price; } else { // sell from player vehicle inv // add selected row to player trade lb , add _itemPrice to _overallPriceCtrl remove index from player vehicle inventory control }; } else { if (_control isEqualTo _playerTradeCtrl) exitWith { // remove selected row && set overall price - row price from player price array, add row to _playerInventoryCtrl or _playerVehicleInventoryCtrl (idk how to define where it was) }; if (_control isEqualTo _traderTradeCtrl) exitWith { // remove selected row + set overall price - row price from trader price array }; //buy // add selected row to trader trade lb , add price from trader price array to overall price control }; 1 Share this post Link to post Share on other sites
HazJ 1289 Posted January 2, 2019 Bigger is better... Share this post Link to post Share on other sites
davidoss 552 Posted January 3, 2019 Unfortunately, I'm going to abandon this. It's too complicated for me. I am unable to script this out. Couple days work for nothing. Sad, but true 1 Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted January 3, 2019 42 minutes ago, davidoss said: Unfortunately, I'm going to abandon this. It's too complicated for me. I am unable to script this out. Couple days work for nothing. Sad, but true What exactly are you trying to do? Hard to tell where you're having problems from your snippet above, besides odd if then checks... Cheers Share this post Link to post Share on other sites
davidoss 552 Posted January 3, 2019 The biggest problem is that i have no space in my mind for this I started this very quickly solved some problems and reach some point where i i have no idea what is where. Exactly i stacked on reverse stuff like this: player single click object in his inventory field - control "item price" displays clicked item price stored in [player trade array] -works player dbclick object in his inventory field. - control "item price" displays clicked item price stored in [player trade prices array] -works - removing item form inventory field -works - adding removed row to control "items to sell" -works - control "balance" displays its value + clicked item price stored in [player trade prices array] -works And now how to reverse things when player changes his mind and wants item back before push sell. I tried to update variables values containing items classes stored in controls namespaces but it has make a mess along indexes count after removelb and displays fake values Its really complicated i can barely explain this. I can link the files if you have mind space for this 1 Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted January 3, 2019 13 minutes ago, davidoss said: The biggest problem is that i have no space in my mind for this I started this very quickly solved some problems and reach some point where i i have no idea what is where. Exactly i stacked on reverse stuff like this: player single click object in his inventory field - control "item price" displays clicked item price stored in [player trade array] -works player dbclick object in his inventory field. - control "item price" displays clicked item price stored in [player trade prices array] -works - removing item form inventory field -works - adding removed row to control "items to sell" -works - control "balance" displays its value + clicked item price stored in [player trade prices array] -works And now how to reverse things when player changes his mind and wants item back before push sell. I tried to update variables values containing items classes stored in controls namespaces but it has make a mess along indexes count after removelb and displays fake values Its really complicated i can barely explain this. I can link the files if you have mind space for this Don't try to make everything with one function, make multiple functions that do one thing only. I guess you can also add custom eventhandlers to handle what you need. Cheers 1 Share this post Link to post Share on other sites
pierremgi 4850 Posted January 3, 2019 If you don't want to save each variable at each step, save all things (your variables for player and shop) when opening the shop. Create an undo button to recover this state. 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted January 3, 2019 3 hours ago, davidoss said: Unfortunately, I'm going to abandon this. Davidoss , you have done all this nice work ! It doesn't worth to leave it like this There is always something more to do ! 1 Share this post Link to post Share on other sites
davidoss 552 Posted January 3, 2019 Yes i just need to figure out any blueprint how to do this in easily way. Is there any way to create on-off switch button? 1 Share this post Link to post Share on other sites
HazJ 1289 Posted January 4, 2019 You can use RscButton or RscCheckbox and style them to your liking. Pretty simple stuff, not able to share anything as I am not at my man cave right now haha. Might share something on weekend. Don't give up on projects, trust me, you end up with drives and drives of ArmA stuff or is this just me lol? I still got stuff from A3 Alpha lmao. Scared to look at the code. 2 Share this post Link to post Share on other sites
davidoss 552 Posted January 5, 2019 Ok i have little progress on this. I can rollback things with prices/money keep arithmetic rules but only to one inventory control. I need to find a way to store information in which listbox item was before moved to "items to sell" control. After that i can move items to proper control after player want to revert his select and dbclicks in "items to sell" control. Any idea how to do this? 1 Share this post Link to post Share on other sites
Larrow 2820 Posted January 5, 2019 Are you using a listbox items lbValue for anything? If not when you double click an item from inventory/vehicle inventory, when you add it to the "Items to sell" listbox set its lbValue to the idc of the listbox it came from? Then the opposite when you DblClick an item in "Items to sell" get its lbValue (reference of listbox it came from, idc) and use this to place it back in the correct listbox. Does not necessarily need to be the lbValue you could always stringify the idc into lbData and parseNumber in reverse. OR if lbValue/lbData are already in use, make "items to sell" a LnB and use the lbValue/lbData of a hidden column for the reference. 1 1 Share this post Link to post Share on other sites
davidoss 552 Posted January 5, 2019 oh please yes yes.I am smart enough to only realise that this is exactly what i need. I am not using it because I had no idea about these command existence. How to use this please , like this? params ["_control","_index"]; #define IDD_TRADER_MENU 38475 #define IDC_PLAYER_INVENTORY_ITEMS_LSTBOX 1506 #define IDC_PLAYER_TRADE_FIELD_LSTBOX 1507 private _display = findDisplay IDD_TRADER_MENU; private _playerInventoryCtrl = _display displayCtrl IDC_PLAYER_INVENTORY_ITEMS_LSTBOX; private _playerTradeCtrl = _display displayCtrl IDC_PLAYER_TRADE_FIELD_LSTBOX; private _selectedItem = _playerInvItems deleteAt _index; private _cfg = [_selectedItem] call fnc_getConfigPath; private _size = (lbSize _playerTradeCtrl); _playerTradeCtrl lbAdd (getText (_cfg >> "displayName")); _playerTradeCtrl lbSetPicture [_size, getText (_cfg >> "picture")]; _playerTradeCtrl lbSetValue [_size,IDC_PLAYER_INVENTORY_ITEMS_LSTBOX]; 1 Share this post Link to post Share on other sites
davidoss 552 Posted January 5, 2019 Thank you @Larrow You are beautiful, you saved my brain. Share this post Link to post Share on other sites