mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
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:
parent
06a0f30a05
commit
b514541bec
@ -3,3 +3,4 @@ PREP(lockSafety);
|
||||
PREP(playChangeFiremodeSound);
|
||||
PREP(setSafeModeVisual);
|
||||
PREP(unlockSafety);
|
||||
PREP(setWeaponSafety);
|
||||
|
36
addons/safemode/functions/fnc_setWeaponSafety.sqf
Normal file
36
addons/safemode/functions/fnc_setWeaponSafety.sqf
Normal 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);
|
||||
};
|
Loading…
Reference in New Issue
Block a user