Jump to content
Ganvai84

Get Weight of Magazines in Scripts

Recommended Posts

Hey guys,

I want to load some ammo boxes automatically so they are still caryable with ACE. Is there a way to get the weight of the magazine?

I did it another way around, but god damn, this script is buggy as hell and doesn't work properly at all.

 

if (! isServer) exitWith {};

_box = _this select 0;

clearWeaponCargoGlobal _box; 
clearMagazineCargoGlobal _box;
clearItemCargoGlobal _box;
clearBackpackCargoGlobal _box;



while {_box call ace_dragging_fnc_getweight < 200 } do {
	_box addMagazineCargoGlobal [secondary_mag, 1];
};

while {_box call ace_dragging_fnc_getweight < 250 } do {
	_box addMagazineCargoGlobal [primary_mag, 1];
};


while {_box call ace_dragging_fnc_getweight < 475 } do {
	_box addMagazineCargoGlobal [dm_mags, 1];
};

while {_box call ace_dragging_fnc_getweight < 550 } do {
	_box addMagazineCargoGlobal [mg_mag, 1];
};

With this script is the problem, no matter what I do, the first item in the code will not be present in _box.

primary_mag, secondary_mag, dm_mags and mg_mag are public variables set on the initServer.sqf with the Class-Name String of the magazine.

I would like to find another alternative to fill the _box but right now, so I don't have to use "while" and rather calculate the amount of magazines I would want to put in. But for this, I would need to know the mass of the magazine. But here I hit a wall, with no idea how to get the mass of a magazine by just knowing its class name.

Thanks for any help.

Share this post


Link to post
Share on other sites
1 hour ago, Ganvai84 said:

But here I hit a wall, with no idea how to get the mass of a magazine by just knowing its class name.

I'm not familiar with the technical side of how ACE does its weight system but are you sure this isn't something you can get from config files? I notice that magazines have two sub-config entries for mass and weight, assuming mass is the correct value you need, then you should be able to use something like this to retrieve it:

_magMass = [configfile >> "CfgMagazines" >> (secondaryMag), "mass"] call BIS_fnc_returnConfigEntry;

From what i understand of the ACEfunction, its weight values are based on this number so you should be able to use this as a starting point at least.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks man, that was the starting point I needed. Will try it out.

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

×