Page MenuHomeFeedback Tracker

Scripting Command: addMagazineCargoEx for Bullet Counts
Closed, ResolvedPublic

Description

Currently the scripting command addMagazineCargo only supports a number of magazines instead of a bullet count.

A scripting command in Arma 3 Similar to http://resources.bisimulations.com/wiki/addMagazineCargoEx would be nice.

So you can preform commands like...
(unitVest player) addMagazineCargoEx ["MagazineClassName","BulletCount"]
to add magazine with a certain bullet count.

You can add magazines with a bullet count with addMagazine (Array) however you cannot control where the magazine will end up, or add magazines with bullet count to storage objects.

Details

Legacy ID
2520607765
Severity
None
Resolution
Fixed
Reproducibility
N/A
Category
Scripting

Event Timeline

Deathlyrage edited Additional Information. (Show Details)
Deathlyrage set Category to Scripting.
Deathlyrage set Reproducibility to N/A.
Deathlyrage set Severity to None.
Deathlyrage set Resolution to Fixed.
Deathlyrage set Legacy ID to 2520607765.May 7 2016, 5:05 PM
Gav added a subscriber: Gav.May 7 2016, 5:05 PM
Gav added a comment.Nov 19 2013, 3:41 AM

Would be great to get any word on this. if it would be able to be added, helps with gear saving on missions / gamemodes

dubnium added a subscriber: dubnium.May 7 2016, 5:05 PM

It would help with several community driven mods. Mods that as everyone in the Arma community knows, keeps the community alive.

MrMeier added a subscriber: MrMeier.May 7 2016, 5:05 PM

Need this all the time!

Jimz00 added a subscriber: Jimz00.May 7 2016, 5:05 PM

Any news on this please?!

Please fix this! D:

This is a major game-breaking (no pun intended) problem for a cutting edge community developed mod and it is greatly disruptive that this small issue has not been fixed.

Is this going to get assigned?

FrankHH added a subscriber: FrankHH.May 7 2016, 5:05 PM

I would like to see this fixed so the modding community has more control over things like this.

matthew added a subscriber: matthew.May 7 2016, 5:05 PM

please add this ASAP

If anyone can handle this, I believe its japa!

Finally assigned :) hope it get's into the game soon!

Now now, hold your horses, there is no commitment from the developer yet. But I thought it would be a good idea to direct his attention to this ticket.

No I let them roam to stomp everyone who wants to revoke this issue :P

Would it be practical to perform a "Save Loadout" feature that stores the players current setup/equipment then run a script that performs an IFF function in relation to death?

Please fix this soon!

TWiG added a subscriber: TWiG.May 7 2016, 5:05 PM
TWiG added a comment.Dec 31 2013, 12:08 AM

big problem

I can easily call this problem "game-breaking" for some mods.
Please fix it asap.

Please fix this, I only really picked up ARMA3 for the online mods but this bug can be game breaking when your playing on hardcore survival mods where bullets are hard to come by.

