Jump to content
Sign in to follow this  
wiggum2

addBackpackCargoGlobal broken ?

Recommended Posts

This is the script i use to fill ammoboxes in my MP misions.

// ammobox.sqf

if (!isServer) exitwith {};

private ["_muzzles","_mags","_muzzle","_ammo","_hit","_wHits","_weaponsList","_namelist","_wCName","_wDName","_wModel","_wType","_wscope","_wPic","_wDesc","_isFake","_weapon","_magazinesList","_mCName","_mDName","_mModel","_mType","_mscope","_mPic","_mDesc","_magazine","_wepcount","_magcount","_cfgweapons","_cfgmagazines","_backpack","_backpackcount","_backpackList"];

_wepcount = 10;
_magcount = 30;
_backpackcount = 4;

clearWeaponCargoGlobal _this;
clearMagazineCargoGlobal _this;

_weaponsList = [];
_namelist = [];
_cfgweapons = configFile >> "cfgWeapons";
for "_i" from 0 to (count _cfgweapons)-1 do {
_weapon = _cfgweapons select _i;
if (isClass _weapon) then {
	_wCName = configName(_weapon);
	_wDName = getText(configFile >> "cfgWeapons" >> _wCName >> "displayName");
	_wModel = getText(configFile >> "cfgWeapons" >> _wCName >> "model");
	_wType = getNumber(configFile >> "cfgWeapons" >> _wCName >> "type");
	_wscope = getNumber(configFile >> "cfgWeapons" >> _wCName >> "scope");
	_wPic =  getText(configFile >> "cfgWeapons" >> _wCName >> "picture");
	_wDesc = getText(configFile >> "cfgWeapons" >> _wCName >> "Library" >> "libTextDesc");	

	_isFake = false;
	_wHits=0;
	_mags=[];
	_muzzles = getArray(configfile >> "cfgWeapons" >> _wCName >> "muzzles");
	if ((_muzzles select 0)=="this") then {
		_muzzles=[_wCName];
		_mags = getArray(configfile >> "cfgWeapons" >> _wCName >> "magazines");
	} else {
		{
			_muzzle=_x;
			_mags = getArray(configfile >> "cfgWeapons" >> _wCName >> _muzzle >> "magazines");
		}forEach _muzzles;
	};
	{
		_ammo = getText(configfile >> "cfgMagazines" >> _x >> "ammo");
		_hit = getNumber(configfile >> "cfgAmmo" >> _ammo >> "hit");
		_wHits = _wHits + _hit;
	}forEach _mags;

	if ((_wCName!="") && (_wDName!="") && (_wModel!="") && (_wPic!="")) then {
		if !(_wDName in _namelist) then {
			_weaponsList = _weaponsList + [[_wCName,_wDName,_wPic,_wDesc]];
				_namelist = _namelist + [_wDName];
		};
	};
};
if (_i % 10==0) then {
	hintsilent format["Loading Weapons List... (%1)",count _weaponsList];
	sleep .0001;
};
};
hint "";
_namelist=nil;

_magazinesList = [];
_namelist = [];
_cfgmagazines = configFile >> "cfgmagazines";
for "_i" from 0 to (count _cfgmagazines)-1 do {
_magazine = _cfgmagazines select _i;
if (isClass _magazine) then {
	_mCName = configName(_magazine);
	_mDName = getText(configFile >> "cfgmagazines" >> _mCName >> "displayName");
	_mModel = getText(configFile >> "cfgmagazines" >> _mCName >> "model");
	_mType = getNumber(configFile >> "cfgmagazines" >> _mCName >> "type");
	_mscope = getNumber(configFile >> "cfgmagazines" >> _mCName >> "scope");
	_mPic =  getText(configFile >> "cfgmagazines" >> _mCName >> "picture");
	_mDesc = getText(configFile >> "cfgmagazines" >> _mCName >> "Library" >> "libTextDesc");	

	if ((_mCName!="") && (_mDName!="") && (_mModel!="")) then {
		if !(_mDName in _namelist) then {
			_magazinesList = _magazinesList + [[_mCName,_mDName,_mPic,_mDesc]];
				_namelist = _namelist + [_mDName];
		};
	};
};
if (_i % 10==0) then {
	hintsilent format["Loading magazines List... (%1)",count _magazinesList];
	sleep .0001;
};
};
hint "";
_namelist=nil;

