Skip to content

Commit

Permalink
Mission - Add Door Lock function (#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike-MF authored Dec 25, 2023
1 parent 96a1a4d commit 0b9f0c1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions addons/mission/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ PREP(enableAI);
PREP(forceShooting);
PREP(groundFog);
PREP(jam);
PREP(lockDoors);
PREP(markBuildings);
PREP(mortarStrike);
PREP(ping);
Expand Down
39 changes: 39 additions & 0 deletions addons/mission/functions/fnc_lockDoors.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "..\script_component.hpp"
/*
* Author: Mike
*
* Call on the server with isGlobal flag or locally without it.
*
* Arguments:
* 0: Building <OBJECT>
* 1: Door Index <ARRAY> (default: [])
* 2: Lock State <NUMBER> (default: 1)
* 2: Global <BOOL> (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;

0 comments on commit 0b9f0c1

Please sign in to comment.