Jump to content
Domkrat

"canAdd" command doesn't work properly

Recommended Posts

This command doesn't work with any weapon, and if you try to use it by this way, it will show an error message "Bad vehicle type".

For example try it in console:

player canAdd "hgun_P07_F";

I wonder why this command works like that.

Also removeWeapon command doesn't work for weapon which is in inventory, but not assigned.

I'll be glad, if somebody could make a ticket on Bug Tracker, because i have some problems with registration so i can't do it.

Share this post


Link to post
Share on other sites

Possible Answers:

* The canAdd command was designed for items prior to the inventory system overhaul.

* The canAdd command only works for specific items or inventory area's (try smoke grenades in backpack)

* The canAdd command is simply a work in progress. They will fix it at some point :)

Maybe in the meantime you can script a temporary workaround. This could be a starting point:

if(primaryWeapon player != "") then {hint "You cannot add a weapon"};

Share this post


Link to post
Share on other sites

Thanks for replies.

I think it would be logical if BIS adds a command like that, but for weapon, since there is a possibility to store weapons in inventory.

The only way you can check it now is by following Kushluk's method.

Is there a way to get object's max capacity from config?

And what about removeWeapon? Just need to wait until they fix it?

Share this post


Link to post
Share on other sites
_backpackCapacity = getnumber (configfile >> "CfgVehicles" >> (backpack player) >> "maximumLoad");
_currentBackpackLoad = loadBackpack player;
_currentBackpackSpace = _backpackCapacity - (_currentBackpackLoad * _backpackCapacity);
_primaryWeaponWeight = getnumber (configfile >> "CfgWeapons" >> (primaryWeapon player) >> "WeaponSlotsInfo" >> "mass");

if (_currentBackpackSpace < _primaryWeaponWeight) then { hint "You do not have enough space to place the weapon in your backpack.";};

Gives you some idea about what you can pull from the configs.

Share this post


Link to post
Share on other sites

Larrow, we know about that, but is there a way to get maximumLoad of uniform?

Mariodu62, unassigned weapon counts as item too. Proof: put a weapon in your inventory and execute this code in console:

items player;

Share this post


Link to post
Share on other sites
Larrow, we know about that, but is there a way to get maximumLoad of uniform?
Yes.

If you know about those then maximumload for loadable items involves one more step, ill give you 2 hints "ItemInfo" and "containerClass".

Share this post


Link to post
Share on other sites

I got to admit, that they made it really messed up. Thanks

Share this post


Link to post
Share on other sites
I got to admit, that they made it really messed up. Thanks

Things do seem a little crowbarred in in places,

.. I need an Uniform.. ok you will find that under weapons ... WAT and yes it has a firerate and a optics zoom level ... WAT .. It has a carrying capacity but this is tied to a vehicle class

.. I need a backpack.. erm you will find that under vehicles ... WAT

Would of been nice if they had diverged the classes a little and made a CFGItem's maybe. The whole thing still needs some coherence to it, the whole debacle with weapons for example, removeWeapon only takes it if its in one of your weapon slots, removeItem doesnt remove weapons from a uniform/backpack yet removeAllItems does!! Items also lists weapons magazines etc

I was experimenting with your problem above about removing the weapon, you can list all items of say the backpack, remove them all, remove the reference to the weapon, then foreach the list and add them back in but, items need to be added with item, mags/grenades with magazine. It all becomes a little messy.

/rant hey its my birthday im allowed a little rant.

Share this post


Link to post
Share on other sites

We had lot of ideas like yours, but if you follow my signature you'll see, that we are trying to make the best optimization :).

Removing and adding thinks back takes too much traffic.

So i guess i'll just wait until they fix removeWeapon and other commands.

It's ok that backpacks are under CfgVehicles, because they are object unlike weapons and gear, but vests and uniform under... WAT:)

Also mass for items and gear is in ItemInfo, but weapon's mass is in WeaponSlotsInfo, so you got to make 2 types of getting mass and sort it. Thats weird...

PS

HB to you, man.:D

Edited by Domkrat

Share this post


Link to post
Share on other sites

I don't think they'll be "fixing" removeWeapon since it's not broken. removeWeapon removes a weapon from the player. It's not intended to remove a itemized weapon from a container.

If anything they need to add a removeItemWeapon command or something similar or allow removeItem to work on "weapons" which are currently items in a container.

Share this post


Link to post
Share on other sites
If anything they need to add a removeItemWeapon command or something similar or allow removeItem to work on "weapons" which are currently items in a container.
LOL

Sorry not laughing at you Kylania but NO ... arggghhh not another command.

What would of been wrong with say container addCargo [thing, amount] and then the engine sorts out anything special the engine needs doing for that particular thing.

Then give us a complementary command like getCargo [container, type(opt)] abit like the near commands. All happy and sorted no need for the 101 commands and i can get to what i need easily. Shit you could even add an extra param of true/false for global to both those and get rid of all the global commands aswell.

container:- vehicles, uniform, vest, backpack, crates etc

thing:- magazines, weapons, items etc

Hey ive only been scripting for the ARMA engine since march so if anything im saying sounds wrong and im missing a point here speak up im all for hearing other opinions.

