{"name":"BIS_fnc_switchLamp","title":"BIS fnc switchLamp","type":"function","url":"https://community.bistudio.com/wiki/BIS_fnc_switchLamp","revid":348593,"updated":"2023-11-08T13:44:37Z","groups":["Object Manipulation"],"status":"ok","games":{"arma3":"1.64"},"since":"arma3 1.64","arma3_since":"1.64","locality":{"effect":"local"},"description":"Switch streetlamp on/off.","syntaxes":[{"syntax":"[object, state] call BIS_fnc_switchLamp","params":[{"name":"object","type":"Object","description":"street Lamp","type_expr":"Object"},{"name":"state","type":"Boolean","description":"true to turn lamp on, false to turn it off","type_expr":"Boolean"}],"returns":{"type":"Nothing","type_expr":"Nothing"}}],"examples":[{"code":["// switches all lamps off in a radius of 200m\nprivate _lampsIn200m = nearestObjects [player, [\"Lamps_base_F\", \"PowerLines_base_F\", \"PowerLines_Small_base_F\"], 200];\n{ [_x, false] call BIS_fnc_switchLamp; } forEach _lampsIn200m;"]},{"text":"```sqf\n// simulates a damaged street light\naLamp spawn {\n    params [\n        [\"_lamp\", objNull, [objNull]]\n    ];\n    while { player distance _lamp < 200 } do\n    {\n        [_lamp, selectRandom [true, false]] call BIS_fnc_switchLamp;\n        sleep 0.1 + random 0.5;\n    };\n};\n```","code":["// simulates a damaged street light\naLamp spawn {\n\tparams [\n\t\t[\"_lamp\", objNull, [objNull]]\n\t];\n\twhile { player distance _lamp < 200 } do\n\t{\n\t\t[_lamp, selectRandom [true, false]] call BIS_fnc_switchLamp;\n\t\tsleep 0.1 + random 0.5;\n\t};\n};"]}],"see_also":["switchLight"]}