2015-08-10 21:07:47 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
2015-08-18 21:59:01 +00:00
|
|
|
* Initializes vehicle, adds open cargo menu action if available.
|
2015-08-10 21:07:47 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2015-08-16 20:41:35 +00:00
|
|
|
* 0: Vehicle <OBJECT>
|
2015-08-10 21:07:47 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
2015-08-16 20:41:35 +00:00
|
|
|
* Example:
|
|
|
|
* [vehicle] call ace_cargo_fnc_initVehicle
|
|
|
|
*
|
2015-08-10 21:07:47 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
params ["_vehicle"];
|
|
|
|
TRACE_1("params", _vehicle);
|
|
|
|
|
|
|
|
private ["_type", "_initializedClasses"];
|
|
|
|
_type = typeOf _vehicle;
|
|
|
|
_initializedClasses = GETMVAR(GVAR(initializedClasses),[]);
|
|
|
|
|
2015-08-11 21:18:01 +00:00
|
|
|
if (isServer) then {
|
|
|
|
{
|
|
|
|
if (isClass _x) then {
|
2015-09-20 15:05:34 +00:00
|
|
|
private ["_cargoClassname", "_cargoCount"];
|
|
|
|
_cargoClassname = getText (_x >> "type");
|
|
|
|
_cargoCount = getNumber (_x >> "amount");
|
|
|
|
TRACE_3("adding ACE_Cargo", (configName _x), _cargoClassname, _cargoCount);
|
|
|
|
["AddCargoByClass", [_cargoClassname, _vehicle, _cargoCount]] call EFUNC(common,localEvent);
|
2015-08-11 21:18:01 +00:00
|
|
|
};
|
2015-08-14 16:07:31 +00:00
|
|
|
} count ("true" configClasses (configFile >> "CfgVehicles" >> _type >> "ACE_Cargo" >> "Cargo"));
|
2015-08-11 21:18:01 +00:00
|
|
|
};
|
|
|
|
|
2015-08-10 21:07:47 +00:00
|
|
|
// do nothing if the class is already initialized
|
|
|
|
if (_type in _initializedClasses) exitWith {};
|
|
|
|
// set class as initialized
|
|
|
|
_initializedClasses pushBack _type;
|
|
|
|
SETMVAR(GVAR(initializedClasses),_initializedClasses);
|
|
|
|
|
2015-08-16 20:41:35 +00:00
|
|
|
if (getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(hasCargo)) != 1) exitWith {};
|
2015-08-10 21:07:47 +00:00
|
|
|
|
|
|
|
private ["_text", "_condition", "_statement", "_icon", "_action"];
|
2015-08-26 21:26:08 +00:00
|
|
|
_condition = {
|
|
|
|
params ["_target", "_player"];
|
2015-09-26 16:16:38 +00:00
|
|
|
GVAR(enable) && {locked _target < 2} && {alive _target} && {[_player, _target, []] call EFUNC(common,canInteractWith)}
|
2015-08-26 21:26:08 +00:00
|
|
|
};
|
2015-08-14 20:46:51 +00:00
|
|
|
_text = localize LSTRING(openMenu);
|
2015-08-14 20:01:14 +00:00
|
|
|
_statement = {GVAR(interactionVehicle) = _target; createDialog QGVAR(menu);};
|
2015-08-10 21:07:47 +00:00
|
|
|
_icon = "";
|
|
|
|
|
|
|
|
_action = [QGVAR(openMenu), _text, _icon, _statement, _condition] call EFUNC(interact_menu,createAction);
|
|
|
|
[_type, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToClass);
|