Home   Help Search Login Register  

Author Topic: Moving weapon from vehicle to ammocrate  (Read 889 times)

0 Members and 1 Guest are viewing this topic.

Offline Andor14

  • Members
  • *
Moving weapon from vehicle to ammocrate
« on: 21 Nov 2010, 21:27:52 »
i want to know how to move all weapons and ammo in a vehicle to a ammocrate.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Moving weapon from vehicle to ammocrate
« Reply #1 on: 22 Nov 2010, 16:19:04 »
That would be by using getWeaponCargo and getMagazineCargo on the vehicle, and then addMagazineCargo and addWeaponCargo on the ammobox.

Hmm.  :dry: It seems that the commands removeMagazineCargo and removeWeaponCargo might not yet have been ported to Arma 2...however, since you want to move ALL the weapons/magazines, you can simply use clearWeaponCargo and clearMagazineCargo to get the job done!  :good:

Haven't use the commands myself, but it should be fairly simple. Make a script that looks something like this:

Code: [Select]
_truck = _this select 0;
_crate = _this select 1;

_ammo = getMagazineCargo _truck;
_weapons = getWeaponCargo _truck;

// Add magazines

for "_i" from 0 to (count ((_ammo select 0) - 1)) do
{
_magtype = ((_ammo select 0) select _i);
_magcount = ((_ammo select 1) select _i);
_crate addmagazinecargo [_magtype, _magcount];
};

// Add weapons

for "_i" from 0 to (count ((_weapons select 0) - 1)) do
{
_weaptype = ((_weapons select 0) select _i);
_weapcount = ((_weapons select 1) select _i);
_crate addweaponcargo [_weaptype, _weapcount];
};

clearMagazineCargo _truck;
clearWeaponCargo _truck;


Called [truckname, cratename] execvm "scriptname.sqf"

Should work, although untested :)

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"