/* * Author: Clarky * Usage: * [] call CLF_fnc_factoryBuildConfirm; * * Intended to be called via the factoryBuild function once player confirms BIS_fnc_locations * * Purpose: * Concludes the process of building a vehicle with player selection on the VehicleFactory dialog * */ params ["_hq", "_player", "_vehicleClass", "_vehiclePreviewLocation", "_rotation", "_vectorUp", "_cost", "_buildTime", "_specialisation", "_specialisationData"]; // Check current materiel available at this base private _currentMateriel = [_hq, _player] call CLF_fnc_materielCheck; if (_currentMateriel > _cost) then { // Function runs and consumes the required supplies, returns true if successful, OR returns false after giving a 'not enough supplies' message to the player (theoretically) //[_hq, _cost, _player] remoteExec ["CLF_fnc_materielConsume", 2]; [ "CLF_MaterielConsume", [ _hq, _cost, _player ] ] call CBA_fnc_serverEvent; private _vehicle = createVehicle [_vehicleClass, _vehiclePreviewLocation, [], 0, "CAN_COLLIDE"]; waitUntil { _vehicle == _vehicle }; _vehicle allowDamage false; _vehicle enableSimulationGlobal false; _vehicle setDir _rotation; _vehicle setVectorUp _vectorUp; _vehicle setVehicleLock "LOCKED"; _vehicle lockInventory true; _vehicle setVariable ["buildComplete", false, true]; [ "CLF_ConfirmFactoryVehicleClient", [ _hq, _vehicle, _cost, _buildTime, _player ], _player ] call CBA_fnc_targetEvent; [ _vehicle, _buildTime, _specialisation, _specialisationData ] spawn { params ["_vehicle", "_buildTime", "_specialisation", "_specialisationData"]; sleep _buildTime; if (isNull _vehicle) exitWith {}; _vehicle allowDamage true; _vehicle enableSimulationGlobal true; _vehicle setVehicleLock "UNLOCKED"; _vehicle lockInventory false; _vehicle setVariable ["buildComplete", true, true]; switch (_specialisation) do { case "SUPPLY": { [ _vehicle, _specialisationData select 0, 0, _specialisationData select 1 ] call CLF_fnc_initSupplyVehicle; } }; }; } else { hintSilent ""; [ "CLF_ShowMessage", [ 1, 0, "Not enough materiel." ], _player ] call CBA_fnc_targetEvent; }