The script for finding the object ids takes a long time to run (several minutes) so it is not really for use in the game. Run it on its own and then make a note of the object ids for the lamps then in your init.sqs or somewhere else in the mission have the switchlight "OFF" instructions. You can do that for several lights in a simple way:
{(object _x) switchlight "OFF"} forEach [1251,2003,28419,......]
where the numbers in the array are the object ids that you get from running the script.
As an exercise in scriptng only - if you did want to modify the script to find them as well as turn them off then it should look something like:
_maxid = 200000
_i = 0
#loop
if (typeof (object _i) in ["StreetLampPanel","StreetLampMetal","StreetLampWood","StreetLampPanelAmpl","StreetLampYellow","StreetLampCut"]) then {(object _i) switchlight "OFF"}
_i = _i + 1
if (_i <= _maxid) then {goto "loop"}
exit
Note That:
if (typeof (object _i) in ["StreetLampPanel","StreetLampMetal","StreetLampWood","StreetLampPanelAmpl","StreetLampYellow","StreetLampCut"]) then {(object _i) switchlight "OFF"}
Is all one line.
On your second question:
If you create an East Present trigger and set it to repeating then it will activate whenever there are living east units in its area and it will deactivate if there are none.
So:
East Present
Repeating
Condition: this
Deactivate: Put here whatever it is you want to happen when the last one in the area gets killed (or moves out of the area).
It might work with a non-Repeating trigger - I just have not checked that.
If you want to check this from a script then give the trigger a name - say trigEastThere
In the script you can see what units are in the trigger area by checking the value of:
list trigEastThere
so for example
count list trigEastThere
would give you the number of units in the trigger area.