Jump to content
Lucky44

Seeking help with BIS_fnc_removeVirtualItemCargo

Recommended Posts

I've been trying everything I can think of to make this work, and nothing seems to do anything. I've read this over and tried various approaches, but nothing is working to limit the objects from the crate.

 

I've tried putting the code in the init box of the crate (with the crate names VA1), like this:

handle = ["AmmoboxInit", [this,true,{true}]] spawn BIS_fnc_arsenal; 
[ VA1, ["launch_B_Titan_short_F", "launch_B_Titan_short_tna_F",  "launch_O_Titan_short_F", "launch_I_Titan_short_F","launch_I_Titan_short_ghex_F"] ] call BIS_fnc_removeVirtualItemCargo; 

And I've tried calling the code in other ways. 

 

Am I doing something wrong? Any suggestions??

Share this post


Link to post
Share on other sites

Have you tried to set the third parameter true, e.g, removing the items globally?
 

Quote


(Note: Only cargo specifically whitelisted can be removed via these commands e.g creating an arsenal container with a whitelist of true (<allowAll>) and then trying to remove "arifle_MX_ACO_pointer_F" will not work)

 

 

From: https://community.bistudio.com/wiki/Arsenal#Remove

Share this post


Link to post
Share on other sites

Thanks for your reply, R3vo. Are you saying that you need to first whitelist anything that you're going to blacklist? I looked at the link and I tried this:

 

EDIT: I changed the BIS_fnc_removeVirtualItemCargo to BIS_fnc_removeVirtualWeaponCargo, but that didn't change anything.

handle = ["AmmoboxInit", [this,true,{true}]] spawn BIS_fnc_arsenal;
[VA1, ["launch_B_Titan_short_F", "launch_B_Titan_short_tna_F",  "launch_O_Titan_short_F", "launch_I_Titan_short_F","launch_I_Titan_short_ghex_F"], true] call BIS_fnc_addVirtualWeaponCargo;
[VA1, ["launch_B_Titan_short_F", "launch_B_Titan_short_tna_F",  "launch_O_Titan_short_F", "launch_I_Titan_short_F","launch_I_Titan_short_ghex_F"] ] call BIS_fnc_removeVirtualWeaponCargo; 

But it didn't do anything. Am I missing something?

Share this post


Link to post
Share on other sites

Is anyone using BIS_fnc_removeVirtualWeaponCargo effectively? I'd love to be able to use it!

Share this post


Link to post
Share on other sites

No one uses this function to blacklist a few items on a VA crate?

Share this post


Link to post
Share on other sites

Sorry for the late reply. Here's a working example:


 

#define BOX Revo_ammo //Replace Revo_ammo with your variable name

private _launcherPool = ["launch_B_Titan_short_F", "launch_B_Titan_short_tna_F",  "launch_O_Titan_short_F", "launch_I_Titan_short_F","launch_I_Titan_short_ghex_F"];


["AmmoboxInit", [BOX]] spawn BIS_fnc_arsenal;//Create an empty Arsenal with only the items available the character carries


[BOX,_launcherPool] call BIS_fnc_addVirtualWeaponCargo;//Add the launchers from the launcher pool

sleep 5;

hint "Launchers removed!";

[BOX,_launcherPool - ["launch_B_Titan_short_F"]] call BIS_fnc_removeVirtualWeaponCargo;//Remove all launchers exept one after 5 seconds

 

 

 

Since adding all items manually is nearly impossible, here is a script to do that automatically. That way you start with a full Arsenal, but you can still remove certain items.  Doesn't work!

Spoiler



#define BOX Revo_ammo

//Create a full arsenal
["AmmoboxInit", [BOX,true]] spawn BIS_fnc_arsenal;
//Retrieve all items
private _magazines = BOX call BIS_fnc_getVirtualMagazineCargo;
private _weapons = BOX call BIS_fnc_getVirtualWeaponCargo;
private _items = BOX call BIS_fnc_getVirtualItemCargo;
private _backpacks = BOX call BIS_fnc_getVirtualBackpackCargo;
//Remove full arsenal
["AmmoboxExit",[BOX]] spawn BIS_fnc_arsenal;
sleep 2;
hint "New Arsenal created";
//Create new empty arsenal
["AmmoboxInit", [BOX]] spawn BIS_fnc_arsenal;
//Add all items
[BOX,_magazines] call BIS_fnc_addVirtualMagazineCargo;
[BOX,_weapons] call BIS_fnc_addVirtualWeaponCargo;
[BOX,_items] call BIS_fnc_addVirtualItemCargo;
[BOX,_backpacks] call BIS_fnc_addVirtualBackpackCargo;

/*The Arsenal can no be edited freely*/

[BOX,_backpacks] call BIS_fnc_removeVirtualBackpackCargo;

 

 

Edited by R3vo
second script doesn't work

Share this post


Link to post
Share on other sites

