OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: Andor14 on 21 Nov 2010, 21:27:52

Title: Moving weapon from vehicle to ammocrate
Post by: Andor14 on 21 Nov 2010, 21:27:52
i want to know how to move all weapons and ammo in a vehicle to a ammocrate.
Title: Re: Moving weapon from vehicle to ammocrate
Post by: Wolfrug on 22 Nov 2010, 16:19:04
That would be by using getWeaponCargo (http://www.ofpec.com/COMREF/index.php?action=details&id=1344&game=All) and getMagazineCargo (http://www.ofpec.com/COMREF/index.php?action=details&id=1345&game=All) on the vehicle, and then addMagazineCargo (http://www.ofpec.com/COMREF/index.php?action=details&id=9&game=All) and addWeaponCargo (http://www.ofpec.com/COMREF/index.php?action=details&id=14&game=All) on the ammobox.

Hmm.  :dry: It seems that the commands removeMagazineCargo (http://community.bistudio.com/wiki/removeMagazineEx_%28VBS2%29) and removeWeaponCargo (http://community.bistudio.com/wiki/removeWeaponCargo_%28VBS2%29) might not yet have been ported to Arma 2...however, since you want to move ALL the weapons/magazines, you can simply use clearWeaponCargo (http://www.ofpec.com/COMREF/index.php?action=details&id=63&game=All) and clearMagazineCargo (http://www.ofpec.com/COMREF/index.php?action=details&id=61&game=All) 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.