diff --git a/addons/mission/XEH_PREP.hpp b/addons/mission/XEH_PREP.hpp index e9274159..a2d05bf5 100644 --- a/addons/mission/XEH_PREP.hpp +++ b/addons/mission/XEH_PREP.hpp @@ -22,6 +22,7 @@ PREP(enableAI); PREP(forceShooting); PREP(groundFog); PREP(jam); +PREP(lockDoors); PREP(markBuildings); PREP(mortarStrike); PREP(ping); diff --git a/addons/mission/functions/fnc_lockDoors.sqf b/addons/mission/functions/fnc_lockDoors.sqf new file mode 100644 index 00000000..74a01015 --- /dev/null +++ b/addons/mission/functions/fnc_lockDoors.sqf @@ -0,0 +1,39 @@ +#include "..\script_component.hpp" +/* + * Author: Mike + * + * Call on the server with isGlobal flag or locally without it. + * + * Arguments: + * 0: Building + * 1: Door Index (default: []) + * 2: Lock State (default: 1) + * 2: Global (default: true) + * + * Return Value: + * None + * + * Examples: + * [My_Building, [1, 2]] call MFUNC(lockDoors); + * [My_Building, [1, 2, 3, 4], 0, false] call MFUNC(lockDoors); +*/ + +params ["_building", ["_doorIndex", []], ["_lockState", 1], ["_isGlobal", true]]; + +// If running globally, exit if not the server. +if (_isGlobal && !isServer) exitWith {}; + +// Exit if door index array is empty +if (_doorIndex isEqualTo []) exitWith { + ERROR_MSG("Door Index is empty."); +}; + +// Check lockstate value is correct. +if !(_lockState in [0, 1]) exitWith { + ERROR_MSG_1("Lock State is invalid (%1), expected 0 or 1.",_lockState); +}; + +{ + private _door = format ["BIS_Disabled_Door_%1", _x]; + _building setVariable [_door, _lockState, _isGlobal]; +} forEach _doorIndex;