Skip to content

Commit

Permalink
Safemode - add public setWeaponSafety function (#7092)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
2 people authored and PabstMirror committed Oct 8, 2019
1 parent 06a0f30 commit b514541
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions addons/safemode/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ PREP(lockSafety);
PREP(playChangeFiremodeSound);
PREP(setSafeModeVisual);
PREP(unlockSafety);
PREP(setWeaponSafety);
36 changes: 36 additions & 0 deletions addons/safemode/functions/fnc_setWeaponSafety.sqf
Original file line number Diff line number Diff line change
@@ -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);
};

0 comments on commit b514541

Please sign in to comment.