sleep 0.1;
_backpackList = ["US_Assault_Pack_EP1","US_Patrol_Pack_EP1","US_Backpack_EP1","BAF_AssaultPack_MGAmmo","BAF_AssaultPack_RifleAmmo","BAF_AssaultPack_special","BAF_AssaultPack_ATAmmo","CZ_Backpack_EP1","CZ_VestPouch_EP1","TK_ALICE_Pack_EP1","TK_Assault_Pack_EP1"];
sleep 0.1;

if (alive _this) then {
   clearWeaponCargoGlobal _this;
   clearMagazineCargoGlobal _this;

   for "_i" from 0 to (count _weaponsList)-1 do {
       _weapon = _weaponsList select _i;
       if !(_weapon select 0 in ["CDF_dogtags","Cobalt_File","EvDogTags","EvKobalt","EvMap","EvMoney","EvMoscow","EvPhoto","Kostey_map_case","Kostey_notebook","Kostey_photos","Moscow_Bombing_File","PMC_documents"]) then {
           _this addWeaponCargoGlobal [_weapon select 0,_wepcount];
       };
   };

   for "_i" from 0 to (count _magazinesList)-1 do {
       _magazine = _magazinesList select _i;
       _this addMagazineCargoGlobal [_magazine select 0,_magcount];
   };

       for "_i" from 0 to (count _backpackList)-1 do {
       _backpack = _backpackList select _i;
        _this addBackpackCargoGlobal [_backpack,_backpackcount];
   };

};

But addBackpackCargoGlobal seems broken...

If i use:

_this addBackpackCargo [_backpack,_backpackcount];

It works and all backpacks are inside the ammobox.

But with:

_this addBackpackCargoGlobal [_backpack,_backpackcount];

Only one backpack is inside the box and all other lie right next to the box on the ground...:oh:

Any idea what is wrong with this ?

Share this post


Link to post
Share on other sites

The addxxxxxxCargoGlobal commands have always taking the constraints of the object you're trying to add the thing into consideration, most objects like ammo boxes and vehicles can only contain 2 backpacks.

Share this post


Link to post
Share on other sites

Sounds like the local addBackpackCargo is not using the defined limit set in the config while the global one is applying it.

For instance, the US Basic ammo crate can handle:

1 Backpack

5000 Weapons

20000 Magazines

If you want to know the limit of the vehicles/crates/backpack you can use the following commands:

//--- Assuming that _this is an object
diag_log getNumber(configFile >> 'CfgVehicles' >> typeOf _this >> "transportMaxBackpacks");
diag_log getNumber(configFile >> 'CfgVehicles' >> typeOf _this >> "transportMaxMagazines");
diag_log getNumber(configFile >> 'CfgVehicles' >> typeOf _this >> "transportMaxWeapons");

It might be an engine "bug", the others local commands (addMagazineCargo & addWeaponCargo) never go above their respective limit.

Share this post


Link to post
Share on other sites

Sorry, but if this is the truth its totally stupid !

Only 1 Backpack but 5000 Weapons...FPDR

Thats a really odd box !

Is there any box with unlimited space ?

Share this post


Link to post
Share on other sites

From what i see in the config of weapons_e\AmmoBoxes\config.cpp, all the boxes have the same value, it might be an idea to have a CIT ticket in order to increase the max backpack capacity of the ammocrates ? 1 is indeed very low.

Share this post


Link to post
Share on other sites

Ok, will do that.

But for myscript, i think i should use a isServer check for the addWeapons and addMagazine stuff so only Weapons the server has will be added to the box and not some mod stuff a client maybe has.

Then i could use "addBackpackCargo" for every client, no problem i think...

Share this post


Link to post
Share on other sites
Ok, will do that.

But for myscript, i think i should use a isServer check for the addWeapons and addMagazine stuff so only Weapons the server has will be added to the box and not some mod stuff a client maybe has.

Then i could use "addBackpackCargo" for every client, no problem i think...

Yep, in the meanwhile an isServer and local player check shall do the job.

Gl with the rest :)

Share this post


Link to post
Share on other sites

If they fix this with the next patch they need to change the "transportMaxBackpacks" for the ammunition box to 100 or something.

Or just give us a "magic" box with unlimited space for everything !

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
Sign in to follow this  

×