I understand Legacy but all systems have to get their users to start using new commands at some point , start pointing them away from deprecated commands, stop adding more and more commands that just make things harder for me as a user and i would presume as a developer aswell to keep track of.

I mean even if a dev reads this, whats different on the back end say between addMagazineCargo and addItemCargo that would prevent an internal all encompassing command?

Now i really am being a grumpy old ranting BDay boy :D Ah roll on tomorrow.

Share this post


Link to post
Share on other sites

Can i get the current load of a box? Seens all functions to check load only works to check player load or uniform, vest and backpack load, accordingly to the WIKI.

Share this post


Link to post
Share on other sites

AFAIK, you need to run a few commands to get everything.

getItemCargo

getWeaponCargo

getMagazineCargo

 

These will return object types with quantities in a following subarray.

[["optic_ACO_grn_smg","U_C_IDAP_Man_Jeans_F","V_PlateCarrier1_blk","H_HelmetSpecO_ocamo","NVGoggles_OPFOR","FirstAidKit"],[1,1,1,1,1,1],
["SMG_03_black","launch_O_Vorona_brown_F","hgun_Pistol_heavy_01_green_F","Binocular"],[1,1,1,1],
["9Rnd_45ACP_Mag","30Rnd_65x39_caseless_mag","MRAWS_HEAT_F","APERSBoundingMine_Range_Mag"],[2,2,2,3]]

 

If you just want a plain list of all items in a container (e.g. 12 identical magazines will be listed as 12 objects), you can use the "non-get" versions of those commands:

itemCargo

weaponCargo

magazineCargo

 

["optic_ACO_grn_smg",
"U_C_IDAP_Man_Jeans_F",
"V_PlateCarrier1_blk",
"H_HelmetSpecO_ocamo",
"NVGoggles_OPFOR",
"FirstAidKit",
"SMG_03_black",
"launch_O_Vorona_brown_F",
"hgun_Pistol_heavy_01_green_F",
"Binocular",
"9Rnd_45ACP_Mag","9Rnd_45ACP_Mag",
"30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag",
"MRAWS_HEAT_F","MRAWS_HEAT_F",
"APERSBoundingMine_Range_Mag","APERSBoundingMine_Range_Mag","APERSBoundingMine_Range_Mag"]
  • Like 1

Share this post


Link to post
Share on other sites
On 9/5/2013 at 9:47 AM, Larrow said:

I mean even if a dev reads this, whats different on the back end say between addMagazineCargo and addItemCargo that would prevent an internal all encompassing command?

 

 

At least, a minus count on addAnyCommand for items, mags and weapons could be smart:

_truck addMagazineCargo ["M16", -5];

Same for the whole family of these commands.

(with a limit to 0, if that worth to be precised).

Share this post


Link to post
Share on other sites
Just now, pierremgi said:

 

At least, a minus count on addAnyCommand for items, mags and weapons could be smart:

_truck addMagazineCargo ["M16", -5];

Same for the whole family of these commands.

(with a limit to 0, if that worth to be precised).

 

It has been over six years, I wouldn't hold my breath 😉

 

Share this post


Link to post
Share on other sites

Thanks a lot Harzach.

 

I was looking for a function do apply to boxes that does the same the function loadBackpack does for backpacks.

https://community.bistudio.com/wiki/loadBackpack

"Returns current percentage of mass from items stored in a backpack relative to the maximum capacity of the backpack."

It returns a percentage: 0% is completely empty and 100% is completely filled.

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Ahh, OK. Yeah, there is no simple way to get that info that I am aware of. Here's a non-simple way I just hacked together:

 

_obj = cursorTarget; 
 
_name = typeOf _obj; 
_cap = getNumber (configFile >> "CfgVehicles" >> _name >> "maximumLoad"); 
_items = []; 
_weaps = []; 
_mags = []; 
_load = 0; 
 
_items = itemCargo _obj; 
_weaps = weaponCargo _obj; 
_weaps append _items;
_mags = magazineCargo _obj; 
 
{ 
    _mass = getNumber (configfile >> "CfgWeapons" >> _x >> "WeaponSlotsInfo" >> "mass"); 
 _load = _load + _mass; 
} forEach _weaps; 
 
{ 
    _mass = getNumber (configfile >> "CfgMagazines" >> _x >> "mass"); 
 _load = _load + _mass; 
} forEach _mags; 

_total = (_load / _cap) * 100;

systemChat str _total;

This is just test code for use in the debug window. You can get _obj however suits you best.
Again, it's hacked together, I'm sure there is a more elegant way to do this.
*edit* - Also, I think this will ignore any items inside containers inside the target container, i.e. items inside a backpack inside a crate. It can be done, I just didn't account for it. Not sure how that would impact the actual percentage, however, as "mass" is actually an abstraction of mass and volume. Blerg.

  • Like 1

Share this post


Link to post
Share on other sites

Harzach, seens a lot complicated to do something fully functional, but your code is a great start in that way, thanks.

Share this post


Link to post
Share on other sites

With Arma, sometimes things just aren't as easy as you'd think they would be. Good luck!

 

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

×