Tankbuster 1746 Posted January 28, 2015 Perhaps I was expecting to0 much, perhaps I'm misunderstanding what this does.... I've created a loadout and have saved it to uinamespace. That's fine - I can use bis_fnc_loadinventory to put that loadout back on the player. But what I can't do is check for the existence of a named loadout using getvariable? For example, [player, [uiNamespace, "test"]] call BIS_fnc_saveInventory; does save the loadout and can be recalled using fnc_loadinventory. But this returns nothing. uiNamespace getvariable "test" What I actually trying to do here is to test for the existence of a loadout in the uinamespace and if it exists, put it on the player. If it doesn't exist, I was planning to grab a default loadout from config and use that. So is getvariable the best way to test for the existence of a named loadout? Share this post Link to post Share on other sites
das attorney 858 Posted January 29, 2015 This is how the function saves your data, so you can use the var name to find it: _namespace setvariable ["bis_fnc_saveInventory_data",_data]; so do uiNamespace getVariable "bis_fnc_saveInventory_data"; Share this post Link to post Share on other sites
Tankbuster 1746 Posted January 29, 2015 Isn't that what I'm already doing? Share this post Link to post Share on other sites
das attorney 858 Posted January 29, 2015 Have you tried it? You said you were looking for "test", not "bis_fnc_saveInventory_data". Share this post Link to post Share on other sites
Tankbuster 1746 Posted January 29, 2015 I haven't tried it, I'll give it a go when I get home later. I just thought that the loadout name I provide to fnc_saveinventory would be the same name that I would put into getvariable to see the data again later. Share this post Link to post Share on other sites
Sniperwolf572 758 Posted January 29, 2015 (edited) I haven't tried it, I'll give it a go when I get home later. I just thought that the loadout name I provide to fnc_saveinventory would be the same name that I would put into getvariable to see the data again later. You need to look for the entry within the bis_fnc_saveInventory_data, as that is a big array containing all the loadouts. I'm not 100% sure what the structure of that array it is right now as I can't check right now, but I'm assuming is an array of pair entries so try accesing it like so. // uiNamespace since you're saving it there, profileNamespace usually for loadouts from Arsenal [ (uiNamespace getVariable "bis_fnc_saveInventory_data"), "test"] call BIS_fnc_getFromPairs; Edit: It should be, according to past me. :p Edited January 29, 2015 by Sniperwolf572 Share this post Link to post Share on other sites
Tankbuster 1746 Posted January 29, 2015 OK, I understand now. bis_fnc_inventory_data is the actual variable name I'm looking for. I'll make a biki update for this later. Apart from anything else, it'll save me asking the same question next year when I've forgotten the answer. It's worrying how many times I do a search for something not unlike this and find a thread started by me! :) Thanks SW and DA. Super helpful as always. :) Share this post Link to post Share on other sites
Larrow 2822 Posted January 29, 2015 You can find your saved loadout name via "test" in ( uiNamespace getvariable "bis_fnc_saveInventory_data" ) or ( uiNamespace getvariable "bis_fnc_saveInventory_data" ) find "test" > -1 Data is stored as KV pairs [ name, [array of loadout data], name, [array of loadout data]] [ loadout name, [ [ uniform, [ uniform items ] ], [ vest, [ vest items ] ], [ backpack, [ backpack items ] ], headgear, goggles, binocular, [ primaryWeapon, [ muzzle, IR, optic ], loaded magazine ], [ secondaryWeapon, [ muzzle, IR, optic ], loaded magazine ], [ handgun, [ muzzle, IR, optics ], loaded magazine ], [ Item#s NVGoggles ], [ ? ] ] ] 1 Share this post Link to post Share on other sites
Tankbuster 1746 Posted February 3, 2015 (edited) My method doesn't work for JIP. BIS_fnc_saveinventory, when saving to uiNamespace is empty when the player JIPs. Larrow very kindly wrote a script that saves and loads this data to the server. I had written something very similar writing to uiNamespace, but as I say above, it's not JIP safe. Writing it to the server means it won't be portable - it will only work on the server it ran on and will only be persistent for the life of the mission on the server. Or am I not reading right? If I save it to profileNamespace on the server, individualised by UID, will it survive mission/server app/box restarts? I could write it to profileNamespace, but then it appears in the VA load/save screen and that's scruffy looking. Ideally, I (think) I'm looking to save it to player so that it survives not only JIP, but mission and server restarts. Edited February 4, 2015 by Tankbuster Share this post Link to post Share on other sites
Larrow 2822 Posted February 4, 2015 If I save it to profileNamespace on the server, individualised by UID, will it survive mission/server app/box restarts? Saving it to any profileNamespace will survive permanently until the data is deleted and will survive both mission and client/server app/box restarts. Only thing with saving it to the server, as you mention, is that it is not portable and the inventory data will only be available on that server. To make it transferable you will need to save to the players profileNamespace. This has two downsides 1) It will appear in the VA 2) People can possibly change their loadout, which may require you to write code to make sure people are not giving themselves items you dont allow in your mission. The other option is to copy the BIS_fnc_saveInventory/loadInventory functions and supply your own variable name to save them under (bis_fnc_saveInventory_data). The information would still be changeable by the player but they would need to read your code or DeRap their Vars to work out where it is saved. Maybe even encode the saved information so it is not easily changeable. I suppose it all depends on your end goal and how safe the information needs to be. Share this post Link to post Share on other sites
Tankbuster 1746 Posted February 4, 2015 Thanks Larrow, you've been proper helpful. Security of the loadout is not a massive issue, I think. Although if I'm honest, I'd not considered that players might change their own loadout while it's in client profilenamespace. I'm whitelisting on the VA anyway so while they could increase the count of something they are allowed, they won't be able to grant themselves stuff that isn't whitelisted (load button will grey out). I *could* write code that transfers the loadout to server profilenamespace when the VA closes and retrieve it on JIP (that's pretty much what you sent me in PM, for which I'm grateful) but I'm in danger of getting bogged down in what is a minor feature in the mission. I think I'm going to go the slightly messy route of saving to client profileNamespace and name it such that the players won't delete it. Perhaps call it Dont-Delete. As ever it will get flagged for 'future improvement' in the development cycle and get done easter after next. :) Share this post Link to post Share on other sites