ACE3/addons/safemode/functions/fnc_setWeaponSafety.sqf
jonpas 742626ff1a
General - Relative script_component.hpp includes (#9378)
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2023-09-12 20:58:10 +02:00

39 lines
868 B
Plaintext

#include "..\script_component.hpp"
/*
* Author: Brostrom.A
* Safe or unsafe the given weapon based on weapon state; locked or unlocked.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Weapon <STRING>
* 2: State <BOOL>
* 3: Show hint <BOOL> (default: true)
*
* Return Value:
* None
*
* Example:
* [ACE_player, currentWeapon ACE_player, true] call ace_safemode_fnc_setWeaponSafety
*
* Public: Yes
*/
params [
["_unit", objNull, [objNull]],
["_weapon", "", [""]],
["_state", true, [true]],
["_hint", true, [true]]
];
if (_weapon == "") exitWith {};
private _safedWeapons = _unit getVariable [QGVAR(safedWeapons), []];
_weapon = configName (configFile >> "CfgWeapons" >> _weapon);
private _muzzle = currentMuzzle _unit;
if (_state isNotEqualTo (_weapon in _safedWeapons)) then {
[_unit, _weapon, _muzzle, _hint] call FUNC(lockSafety);
};