Logout with 2 mags, login back in lost 1 mag:(, Play extra careful due to now low rounds, server resets and suddenly i am left defenseless with zero ammo!, Death shortly follows and frustration is all i have. NOT COOL please fix this ASAP

The most annoying bug the game has so far!
Need immediate fix!

Since when a request for a new scripting command became a bug that needs fixing???

coug added a subscriber: coug.May 7 2016, 5:05 PM
coug added a comment.Jan 5 2014, 6:00 PM

Big issue please fix soon!!

AlphaWolF:
Are your issue reproducible or it was a random bug with low repro rate?

Sorry for any confusion as this is not a bug directly related to the default game but rather the online mod I play (breaking point).

But yes the issue happens reproducible.

If the server resets or restarts, or I happen log out without first removing the ammo for my guns, it removes them from my inventory.
The only workaround is to first remove all ammo to my backpacks before logging out.

So currently I keep being left without any ammunition as it never saves the bullet count in the weapons.

Please help if you can as this is crucial to the modding community.

@AlphaWolF, tell them to use magazinesammofull command instead when reading your current inventory, other magazine commands do not return loaded magazines, this is probably why you lose them.

here ya go this will repack and compress all mags
_compressFirst =
{
_array = _this;
_fullmags = [];
_usedmags = [];
{

		_mag = _x select 0;
		_ammo = _x select 1;
		_loaded = _x select 2;
		_fullammo = getNumber(configFile>>"CfgMagazines">>_mag>>"count");
		if(_ammo == _fullammo)then
		{
			_fullmags set[count _fullmags,[_mag, _ammo]];
		}else{
			_usedmags set[count _usedmags,[_mag, _ammo]];
		};

}forEach _array;
_repacked = [];
_maglist = [];
{

		_mag = _x select 0;
		_ammo = _x select 1;
		if((_maglist find _mag) > -1)then
		{
			_curcount = (_repacked select (_maglist find _mag)) select 1;
			(_repacked select (_maglist find _mag)) set[1, _curcount + _ammo];
		}else{
			_maglist set[count _maglist, _mag];
			_repacked set[count _repacked, [_mag, _ammo]];
		};
		//diag_log _x;

}forEach _usedmags;
{

		_mag = _x select 0;
		_ammo = _x select 1;
		_fullammo = getNumber(configFile >> "CfgMagazines" >> _mag >> "count");
		_fullmagscount = 0;
		_cl = 0;
		_ammoOriginal = _ammo;
		for [{_i = 0},{_i <= _ammoOriginal},{_i = _i + 1}] do
		{
			if(_cl == _fullammo)then
			{
				_fullmagscount = _fullmagscount + 1;
				_ammo = _ammo - _fullammo;
				_cl = 0;
			};
			_cl = _cl + 1;
		};
		for [{_i = 0},{_i <= _fullmagscount},{_i = _i + 1}] do
		{
			_fullmags set[count _fullmags,[_mag, _fullammo]];
		};
		if(_ammo > 0)then
		{
			_fullmags set[count _fullmags,[_mag, _ammo]];
		};

}forEach _repacked;
_fullmags
};
_magazines = ((magazinesAmmoFull player) call _compressFirst);

vbawol added a subscriber: vbawol.May 7 2016, 5:05 PM
vbawol added a comment.Jan 9 2014, 9:38 PM

Up vote! addMagazineCargo and addMagazineCargoGlobal should be updated to support the same features that http://community.bistudio.com/wiki/addMagazine_array does.

<b>@armatech</b> : Here's something that is even more storage-efficient:

----------------------------------------

_getCompressedAmmo =
{
private ["_unit", "_mags", "_added", "_ammoCounts"];
_unit = _this;
_mags = [];

{

		_mag = _x select 0;
		_ammo = _x select 1;
		_added = false;
		
		{
			if (_x select 0 == _mag) exitWith
			{
				_ammoCounts = _x select 1;
				
				{
					if (_x select 0 == _ammo) exitWith
					{
						_x set [1, (_x select 1) + 1];
						_added = true;
					};
				} forEach _ammoCounts;
				
				if (!_added) then
				{
					_ammoCounts set [count _ammoCounts, [_ammo, 1]];
					_added = true;
				};
			};
		} forEach _mags;
		
		if (!_added) then
		{
			_mags set [count _mags, [_mag, [[_ammo, 1]]]];
		};

} forEach magazinesAmmoFull _unit;

_mags
};

_magazines = player call _getCompressedAmmo;

----------------------------------------

The returned array is in the following format:

[
[

		"Mag class",
		[
			[Ammo count, Number of mags],
			...
		]

],
...
]

Please...PLEASE...add these commands! I'm having to do a workaround at the moment to add magazines with specific ammo counts to specific containers (uniform/vest/backpack/etc) that is truly painful and makes me want to cry.

Here's a list of what I would like to have in terms of scripting commands for inventory management. Because I know that the developers have been laying in bed every night since release thinking to themselves "What would Outlawled do if he were a developer? Also, where did he get that jacket? That's a super nice jacket."

And, while I can't help you out with the jacket as I don't remember where I got it, here is the list of scripting commands I want (I've included some commands that are already in the game so that there is a complete list):

container <b>addMagazineCargo</b> [classname, magazineCount];
container <b>addItemCargo</b> [classname, itemCount];
container <b>addWeaponCargo</b> [classname, weaponCount];
container <b>addBackpackCargo</b> [classname, backpackCount];

container <b>addSingleMagazineCargo</b> [classname, bulletCount];
container <b>addSingleWeaponCargo</b> [classname, [attachments], [[magazineClassname1, bulletCount], [magazineClassname2, bulletCount]]];

_backpackContainerObject = container <b>addSingleBackpackCargo</b> classname; Returns the added backpack's corresponding container object.
_uniformOrVestContainerObject = container <b>addSingleItemCargo</b> classname;
Returns objNull or, if the added item is a uniform or vest and therefore has a corresponding container object, the container object will be returned.

<b>clearMagazineCargo</b> container;
<b>clearItemCargo</b> container;
<b>clearWeaponCargo</b> container;
<b>clearBackpackCargo</b> container;

container <b>removeSingleMagazineCargo</b> classname;
container <b>removeSingleItemCargo</b> classname;
container <b>removeSingleWeaponCargo</b> classname;
container <b>removeSingleBackpackCargo</b> classname;

container <b>removeSingleMagazineCargo</b> [classname, bulletCount];
container <b>removeSingleWeaponCargo</b> [classname, [attachments], [[magazineClassname1, bulletCount], [magazineClassname2, bulletCount]]];
container <b>removeSingleContainerCargo</b> containerObject; // "containerObject" referring to the container object that you want to remove from "container."

<b>getMagazineCargo</b> container;
<b>getItemCargo</b> container;
<b>getWeaponCargo</b> container;
<b>getBackpackCargo</b> container;

<b>getMagazineCargoDetail</b> container; returns all magazines and their current ammo counts in format [classname, bulletCount]
<b>getWeaponCargoDetail</b> container;
returns all weapons and their attachments, loaded magazines, and current ammo counts in format [classname, [attachments], [[magazineClassname1, bulletCount], [magazineClassname2, bulletCount]]]
<b>getContainerCargoDetail</b> container; // returns all uniforms, vests, and backpacks and their associated container objects in format [containerObject, itemClassname]

container <b>canAddMagazineToCargo</b> classname;
container <b>canAddItemToCargo</b> classname;
container <b>canAddWeaponToCargo</b> classname;
container <b>canAddBackpackToCargo</b> classname;

These, plus the appropriate global variants, are the only scripting commands I will ever need, and I want them. I want them so hard.

I don't care what you call them... <b>magazineCargoEx</b>, <b>singleMagazineCargo</b>, <b>outlawledIsAnIdiotMagazineCargo</b>, <b>outlawledLikesBoysMagazineCargo</b>.

Seriously. Call them whatever, just please put them in the game.

I will love you forever, Japa.

Yes, exactly Outlawled!

Here are my counter-suggestions to Outlawed's proposal:

-----

container <b>addMagazineCargo(Global)Ex</b> [type, ammo, quantity];

container <b>removeWeaponCargo(Global)</b> [type, quantity];
container <b>removeItemCargo(Global)</b> [type, quantity];
container <b>removeMagazineCargo(Global)</b> [type, quantity];
container <b>removeMagazineCargo(Global)Ex</b> [type, ammo, quantity];
container <b>removeBackpackCargo(Global)</b> backpackObject;

<b>getMagazineAmmoCargo</b> container; works like "magazinesAmmo", but for vehicle inventory cargo
<b>getWeaponItemsCargo</b> container;
works like "weaponsItems", but for vehicle inventory cargo

container <b>addWeaponItemsCargo(Global)</b>
[
weaponType,
muzzleItem,
railItem,
opticItem,
[

		magType1,
		magAmmo1

],
[

		magType2,
		magAmmo2

],
...
] // adds a cargo weapon with linked items and loaded mags, using an array in the style of a sub-array from "weaponsItems"

<b>canAddMagazineToCargo</b> container; // same as Outlawled
<b>canAddItemToCargo</b> container;
<b>canAddWeaponToCargo</b> container;

unit <b>loadMagazineInWeapon</b> [weapon, magazine, ammo]; // silently loads a magazine with specific ammo in a unit's primary/secondary/handgun weapon, in the first compatible muzzle, bypassing the inventory like "linkItem", without reload delay, overwriting the previous magazine if there was one

-----

The only remaining thing that I think would be missing afterwards is a "removeWeaponItemsCargo(Global)", although it would be a bit silly to make it use a sub-array from "weaponsItems" like above, and I'm not sure if such a command would actually be useful.

Well, let's say you have a container with two MXs: one with a silencer, ARCO, flashlight, and a full magazine, and the other has an ACO, laser pointer, and a half-empty magazine.

What if you want to only remove the gun with the laser pointer?

We need to be able to get a list of the unique items in a container and then remove any individual item we want.

This can be achieved via item IDs (e.g. removeItemCargoID), item indices (e.g. removeItemCargoIndex), or by describing all of that item's attributes that make it unique. For magazines, that would be the magazine type and its ammo count. For weapons, that's its type, attachments, magazines, and ammo counts.

I think Japa mentioned some problem with using item IDs at some point.

The problem with the second method is that you'd have to iterate through all the items inside a container to figure out which index the one you want to remove is.

The problem with the third is that it's maybe a bit messy with all those parameters.

I guess there should maybe also be a command for removing the first instance of a specified weapon type, regardless of attachments and all that other stuff.

There should probably also be a command like that for magazines. I'll add those to my first post.

All I know is that I would find the ability to remove a specific weapon incredibly useful.

Also, good call on the bold. Adding that to my first post, too.

Here's a discussion about ID-based commands: http://feedback.arma3.com/view.php?id=12782

About removing instances of weapons and magazines from cargo, I covered those in my previous note, look under addMagazineCargo.

This is the ID problem mentioned by japapatramtara: http://feedback.arma3.com/view.php?id=14576#c57396

My solution that that problem would be quite simple: make cargo containers work like a database table; in other words, have a global "ID" incremental variable for each container, and when an item is added either locally or globally to a global container, assign the ID from the variable to the item, and increment the container's ID variable across the network. That variable would be handled within the engine, and should not be modifiable via scripting.

If we have the ability to remove unique items (only a classname is needed), unique magazines (only a classname and an ammo count is needed), and unique weapons (a classname, a list of attachments, and a list of magazines and their ammo counts is needed), I don't see the need for item IDs.

Now, that is an <i>excellent</i> point you make there.

An additional function I forgot:

container <b>removeBackpackCargo(Global)</b> backpackObject;

Also, it would be great to make <b>addBackpackCargo(Global)</b> return the backpack container instead of nothing.

Oooh, yeah. Forgot about backpacks. I'll update my original post to include backpack commands.

Or maybe instead of backpacks, containers?

So uniforms, vests, and backpacks? Could that work? I know that uniforms and vests count as items in-game, and backpacks are their own separate thing.

But it would be incredibly useful to have a command that returned all the containers inside of another container so that we could get all of the items inside of a container inside of a container.

You know?

container <b>addContainerCargo</b> classname;

<b>getContainerCargo</b> container;

<b>clearContainerCargo</b> container;

container <b>removeSingleContainerCargo</b> classname;

container <b>removeSingleContainerCargo</b> [classname, [items], [magazines], [weapons], [containers]]; ????

Shit, this is starting to get more complicated.

Tip: don't add "Single" to your commands, instead add a "quantity" add the end of the array

The problem is, uniforms and vests are not containers themselves, but have a separate linked container; if you go in the editor and execute "systemChat typeOf uniformContainer player", you'll see the class returned is not the uniform, and is in fact located in CfgVehicles.

Uniforms and vests can already be added using addItemCargo, their containers are created automatically; what we need is a way to retrieve the containers, e.g. getUniformCargo & getVestCargo.

This command of yours:
"container removeSingleContainerCargo [type, [items], [magazines], [weapons], [containers]];"
is completely nuts.

The commands I would suggest are:

vehicle <b>addUniformCargo(Global)</b> [type, quantity]; same addItemCargo for uniforms, but returns container object
vehicle <b>addVestCargo(Global)</b> [type, quantity];
same addItemCargo for vests, but returns container object

<b>getUniformCargo</b> vehicle; return container objects associated with uniforms in vehicle cargo
<b>getVestCargo</b> vehicle;
return container objects associated with vests in vehicle cargo
<b>containerItem</b> container; // if container is linked to uniform or vest item, return the item classname, else empty string

vehicle <b>removeContainerCargo(Global)</b> containerObject; // delete a container from vehicle cargo, and its associated item when applicable

"removeItemCargo" could delete uniforms & vests by classname, and remove their associated container along the way.

Keep it simple and we MAY actually get it. Obviously there's an "ideal" set of commands but let's get the ones so some things aren't impossible. Like adding weapons/uniforms/vests/backpacks to containers with items/attachments/magazines etc, adding magazines with specific ammo counts to containers, etc.

Yeah honestly obtaining uniform and vest containers from vehicles serves little purpose, unless you want absolute perfect world persistence across server restarts, or sell vehicle contents for money in a mission or mod, or move items between vehicles.

Adding/getting magazine by ammo count is highest priority, then removing specific stuff from cargo, then adding/getting weapons with linked items and ammo

The reason I've been adding "single" to the commands is just to emphasize that the command only removes one. If you want to remove multiple, you can easily create your own function which runs the command in a loop.

Also, I'm only suggesting new functionality, I really don't care what the commands are called.

That being said, here are my suggestions for adding containers.

container <b>addSingleBackpackCargo</b> classname; Returns the added backpack's corresponding container object.
container <b>addSingleItemCargo</b> classname;
Returns objNull or, if the added item has a corresponding container object, that will be returned.

<b>getContainerCargoDetail</b> container; // returns all uniforms, vests, and backpacks and their associated container objects in format [containerObject, itemClassname]

container <b>removeSingleContainerCargo</b> containerObject; // This is wayyyyy better than my attempt to define a unique container as if it were a weapon with attachments. Haha.

Exactly, AgentRev, I agree. It's obviously useful and I'd love to have those commands at my disposal but there are commands that are much more useful and should be a higher priority.

Back to this issue, I think the question is, why has it been assigned for 3 months now, yet there is no sign of it being implemented? Since VBS2 already has it, I'm pretty sure it's nothing more than a copy-n-paste in engine code.

Well, either it's not actually that simple, or they're busy doing more important things.

Or they know about that time I stole $20 from my mom's purse when I was eight, and now they're giving me the punishment I deserved but never got.

The engine has the ability to add weapons/uniforms/etc to containers with items/attachments and magazines with ammo counts because you can do it through the inventory system. So it's certainly possible and already implemented, we simply need a command to be able to do it externally.

Quite frankly BIS's priorities are a little skewed. They're focusing on pointless modules/campaign episodes instead of working on what actually makes their game popular. Who plays the series for the campaign? Seriously. Whoever thought that was a good idea really should be looking for work.

They should be spending time adding comprehensive inventory commands, weather syncing, fixing severely broken actions, improving dedicated server efficiency, etc. Arma has two factors that make it popular and unique which are scale and its extensive modification focus. Two things BIS obviously aren't dedicating that much time to improving.

I say they need a dedicated group of employees to keep a regular look on more technical categories of the tracker, like Scripting, Engine, Config, Inventory, etc...

I mean, there are many, many issues in those categories that have not been marked as acknowledged or reviewed, which means to me they didn't even read them. At least, if they do read all of them, then it would be great if they would indicate they reviewed it.

Let's just hope that since the campaign is now done, the bug tracker might receive more attention.

That's the responsibility of the lead programmer at the end of the day.

To be honest I don't think them being marked as acknowledged or even assigned makes a big difference. Some reports have been marked as assigned since the alpha and are still not resolved and haven't even been worked on.

The project lead should be saying what are our assets and why are we popular and then focusing on those areas rather than saying let's focus on areas of the series that have never been popular. Arma is never going to have a better singleplayer than the AAA mainstream FPSs, they simply don't have the creativity or the resources. So why focus on it? There doesn't seem to be any direction for A3 at the moment. They launch a modification contest but don't actually listen to all the requests on the tracker for VITAL features/commands for the modification community. In my opinion someone who knows what they're doing needs to take command of the ship and actually lead.

We all live in hope :p.

Can we PLEASE have this? PLEASE japapatramtara! Not being able to add magazines with specific ammo counts to containers is really ridiculous and such a simple addition for you guys to make! I'm certain it would be really, really useful to a lot of developers!

Plus, I know it's unlikely but...any chance of removePrimaryWeaponMagazine and addPrimaryWeaponMagazine ["classname",ammo count]...obviously for handgun as well...

Another thing that would be really useful because at the moment there's absolutely no way to do this as far as I can see...? Unless you can access player weapon containers (unlikely).

I just thought I'd keep this near the top of the list as much as I possibly can...only over 400 people want it implemented for A3 (so it shouldn't be a high priority)...

container addMagazineCargo ["Classname",Quantity,AmmoCount];
container addMagazineCargoGlobal ["Classname",Quantity,AmmoCount];

removePrimaryWeaponMagazine player;
player addPrimaryWeaponMagazine ["Classname",AmmoCount]

removeHandgunMagazine player;
player addHandgunMagazine ["Classname",AmmoCount]

I'll settle for these please, I'm recreating the A3 inventory system so these are really important and otherwise impossible...

removePrimaryWeaponMagazine player;
player addPrimaryWeaponMagazine ["Classname",AmmoCount];

removeHandgunMagazine player;
player addHandgunMagazine ["Classname",AmmoCount]

tyl3r99 added a subscriber: tyl3r99.May 7 2016, 5:05 PM

upvoted as my vote will make the difference ;)

Come on, Can we at least get two scripting commands added to support ammo count for addMagazineCargo and getMagazineCargo?

curious how this has so many upvotes yet no resolution.

@realmeatshield The great grandmaster japa is busy with other, more pressing things? :)

new scripting command AddMagazineAmmoCargo has been added since DEV. build 127020.

Syntax:

AddMagazineAmmoCargo [magazineName, magsCount, bulletsCount]

Note: works like (global) versions of commands hence we won't support non-global versions of commands anymore

Thank you grandmaster japa, you da best :)

Marking resolved thus.

Gav added a comment.Sep 3 2014, 1:31 AM

woohoooooooooooooo

maybe someone could picks other commands mentioned in this task and split them into their own tickets.. and of course.. assign all of them to me

There ya go japa, separated two groups of scripting commands into new reports.

0020582: Scripting Command to addMagazine directly to weapon with bullet count.
http://feedback.arma3.com/view.php?id=20582

0020584: Scripting Command to add a Weapon to a container with related data
http://feedback.arma3.com/view.php?id=20584