FUNCTIONS FOR GETTING / SETTING VEHICLE LOADOUT
Hi all,
Here is a script for getting the loadout of any vehicle or crate (any container in fact) then transfer it on another vehicle or crate.
This works in SP or MP.
This functions work also for virtual arsenal, edited, or scripted with addAction command.
If any uniform, vest or backpack with their own custom loadout inside it, you'll recover the exact loadout for each one.
(I didn't push to keep the same ammo count on each mag...)
So, it's compatible and consistent with some automatic loaded backpacks, which will be loaded as you let them instead of their auto-default loadout.
NB1: The loadout of the receiving container will be replaced by the loadout you get.
NB2: see also the respawn vehicle script for integration of these two functions on respawning vehicles. (script to be issued soon).
parameters: one objet <vehicle or crate, preferable> applying to getVehicleLoadout,
two objects <new vehicle or crate, old vehicle or crate> applying to getVehicleLoadout
Limitations: The object you picked the loadout with getVehicleLoadout must not be deleted before you apply the setVehicleLoadout on another object.
Not tested, crates and vehicles overall load limitations, if any. I didn't see any of them so far.
Examples:
car1 call MGI_fnc_getVehicleLoadout; // you pick the current loadout of a vehicle;
cursorTarget call MGI_fnc_getVehicleLoadout; // if you're pointing at a backpack on ground, you pick its loadout
(must stay on cursorTarget for transferring the whole backpack in a named vehicle/crate);
[car2,crate1] call MGI_fnc_setVehicleLoadout; // you call the loadout of crate1, previously recorded with MGI_fnc_getVehicleLoadout;
The two objects must be present,
not applicable on player or infantry units (see BI commands getUnitLoadout / setUnitLoadout)
you apply the loadout of crate1 on car2, these two objects have now the same loadout.
[car2,cursorTarget] call MGI_fnc_setVehicleLoadout; // see above. If you are still on same cursorTarget, you pass the container to the new object
(so,new vehicle must be named for debug console usage).
Codes to be run anywhere you need it, locally, preferably on server.
MGI_fnc_getVehicleLdout
MGI_fnc_setVehicleLdout
EDITED