Changed cargo initVehicle to event driven, Added listenable event cargo_itemAdded

This commit is contained in:
jonpas 2015-08-18 23:59:01 +02:00
parent 4c86db9505
commit 583682396f
2 changed files with 7 additions and 2 deletions

View File

@ -27,7 +27,12 @@ _position set [2, (_position select 2) + 7.5];
for "_i" from 1 to _amount do {
_item = createVehicle [_itemClass, _position, [], 0, "CAN_COLLIDE"];
// Load item or delete it if no space left
if !([_item, _vehicle] call FUNC(loadItem)) exitWith {
deleteVehicle _item;
};
// Invoke listenable event
["cargo_itemAdded", [_itemClass, _vehicle, _amount]] call EFUNC(common,globalEvent);
};

View File

@ -1,6 +1,6 @@
/*
* Author: Glowbal
* Initializes vehicle, adds open caro menu action if available.
* Initializes vehicle, adds open cargo menu action if available.
*
* Arguments:
* 0: Vehicle <OBJECT>
@ -25,7 +25,7 @@ _initializedClasses = GETMVAR(GVAR(initializedClasses),[]);
if (isServer) then {
{
if (isClass _x) then {
[getText (_x >> "type"), _vehicle, getNumber (_x >> "amount")] call FUNC(addItem);
["AddCargoItem", [getText (_x >> "type"), _vehicle, getNumber (_x >> "amount")]] call EFUNC(common,localEvent);
};
} count ("true" configClasses (configFile >> "CfgVehicles" >> _type >> "ACE_Cargo" >> "Cargo"));
};