1
0

nightvision.sqf 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "\a3\editor_f\Data\Scripts\dikCodes.h"
  2. #include "../config_macros.hpp"
  3. //handle loadout changed
  4. macro_grp_fnc_name(nightvision,handle_change) = {
  5. params["_unit", "_loadout"];
  6. _nv_gear = _loadout select 9 select 5;
  7. _RD501_isNV = (configFile >> "cfgWeapons" >> _nv_gear >> "RD501_isNV") call BIS_fnc_getCfgDataBool;
  8. player setVariable["RD501_isNV",_RD501_isNV,true];
  9. if (!_RD501_isNV) then {
  10. call macro_grp_fnc_name(nightvision,switch_off);
  11. };
  12. };
  13. //switch nightvision on
  14. macro_grp_fnc_name(nightvision,switch_on) = {
  15. setApertureNew [0.7, 0.7, 0.7, 1];
  16. player setVariable["RD501_NV_on",true,true];
  17. };
  18. //switch nightvision off
  19. macro_grp_fnc_name(nightvision,switch_off) = {
  20. setAperture -1;
  21. player setVariable["RD501_NV_on",false,true];
  22. };
  23. //handle button press
  24. macro_grp_fnc_name(nightvision,handle_switch) = {
  25. _RD501_isNV = player getVariable["RD501_isNV",false];
  26. _RD501_NV_on = player getVariable["RD501_NV_on",false];
  27. if (_RD501_isNV && !_RD501_NV_on) then {
  28. call macro_grp_fnc_name(nightvision,switch_on);
  29. } else {
  30. call macro_grp_fnc_name(nightvision,switch_off);
  31. };
  32. };
  33. //add eventhandler
  34. ["loadout", macro_grp_fnc_name(nightvision,handle_change)] call CBA_fnc_addPlayerEventHandler;
  35. //add keybinds
  36. ["RD501 Nightvision","Cycle",["Cycle","Switch Nightvision on/off"],{
  37. [player] call macro_grp_fnc_name(nightvision,handle_switch);
  38. },"",[DIK_N,[false,true,false]],false] call cba_fnc_addKeybind;