/* ---------------------------------------------------------------------------------------------------- Function: GKB_fnc_blinkLights Author: Gekkibi Terms for copying, distribution and modification: Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) http://creativecommons.org/licenses/by-nc-sa/3.0/ Description: Makes all the lights close to a location blink. They blink until are damaged enough, or until global variables GKB_var_blinkLights_on or GKB_var_blinkLights_off are defined. If GKB_var_blinkLights_off is defined all the lights are turned off, and if GKB_var_blinkLights_on is defined all the lights are turned to auto (Lights are on during night). Parameters: 1st Array Position of the area of effect 2nd Number Range of the area of effect 3rd Strings in array Classnames not affected by this function 4th Numbers in array Blink rate. 1st element is off time and 2nd element is on time Returns: Nil Example: [ [4100, 4100], 500, ["Land_Lamp_Street1_EP1", "Land_Lamp_Street2_EP1"], [1, 5] ] call GKB_fnc_blinkLights; ---------------------------------------------------------------------------------------------------- */ if (isServer) then { private ["_blacklist", "_location", "_range", "_times"]; _location = _this select 0; _range = _this select 1; _blacklist = _this select 2; _times = _this select 3; { if (! (typeOf _x in _blacklist) && damage _x <= 0.5) then { [_x, _times] spawn { private ["_light", "_offTime", "_onTime"]; _light = _this select 0; _offTime = _this select 1 select 0; _onTime = _this select 1 select 1; while {isNil "GKB_var_blinkLights_on" && isNil "GKB_var_blinkLights_off"} do { if (! isNil "GKB_var_blinkLights_on" || damage _light > 0.5) exitWith {}; _light setDamage 0.3; _light switchLight "OFF"; sleep random _offTime; if (! isNil "GKB_var_blinkLights_off" || damage _light > 0.5) exitWith {}; _light setDamage 0; _light switchLight "AUTO"; sleep random _onTime; }; }; [_x] spawn { private ["_light"]; _light = _this select 0; waitUntil {sleep 1; ! isNil "GKB_var_blinkLights_off" || ! isNil "GKB_var_blinkLights_on" || damage _light > 0.5}; if (! isNil "GKB_var_blinkLights_on") then { _light setDamage 0; _light switchLight "AUTO"; }; if (! isNil "GKB_var_blinkLights_off") then { _light setDamage 0.3; _light switchLight "OFF"; }; }; }; } forEach (_location nearObjects ["StreetLamp", _range]); };