ACE3/addons/map/functions/fnc_switchFlashlight.sqf

40 lines
1.0 KiB
Plaintext
Raw Normal View History

2015-08-11 17:49:39 +00:00
/*
* Author: voioper
* Switch flashlight on/off.
2015-08-11 17:49:39 +00:00
*
* Arguments:
* 0: Unit <OBJECT>
* 1: New flashlight classname ("" for off) <STRING>
2015-08-11 17:49:39 +00:00
*
2016-06-18 09:50:41 +00:00
* Return Value:
2015-08-11 17:49:39 +00:00
* None
*
* Example:
* [ACE_player, "ACE_Flashlight_MX991"] call ace_map_fnc_switchFlashlight;
2015-08-11 17:49:39 +00:00
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_newFlashlight"];
private _unitLight = _unit getVariable [QGVAR(flashlight), ["", objNull]];
_unitLight params ["_flashlight", "_glow"];
2015-08-11 17:49:39 +00:00
if (GVAR(mapGlow)) then {
// we don't want to set the PVAR twice in a row, so tell this func not to set it
_glow = [_unit, _newFlashlight, false] call FUNC(flashlightGlow);
2015-08-11 17:49:39 +00:00
};
private _config = (configFile >> "CfgWeapons");
if (
(getNumber (_config >> _newFlashlight >> "ItemInfo" >> "FlashLight" >> "ACE_Flashlight_Sound") > 0) ||
{getNumber (_config >> _flashlight >> "ItemInfo" >> "FlashLight" >> "ACE_Flashlight_Sound") > 0}
) then {
playSound QGVAR(flashlightClick);
};
_unit setVariable [QGVAR(flashlight), [_newFlashlight, _glow], true];