Thanks for the reply, Revo.

 

I tried this:

 

#define BOX VA1

//Create a full arsenal
["AmmoboxInit", [BOX,true]] spawn BIS_fnc_arsenal;
//Retrieve all items
private _magazines = BOX call BIS_fnc_getVirtualMagazineCargo;
private _weapons = BOX call BIS_fnc_getVirtualWeaponCargo;
private _items = BOX call BIS_fnc_getVirtualItemCargo;
private _backpacks = BOX call BIS_fnc_getVirtualBackpackCargo;
//Remove full arsenal
["AmmoboxExit",[BOX]] spawn BIS_fnc_arsenal;
sleep 2;
hint "New Arsenal created";
//Create new empty arsenal
["AmmoboxInit", [BOX]] spawn BIS_fnc_arsenal;
//Add all items
[BOX,_magazines] call BIS_fnc_addVirtualMagazineCargo;
[BOX,_weapons] call BIS_fnc_addVirtualWeaponCargo;
[BOX,_items] call BIS_fnc_addVirtualItemCargo;
[BOX,_backpacks] call BIS_fnc_addVirtualBackpackCargo;

/*The Arsenal can now be edited freely*/

[BOX,_backpacks] call BIS_fnc_removeVirtualBackpackCargo;

[BOX, ["launch_B_Titan_short_F", "launch_B_Titan_short_tna_F",  "launch_O_Titan_short_F", "launch_I_Titan_short_F","launch_I_Titan_short_ghex_F"] ] call BIS_fnc_removeVirtualWeaponCargo;

And it creates a VA crate, and then it removes the backpacks, but it won't remove the launchers. Any idea why that would be?

Share this post


Link to post
Share on other sites

That second script will do nothing R3vo other than to remove whole sections (backpacks as written). It still will not allow you to remove certain classes from the sections e.g remove a "arifle_MX_F" from weapons.

 

["AmmoboxInit", [BOX,true]] spawn BIS_fnc_arsenal;

AmmoboxInit runs all the addVirtual#Cargo functions with the parameters of [_box,true,true,false] being...

  • the container (_box) that the arsenal/cargo is to be placed on
  • True to add all classes which in fact only adds the String "%ALL", %ALL signifies that the arsenal is to use its internal whitelist to fill this section(magazines,weapons,items or backpacks)
  • True to add it globally on all clients
  • False to not add the arsenal action to the container(_box)

It then tells the server to add the container(BOX) to its list of arsenal boxes(missionnamespace "bis_fnc_arsenal_boxes") and PVs the list to all clients.

And then adds the arsenal action to the BOX on all clients.

 

If after this you were to check the variable("bis_addVirtualWeaponCargo_cargo") on the arsenal container(BOX) you would see that it holds [["%ALL"],["%ALL"],["%ALL"],["%ALL"]] so..

private _magazines = BOX call BIS_fnc_getVirtualMagazineCargo;
private _weapons = BOX call BIS_fnc_getVirtualWeaponCargo;
private _items = BOX call BIS_fnc_getVirtualItemCargo;
private _backpacks = BOX call BIS_fnc_getVirtualBackpackCargo;

These four variables will each now hold ["%ALL"]

 

["AmmoboxExit",[BOX]] spawn BIS_fnc_arsenal;

Does nothing other than to remove the container(BOX) from the servers list of arsenal boxes()

 

[BOX,_magazines] call BIS_fnc_addVirtualMagazineCargo;
[BOX,_weapons] call BIS_fnc_addVirtualWeaponCargo;
[BOX,_items] call BIS_fnc_addVirtualItemCargo;
[BOX,_backpacks] call BIS_fnc_addVirtualBackpackCargo;

Then adds "%ALL" back into each section of "bis_addVirtualWeaponCargo_cargo" essentially doing nothing as this is what they already hold.

 

[BOX,backpacks] call BIS_fnc_removeVirtualBackpackCargo;

Will remove the keyword "%ALL" from the backpacks sections leaving "bis_addVirtualWeaponCargo_cargo" looking like [["%ALL"],["%ALL"],["%ALL"],[]]

 

Trying to remove any particular item("arifle_MX_F") from there will still result in the item appearing in the arsenal as the item does not appear in the "bis_addVirtualWeaponCargo_cargo" sections, all they hold is the keyword "%ALL"or [] in the case of backpacks, and as previously stated you cannot remove an item that has not already been specifically added via the addVirtual#Cargo functions, which would insert the specific class name in one of "bis_addVirtualWeaponCargo_cargo" sections.e.g from scratch doing..

[ BOX, [ "arilfe_MX_F" ], false ] call BIS_fnc_addVirtualWeaponCargo;

Would leave the containers "bis_addVirtualWeaponCargo_cargo" variable looking like [[],["arilfe_MX_F"],[],[]].

From here you would be able to remove the item as it has specifically been added.

 

