Jump to content
Sign in to follow this  
roguetrooper

How to disable street lights?

Recommended Posts

Is there a way to disable all street lights by script (without destroying them)? Something like:

{_x switchlight "Off"} forEach (nearestObjects [player, ["StreetLamp"], 1000]);

Share this post


Link to post
Share on other sites

Tried quite a few things, none of them worked.

Seems that destroying the light bulbs per script is the only way to turn them off.

Share this post


Link to post
Share on other sites

Tried setDamage variant? Where setDamage 1 is off and 0 is on.

Share this post


Link to post
Share on other sites

{ 

private "_lamp";
_lamp = _x;

{ _lamp setHit [ format [ "Light_%1_hitpoint", _x ], 1 ] } forEach [ 1, 2, 3 ];

} foreach ( nearestObjects [ player, ["Lamps_base_F"], 200 ] );

Obviously you will need to modify the nearestObjects arguments. Other than that, this should work for most if not all street lights.

Share this post


Link to post
Share on other sites

I tried the one script in the other thread, it has lamp base in there, and half the lights went out, other half stayed on. I put a 1000m marker. There were so many lights inside the grid that remained on. No idea why. Its almost like there were too many lights, or the .95 wasn't enough damage to knock them out. Yet a bullet took them out just fine.

Share this post


Link to post
Share on other sites

Needs 1 damage, not .95. setHit also works. There's also different lamp types, you'll have to search around.

Share this post


Link to post
Share on other sites

The post by me in the other thread has the working script. I turns off all lights with only a few exceptions (runway markers, gas station). Also, use 0.95 because the destroys the light, and not the whole post. 1 will completely destroy the whole thing.

http://forums.bistudio.com/showthread.php?172320-I-am-one-type-of-lights-ClassName-short-of-success-help!!-P&p=2620825&viewfull=1#post2620825

Share this post


Link to post
Share on other sites

Yo fight, where do I put that .95? By the way? Because it wasn't working for me when I tried it

Share this post


Link to post
Share on other sites

Use it as a parameter when calling the script. The script works for both off and on.

off: 0 = [0.95] execVM "lights.sqf";

on: 0 = [0] execVM "lights.sqf";

Share this post


Link to post
Share on other sites

I'll make an example mission with a few different options.

Share this post


Link to post
Share on other sites

The AO I was attempting to disable is the town by the castle on the western shoreline of Altis, with the powerplant north of it, and comms towers up the mountain. Dont remember the name of the town.

I tested the trigger with alpha radio for off, and bravo radio for on. so I could easily turn lights on and off.

I included all the lights listed in the config viewer. Even had the lamp base in the list too. I dont know why only half the lights went out and half stayed on. Range set covered all area from castle up to the comms towers in the north.

When I went in to see what type lights were still on, one type looked like typical street lights with the curved bar at the top, and the small lamp top of a wood pole like the ones you build in Epoch. Except, the script only affected some of those. saw some on, some off of the exact same type. So im stumped.

---------- Post added at 20:27 ---------- Previous post was at 20:24 ----------

so that goes in init, or Trigger?

goes in trigger. from the 0 on forward. leave out the// and on and off.

Share this post


Link to post
Share on other sites

Ok, here is an example mission with two different options. Use the laptops in the building to turn the power on and off, or blow the transformers (sign actually) and it will kill the power. There are instructions while playing on what to do.

I might edit the script later to be more universal with optional distance and placement variables. Maybe...

https://dl.dropboxusercontent.com/u/17023300/lightsoff.Altis.zip

Share this post


Link to post
Share on other sites

Ok I upgraded the script a little bit to be more universal. This way, you can use it multiple times with different markers or objects. Of course, if you want you want to use the defaults, that's fine too.

Basic usage:

Make a marker named "lightsmarker" and make a trigger with 0 = [] execVM "lights.sqf"; in the On Act. Simple as that. Will cut all lights 1000m around "lightsmarker".

Use 0 = [0] execVM "lights.sqf"; to turn lights back on.

Advanced usage:

_this select 0 (optional): Damage, 0 for ON, 0.95 for OFF - Default 0.95

_this select 1 (optional): Distance - default 1000

_this select 2 (optional): Position - position objectName for object, getMarkerPos "markerName" for marker - Default getMarkerPos "lightsmarker"

