Safemode - add public setWeaponSafety function (#7092)

* Create fn_safeWeapon.sqf

* Update XEH_PREP.hpp

* Adjustments to script to meet demands 

not tested

* adjustment according to review

* minor adjustments

* Update fn_safeWeapon.sqf

* Rename and adjustments

* Adjustments

* Fixed typo

Co-Authored-By: commy2 <commy-2@gmx.de>

* Update addons/safemode/functions/fn_setWeaponSafety.sqf

Co-Authored-By: commy2 <commy-2@gmx.de>

* Update addons/safemode/functions/fn_setWeaponSafety.sqf

Co-Authored-By: commy2 <commy-2@gmx.de>

* Fixed missing param in exsample

* Test fixes

* Update addons/safemode/functions/fnc_setWeaponSafety.sqf

Co-Authored-By: Filip Maciejewski <veteran29@users.noreply.github.com>
This commit is contained in:
Broström.A | Evul 2019-10-08 03:19:04 +02:00 committed by PabstMirror
parent 06a0f30a05
commit b514541bec
2 changed files with 37 additions and 0 deletions

View File

@ -3,3 +3,4 @@ PREP(lockSafety);
PREP(playChangeFiremodeSound);
PREP(setSafeModeVisual);
PREP(unlockSafety);
PREP(setWeaponSafety);

View File

@ -0,0 +1,36 @@
#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>
*
* 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]]
];
if (_weapon == "") exitWith {};
private _safedWeapons = _unit getVariable [QGVAR(safedWeapons), []];
_weapon = configName (configFile >> "CfgWeapons" >> _weapon);
private _muzzle = currentMuzzle _unit;
if !(_state isEqualTo (_weapon in _safedWeapons)) then {
[_unit, _weapon, _muzzle] call FUNC(lockSafety);
};