OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started 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.
-
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:
_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.