Examples:

0 = [0.95, 100, position generator] execVM "lights.sqf"; - cut the lights 100m around object named "generator"

0 = [0, 500, position lightswitch] execVM "lights.sqf"; - restore the lights 500m around object named "lightswitch"

0 = [0.95, 1000, getMarkerPos "townMarker"] execVM "lights.sqf"; - cut lights 1000m around marker named "townmarker"

0 = [0, 250, getMarkerPos "powerplant"] execVM "lights.sqf"; - restore lights 250m around marker named "powerplant"

Script:

Make a file called lights.sqf and paste the following

_onoff = [_this, 0, 0.95, [0]] call BIS_fnc_param;
_distance = [_this, 1, 1000, [0]] call BIS_fnc_param;
_marker = [_this, 2, getMarkerPos "lightsmarker", ["",[],objNull]] call BIS_fnc_param;

_types = ["Lamps_Base_F", "PowerLines_base_F","Land_LampDecor_F","Land_LampHalogen_F","Land_LampHarbour_F","Land_LampShabby_F","Land_NavigLight","Land_runway_edgelight","Land_PowerPoleWooden_L_F"];

for [{_i=0},{_i < (count _types)},{_i=_i+1}] do
{
   _lamps = _marker nearObjects [_types select _i, _distance];
   sleep 0.1;
   {_x setDamage _onoff} forEach _lamps;
};

I take no credit for the original script. I've seen it passed around so much, I'm not sure who first shared it. All I did was make some simple edits to help make it more universal. This has been asked about a lot lately, so I thought I would share.

Edited by Fight9

Share this post


Link to post
Share on other sites

_list = [];
_list = _list + ["Lamps_base_F"];
_list = _list + ["Land_LampStreet_small_F"];
_list = _list + ["Land_LampStreet_F"];
_list = _list + ["Land_LampDecor_F"];
_list = _list + ["Land_LampHalogen_F"];
_list = _list + ["Land_LampHarbour_F"];
_list = _list + ["Land_LampShabby_F"];

_lamps = nearestObjects [logic1, _list, 3000];
{_x setHit ["light_1_hitpoint", 0.97]} forEach _lamps;
{_x setHit ["light_2_hitpoint", 0.97]} forEach _lamps;
{_x setHit ["light_3_hitpoint", 0.97]} forEach _lamps;
{_x setHit ["light_4_hitpoint", 0.97]} forEach _lamps;

exit;

This works perfectly. This way you can create pitch black towns at night.

"0.0" instead of "0.97" turns them on again. "light_2_hitpoint" and higher is for lamps with more than one bulb.

Share this post


Link to post
Share on other sites

More lights:

	_types = [
"Lamps_Base_F",
"Land_LampAirport_F",
"Land_LampSolar_F",
"Land_LampStreet_F",
"Land_LampStreet_small_F",
"PowerLines_base_F",
"Land_LampDecor_F",
"Land_LampHalogen_F",
"Land_LampHarbour_F",
"Land_LampShabby_F",
"Land_PowerPoleWooden_L_F",
"Land_NavigLight",
"Land_runway_edgelight",
"Land_runway_edgelight_blue_F",
"Land_Flush_Light_green_F",
"Land_Flush_Light_red_F",
"Land_Flush_Light_yellow_F",
"Land_Runway_PAPI",
"Land_Runway_PAPI_2",
"Land_Runway_PAPI_3",
"Land_Runway_PAPI_4",
"Land_fs_roof_F", // Fuel station roof lights
"Land_fs_sign_F"
];

Share this post


Link to post
Share on other sites

Hey Guys,

I'm trying to make a mission were the power is off over the entire altis map. Looking at the above sample by fight9 I wanted to use the town markers to switch it off. And have it come back on when power generators in the nearby plants are captured.

It is a multiplayer mission also.

I got the sript working with this.

Make a marker named "lightsmarker" and make a trigger with 0 = [] execVM "lights.sqf"; in the On Act. Simple as that. Will cut all lights 1000m around "lightsmarker".

Use 0 = [0] execVM "lights.sqf"; to turn lights back on.

But I'm a bit lost in using this: 0 = [0.95, 1000, getMarkerPos "townMarker"] execVM "lights.sqf"; - cut lights 1000m around marker named "townmarker"

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×