One possible solution is to manipulate the Arsenal internal whitelist. If you remove it from there it will not appear in the arsenal no matter what you do with the add/removeVirtual#Cargo.

If you preload the arsenal data first and manipulate this data (currently there is an error with the Arsenal that will cause preloading to throw an error, although it still works), this data is stored in the missionNamespace variable called "bis_fnc_arsenal_data" and is an array of arrays of..

PRIMARYWEAPON    0
SECONDARYWEAPON    1
HANDGUN            2
UNIFORM            3
VEST            4
BACKPACK        5
HEADGEAR        6
GOGGLES            7
NVGS            8
BINOCULARS        9
MAP                10
GPS                11
RADIO            12
COMPASS            13
WATCH            14
FACE            15
VOICE            16
INSIGNIA        17
ITEMOPTIC        18
ITEMACC            19
ITEMMUZZLE        20
CARGOMAG        21
CARGOTHROW        22
CARGOPUT        23
CARGOMISC        24
ITEMBIPOD        25
CARGOMAGALL        26

Some of these arrays maybe empty and items are only added to the Arsenal interface at run time when a specific left hand selection is used, e.g like when you pick a weapon only then is the optics section filled with compatible optics for the selected weapon, and they are only checked against missionNamespace and the containers "bis_addVirtualWeaponCargo_cargo" variable.

Anything removed from this data will not appear in the Arsenal, as this is what the arsenal checks against for any items you may have added using BIS_fnc_addVirtual#Cargo functions.

Using True for the arsenal "%ALL" just flags the arsenal to use everything from this internal whitelist.

 


[ "Preload" ] call BIS_fnc_arsenal;

_blacklistItems = [ "arifle_Katiba_F" ];

{
    _arsenalData = _x;
    {
        _blackItem = _x;
        if ( { _x == _blackItem }count _arsenalData > 0 ) then {
            _arsenalData = _arsenalData - [ _blackItem ];
        };
    }forEach _blacklistItems;
    BIS_fnc_arsenal_data set [ _forEachIndex, _arsenalData ];
}forEach bis_fnc_arsenal_data;

Running this at mission start will strip all items in _blacklistItems from the arsenals data and they will not appear in any arsenal (taking into consideration the caveat I mentioned above about run time items ), unless as per normal they are an item the unit is already carrying, which are automatically added when the Arsenal interface loads. Although it should be good for most things like uniform, vest, backpacks, pri sec and handgun weapons.

 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for that explanation, Larrow. I can't say that I understood it all. But I was able to get the bottom section of code to work, creating a blacklist of items that don't appear in the crate, while everything else does. I have one problem still, though: if an item (e.g., the compact titan launchers in my list above) is in the blacklist, it doesn't appear in the crate, but it will still get given to someone who has it in their saved loadouts. That's true even if they don't have one in their current inventory. I'm testing this on a MP server, by the way.

 

Any ideas how to prevent the blacklisted gear from showing up if it's someone's  saved loadouts?

 

Also, I assume that you do not find bis_fnc_removevirtualweaponcargo useful, correct?

Share this post


Link to post
Share on other sites
Quote

Also, I assume that you do not find bis_fnc_removevirtualweaponcargo useful, correct?

Its only useful if you want to remove stuff you have previously added, so is very situational.

 

Quote

Any ideas how to prevent the blacklisted gear from showing up if it's someone's  saved loadouts?

I wrote an example Here (see How about something like this link) that works off of the items whitelisted via the addVirtual#Cargo functions and will strip players when loading a previously saved loadout of any items that are not in the whitelist. Comes with a rudimentry UI to show the players what was not allowed and has been stripped.

Have a look bearing in mind its setup for addVirtual#Cargo whitelists and if it generally works for want you need I will have a think about a rewrite to be able to switch to the arsenals internal whitelist or strip items is they are in your blacklist array instead.

  • Like 1

Share this post


Link to post
Share on other sites

Yeah, I guess the problem is that I'm trying to create a Virtual Arsenal that has 99.9% of the possible items in it, including the mods my group uses. So I really only want to Blacklist a dozen or two things. So any approach where I have to whitelist everything I want to include is not going to work, it seems, right?

 

I looked at your linked scripts/functions. If I understand correctly, they require a whitelist. I can't do that by adding whole classes (like configFile >> "CfgWeapons"), can I?

 

I am just looking for a way to restrict 10-20 items from a VA crate w/o having to whitelist every single item that is acceptable. -You'd think that BIS would make such a method!!

Share this post


Link to post
Share on other sites

Thanks larrow for your explanation.

Share this post


Link to post
Share on other sites

@lucky44 make sure to check your PMs, I have forwarded you a quick rewrite of the script from the previously linked thread.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks a ton, Larrow. 

 

And so everyone knows: the BIS_fnc_removeVirtualItemCargo function only seems to work on items you have whitelisted already. That makes it useless for my purposes.

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

×