ALiVEOS / ALiVE.OS

ALiVE Open Source GPL v2
http://alivemod.com/
Other
157 stars 80 forks source link

Player Combat Logistics - modified ammo boxes #318

Open SavageCDN opened 7 years ago

SavageCDN commented 7 years ago

Running on dedicated server:

One Box_NATO_Ammo_F begins the mission at my base (was placed in the editor) and then I requested another one via Combat Logistics (Helo, Airdrop or Convoy). The Box_NATO_Ammo_F that was placed on the map in the editor has the custom item in it but the Box_NATO_Ammo_F that came in by Combat Logistics has the default items (Same thing happens if I use Zues to drop one into the mission also, it has all the default items).

When testing thru the Editor/Single player everything works, both boxes contain just the custom item.

See this forum thread for more info and script used to customize crates: http://alivemod.com/forum/2062-modify-ammo-supply-crates

Repro mission attached @CBA @ALiVE

ammocrate.Stratis.pbo.zip

Whigital commented 6 years ago

Dont think this is an ALiVE issue, but general init order issue.

Ran the supplied repro mission and indeed the delivered box had default items. Optimized the used scripts and XEH a bit and got desired result.

description.ext

class Extended_Init_EventHandlers {
    class Box_NATO_Ammo_F { 
         initServer = "(_this select 0) call (compile preprocessFileLineNumbers 'scripts\ammo.sqf')";
    };
};

ammo.sqf

params [
    ["_crate", objNull]
];

if !(isServer) exitWith {};

if (isNull _crate) exitWith {diag_log "ammo.sqf :: input is objNull"};

_crate allowDamage false;

clearWeaponCargoGlobal _crate;
clearMagazineCargoGlobal _crate;
clearItemCargoGlobal _crate;
clearBackpackCargoGlobal _crate;
_crate addMagazineCargoGlobal ["30Rnd_65x39_caseless_mag", 20];