Files
Clarksons_Logi_Framework/functions/fn_initSupplyDepot.sqf
T

65 lines
1.5 KiB
Plaintext
Raw Normal View History

/*
Author: Clarky
Usage:
[this, 1000, 0, false, 0] call CLF_fnc_initSupplyDepot;
Intended to run on the server, which calls a CBA event handler that runs a client-level script for adding relevant interactions
*/
params [["_hq", "", ["", objNull]], "_depot", "_maxMateriel", "_currentMateriel", "_isGenerator", "_materielRate"];
_depot setVariable ["isSupplyDepot", true, true];
_depot setVariable ["maxMateriel", _maxMateriel, true];
_depot setVariable ["currentMateriel", _currentMateriel, true];
_depot setVariable ["isGenerator", _isGenerator, true];
_depot setVariable ["materielRate", _materielRate, true];
if (_hq isNotEqualTo "") then {
_depot setVariable ["hq", _hq, true];
private _baseDetails = _hq getVariable "baseDetails";
private _depots = _baseDetails get "depots";
_depots pushBack _depot;
//_hq setVariable ["baseDetails", _baseDetails];
};
[_depot] remoteExecCall [
"CLF_fnc_initSupplyDepotInteractions",
0,
true
];
if (_depot getVariable "isGenerator") then {
[_depot, _materielRate] spawn {
params ["_depot", "_materielRate"];
while {alive _depot} do {
private _depotCurrent =
_depot getVariable "currentMateriel";
private _depotMax =
_depot getVariable "maxMateriel";
private _freeSpace =
_depotMax - _depotCurrent;
private _amount =
(_materielRate min _freeSpace);
_depot setVariable [
"currentMateriel",
_depotCurrent + _amount,
true
];
sleep 30;
};
};
};
/*
[
"CLF_SupplyDepotCreated",
[_depot]
] call CBA_fnc_globalEventJIP;
*/