diff --git a/addons/vehicles/XEH_preInit.sqf b/addons/vehicles/XEH_preInit.sqf index b47cf6628db..028a8aec1c3 100644 --- a/addons/vehicles/XEH_preInit.sqf +++ b/addons/vehicles/XEH_preInit.sqf @@ -6,4 +6,37 @@ PREP_RECOMPILE_START; #include "XEH_PREP.hpp" PREP_RECOMPILE_END; +#include "initSettings.sqf" + +[ + "AllVehicles", + "initPost", + { + params ["_vehicle"]; + _vehicle setVariable [QGVAR(engineState), isEngineOn _vehicle]; + } +] call CBA_fnc_addClassEventHandler; +[ + "AllVehicles", + "engine", + { + params ["_vehicle", "_state"]; + _vehicle setVariable [QGVAR(engineState), _state]; + } +] call CBA_fnc_addClassEventHandler; +[ + "AllVehicles", + "getout", + { + params ["_vehicle", "_position", "_unit"]; + if (!GVAR(keepEngineRunning)) exitWith {}; + if (_unit == ACE_player && {_position == "driver" && {_vehicle getVariable [QGVAR(engineState), false]}}) then { + [{ + params ["_vehicle"]; + [QEGVAR(common,engineOn), _this, _vehicle] call CBA_fnc_targetEvent; + }, [_vehicle, true]] call CBA_fnc_execNextFrame; + }; + } +] call CBA_fnc_addClassEventHandler; + ADDON = true; diff --git a/addons/vehicles/initSettings.sqf b/addons/vehicles/initSettings.sqf new file mode 100644 index 00000000000..026367a794e --- /dev/null +++ b/addons/vehicles/initSettings.sqf @@ -0,0 +1,9 @@ + +[ + QGVAR(keepEngineRunning), + "CHECKBOX", + [LSTRING(SettingKeepEngineRunningName), LSTRING(SettingKeepEngineRunningDesc)], + localize ELSTRING(common,ACEKeybindCategoryVehicles), + false, // default value + true // isGlobal +] call CBA_settings_fnc_init; diff --git a/addons/vehicles/stringtable.xml b/addons/vehicles/stringtable.xml index b2d282b3055..271c788ad3f 100644 --- a/addons/vehicles/stringtable.xml +++ b/addons/vehicles/stringtable.xml @@ -67,5 +67,13 @@ 速度制限を減らす Zmniejsz ograniczenie prędkości + + Disable automatic engine shut-off + Motor nach Verlassen laufen lassen + + + Prevent the automatic shut-off of the engine when exiting vehicles. + Verhindere das automatische Abschalten des Motors beim Verlassen des Fahrzeugs. +