/* * Author: Clarky * Usage: * [_hq, _vehicle, _cost, _buildTime] call CLF_fnc_factoryBuildConfirmClient; * * * * Purpose: * * */ params ["_hq", "_vehicle", "_cost", "_buildTime", "_player"]; missionNamespace setVariable ["buildActive", true]; missionNamespace setVariable ["cancelBuild", false]; _player playMoveNow "Acts_carFixingWheel"; private _endTime = time + _buildTime; [_hq, _vehicle, _cost, _buildTime, _endTime, _player] spawn { params ["_hq", "_vehicle", "_cost", "_buildTime", "_endTime", "_player"]; // Load the 'display' handling input events private _display = findDisplay 46; // Add an event handler to be able to cancel the build private _keyboardCancel = _display displayAddEventHandler [ // Handle keyboard clicks as extra verification tools "KeyDown", { params ["", "_key"]; switch (_key) do { case 1: // Escape { missionNamespace setVariable [ "cancelBuild", true ]; }; }; false; } ]; private _mouseCancel = _display displayAddEventHandler [ // Handle LMB/RMB click "MouseButtonDown", { params ["", "_button"]; switch (_button) do { case 1: // RMB { missionNamespace setVariable [ "cancelBuild", true ]; }; }; false; } ]; waitUntil { animationState player == "Acts_carFixingWheel" }; while { missionNamespace getVariable ["buildActive", false]; } do { private _remainingTIme = ceil (_endTime - time); hintSilent format ["Remaining Build Time: %1\n\nRMB or ESC to cancel", _remainingTime max 0]; if (animationState player != "Acts_carFixingWheel" && (missionNamespace getVariable ["buildActive", false]) && (_vehicle getVariable "buildComplete")) then { player playMoveNow "Acts_carFixingWheel"; }; if ((missionNamespace getVariable "cancelBuild") || !(alive _vehicle)) then { [ "CLF_CancelFactoryBuildServer", [ _hq, _vehicle, _cost, _player ] ] call CBA_fnc_serverEvent; missionNamespace setVariable ["buildActive", false]; }; if (_vehicle getVariable "buildComplete") then { missionNamespace setVariable ["buildActive", false]; }; sleep 0.2; if (!(missionNamespace getVariable ["buildActive", false])) then { hintSilent ""; if (animationState player == "Acts_carFixingWheel") then { player switchMove ""; }; _display displayRemoveEventHandler ["MouseButtonDown", _mouseCancel]; _display displayRemoveEventHandler ["KeyDown", _keyboardCancel]; } }; };