Added support for cargo configuration on vehicle spawn

This commit is contained in:
Glowbal 2015-08-11 23:18:01 +02:00
parent ffa476bee2
commit abc732ac35
2 changed files with 31 additions and 1 deletions

View File

@ -4,6 +4,15 @@ class CfgVehicles {
class Car: LandVehicle {
GVAR(space) = 4;
GVAR(hasCargo) = 1;
class ACE_Cargo {
/*
class Cargo {
class ACE_medicalSupplyCrate {
type = "ACE_medicalSupplyCrate";
amount = 1;
};*/
};
};
};
class Tank: LandVehicle {

View File

@ -17,10 +17,31 @@ params ["_vehicle"];
TRACE_1("params", _vehicle);
private ["_type", "_initializedClasses"];
_type = typeOf _vehicle;
_initializedClasses = GETMVAR(GVAR(initializedClasses),[]);
if (isServer) then {
{
if (isClass _x) then {
private ["_className", "_amount","_position","_object"];
_className = getText (_x >> "type");
_amount = getNumber (_x >> "amount");
_position = getPos _vehicle;
_position set [2, (_position select 2) + 7.5];
_position set [1, (_position select 1) + 1];
for "_i" from 1 to _amount do {
_object = createVehicle [_className, _position, [], 0, "CAN_COLLIDE"];
if !([_object, _vehicle] call FUNC(loadItem)) exitwith {
deleteVehicle _object;
};
};
};
nil
}count ("true" configClasses (configFile >> "CfgVehicles" >> _type >> "ACE_Cargo" >> "Cargo"));
};
// do nothing if the class is already initialized
if (_type in _initializedClasses) exitWith {};
// set class as initialized