Jump to content
Sign in to follow this  
total

Need help: Turn off lamps

Recommended Posts

Yo,

I'm trying to get all street lamps (Street Lamp small) in a city to turn off after I destroys a particular object (Power generator) on the map, but it doesn't seem to work. What's wrong?

lampkiller.sqf

if (!isServer) exitWith {};

_types = ["Land_LampStreet_small_F", "Land_LampStreet_F"];
for [{_i=0},{_i < (count _types)},{_i=_i+1}] do {
	_lamps = position lampchooser nearObjects [_types select _i, 1200];
	{_x setDamage 0.95; sleep 0.15} forEach _lamps;
};
};

Trigger:

CONDITION: isServer && damage (position powergenerator nearestObject 1487938) > 0.9;

ON ACT: _nul = [] execVM "scripts\lampkiller.sqf";

Game logics:

1: lampchooser -> Placed in the middle of the city

2: powergenerator -> Placed on top of the power generator

Edited by Total

Share this post


Link to post
Share on other sites

I think theres a problem with the logic inside the script itself, 'lamps' is an array and your trying to use it as an object, anyhow, here's my solution to doing something similar, needs a few tweaks

_centerPos = _this select 0;
blowlights = ["Lamps_base_f","Land_PowerPoleWooden_L_F","PowerLines_base_f","PowerLines_small_base_f"];
_nearestGenerator = nearestObject[_centerPos,"Land_spp_transformer_f"];
_allLights = nearestObjects[_nearestGenerator,blowlights,];
waitUntil{damage _nearestgenerator >= 1};
hint "Generator Down";
{
_x setHit ["light_1_hitpoint",0.97];
_x setHit ["light_2_hitpoint",0.97];_x setHit ["light_3_hitpoint",0.97];
_x setHit ["light_4_hitpoint",0.97];
} foreach nearestObjects[_nearestGenerator,blowlights,];

ripped from my editing tool script templates

Edited by austin_medic

Share this post


Link to post
Share on other sites
I think theres a problem with the logic inside the script itself, 'lamps' is an array and your trying to use it as an object, anyhow, here's my solution to doing something similar, needs a few tweaks

Yes, _lamps is an array, but lamps is also a name of a Game logic placed in the middle of the city to choose every lamp in 1200m. Gamelogic name is changed ;)

Anyway, I can't get any of the scripts to work. Is the Street Lamp class name wrong?

Share this post


Link to post
Share on other sites

I trying to turn street lights that are already exist on the map, OFF! Not editor placed lamps. Is that possible? Either destroy them or change between [ON] and [OFF]

---------- Post added at 16:25 ---------- Previous post was at 15:31 ----------

Got it to work with: 0 = [0.95] execVM "scripts\lampkiller.sqf";

Share this post


Link to post
Share on other sites

setDamage is the way to go. Here's a version I used for a mission:

if (isServer) then {	_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"
];


for [{_i=0},{_i < (count _types)},{_i=_i+1}] do
{
	_lamps = (getMarkerPos "ps1") nearObjects [_types select _i, 2000]; // 1000 = distance
	sleep 0.1;
	{_x setDamage 0.95} forEach _lamps;
};  

};

Edited by whiztler
snippet screwed up

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  

×