
>> FOLLOW THIS POST FOR CHERNARUS <<
>> FOR CELLE EDITS: HERE <<
>> TAVIANA STREET LIGHTS HERE<<
Here it is, working street lights for Chernarus:
init.sqf (add these lines):
Code:
if (isServer) then {
axe_server_lampObjs = compile preprocessFileLineNumbers "lights\fnc_returnLampWS.sqf";
"axeLampObjects" addPublicVariableEventHandler {_id = (_this select 1) spawn axe_server_lampObjs};
};
if (!isDedicated) then {
//StreetLights
[] execVM "lights\street_lights.sqf";
};
Create a new folder called lights and add the following two files. This is all basic mission editing and there are plenty of threads covering this area, please go and try the dayZ House Lights or one of the other great addons here or in dayZ Scripting Discussions or search / browse before asking basic mission editing questions here. Will answer any queries but trying to keep the thread as clean as possible, ta
lights\fnc_returnLampWS.sqf: Download Rar File (Too big for posting)
lights\street_lights.sqf
Code:
//dayZ Street Lights from axeman - [email protected]
waitUntil {!isNull player};
//waitUntil {time > 30};
private ["_plCellsLitVar","_1stPos""_cellGen","_objLightPoint","_lightposX","_lightposY","_xpos","_ypos","_awayx","_awayy","_location","_plCurrX","_plCurrY","_nLampObject"];
_plCellsLitVar=[];
private["_mtrxNum","_mapSW","_mapNE","_widthX","_widthY","_cellWidth","_cellHeight"];
while {alive player}do{
axeLampReturn=[];
if(daytime<6||daytime>17)then {
_plCellsLitVar = player getVariable ["axeCellsLit",[]];
//hint format ["CELLSLIT:%1",_plCellsLitVar];
sleep 0.2;
_plCurrX = getPos vehicle player select 0;
_plCurrY = getPos vehicle player select 1;
_mtrxNum = 6;
_mapSW = [484,1546,0];
_mapNE = [14323,13556,0];
_widthX = (_mapNE select 0) - (_mapSW select 0);
_widthY = (_mapNE select 1) - (_mapSW select 1);
_cellWidth = _widthX / _mtrxNum;
_cellHeight = _widthY / _mtrxNum;
//GET CELL PLAYER IS IN - CHECK IF LIT ALREADY
for "_x" from 0 to (_mtrxNum - 1) do {
if(_plCurrX > (_mapSW select 0) + (_cellWidth * _x) && _plCurrX < (_mapSW select 0) + (_cellWidth * (_x+1)))then{
for "_y" from 0 to (_mtrxNum - 1) do {
if(_plCurrY > (_mapSW select 1) + (_cellHeight * _y) && _plCurrY < (_mapSW select 1) + (_cellHeight * (_y+1)))then{
if(call Compile format ["%1%2",_x,_y] in _plCellsLitVar)then{
axeLampReturn=[];
//hint format ["IN CELL:%1%2 | ALREADY LIT:%3",_x,_y,_plCellsLitVar];
}else{
//Call Compile format ["_plCell = _cell%1%2",_x,_y];
axeLampObjects = [_x,_y,player];
publicVariable "axeLampObjects";
waitUntil {count axeLampReturn > 0};
Call Compile format ["_plCellsLitVar = _plCellsLitVar + [%1%2]",_x,_y];
//hint format ["IN CELL:%1%2 | NOT LIT :%3",_x,_y,_plCellsLitVar];
};
sleep 1;
};
};
};
};
if(count axeLampReturn >0)then{
//Illuminate
{
_location = [_x select 0,_x select 1,_x select 2];
_objLightPoint = nearestObject [_location, "#lightpoint"];
_awayx=(_location select 0)-(getPos _objLightPoint select 0);
_awayy=(_location select 1)-(getPos _objLightPoint select 1);
if((_awayx>1 or _awayx<-1)or(_awayy>1 or _awayy<-1))then{
_location set [1, (_x select 1) + ((0.6)*sin(_x select 3))];
_location set [2,_location select 2 - 0.2];
_location=[_location select 0, _location select 1, _location select 2];
_lp = "#lightpoint" createVehicle _location;
_lp setLightColor [1, 0.88, 0.73];
_lp setLightBrightness 0.04;
_lp setLightAmbient [1, 0.88, 0.73];
_lp setVectorUp [0,0,-1];
player reveal _lp;
//hint format ["LAMP NOT FOUND:%1 | %2",_x,time];
sleep 0.2;
}else{
//hint format["LAMP ALREADY FOUND | Var:%1",_objLightPoint getVariable "axeLit"];
if(_objLightPoint getVariable ["axeLit",0]<1)then{
_objLightPoint setLightColor [1, 0.88, 0.73];
_objLightPoint setLightBrightness 0.04;
_objLightPoint setLightAmbient [1, 0.88, 0.73];
_objLightPoint setVectorUp [0,0,-1];
};
sleep 0.2;
};
}forEach axeLampReturn;
player setVariable ["axeCellsLit",_plCellsLitVar];
};
sleep 3;
};
};
Battleye: (script restriction #20 )
Add
Code:
!"#lightpoint createVehicle _location;" !"#lightpoint createVehicleLocal _location;"
Code:
5 createVehicle
That's It ! (Go load it up) The rest is info.
Essentially the server holds a 6x6 grid array, of Chernarus, including all the locations of streetlamps on the server (there are some not included i.e. the telegraph poles with the lamp on top - these can be added).
Once the survivor enters the cell the script calls the server for the cell worldspaces and the client lights them up for just that cell.. New clients do not need to recreate the 'vehicle', that the #lightpoint' is made with, but do light up an existing one.. Was working on reducing this as other clients will see existing lights but will still set the brightness etc. (you may see a light blink)..
Changes: I have had previous issues which, I think, have been resolved with this newer version. My test code was recently deliberately used (and sold) without my permission so I feel I should just get this out there.. Just goes to show, not everyone is good to their word.
Additions: I really wanted to incorporate Personal Generators into this and merge it with my dayZ House Lights script amongst other ideas I have been toying with on my servers. Such as light failures, only working in some areas randomly, thunder storms knocking out lights, flickering lighting to add to the atmosfear etc.

There is a separate piece of code (Not Included) that runs once on the server to create the 'map' of all the streetlights. Basically, the streetlamps are, what I call, map items. They can only be seen by the server and even then can not be accessed using the normal nearestObjects until they have been parsed from all the other stuff on the map..
I did try sending the surrounding worldspaces, to the survivor, in real time from the server. Over a 50m radius was causing yellow chains (due to the amount of items) with me on my localhost server / gaming pc (is quite powerful). Which is why I went down the 'mapping / grid' route..
It took the program around 6 hours to parse 1321 'lampa' items from 3,031,789 chernarus 'map items', on my local test server, to build the streetlight position array (in the downloadable sqf). I can run this against other maps and easily apply the coords to them.
I have been playing with this concept and picking it up every other weekend and tweaking and changing, trying different methods, determined to beat it. I would have preferred to have released this when I was ready ! Am happy this will work ok, just not got the chance to test it on a big LAN server.
The fnc_returnLampWS.sqf can be packaged into the server files as the communication between that and the main street_lights.sqf is done with public variables, more importantly public server variables and public client variables (to reduce network traffic). This also has the advantage of reducing the download size of your mission file.. (This is how I have tested it)
Here it is, hope you get it going and am quietly confident that it will run sweet
Gameplay: From a gameplay point of view, it really adds to the playability at night. I have changed my server times so is 6 hours over dusk. Industrial areas and train stations are now easy to navigate in the dark, there are pointers when starting on the coast (the motorways / highways being lit). Yet you still get plenty of dark and scary moments, the lit areas add to the suspense as, when un-tooled up, you end up running back into the dark being chased by zombies.. There is no reason to not add a bit of lighting, with full moon nights (Set your date to static in the hiveext.ini) it is a winning combination..
Zombies in the day is fun, at night it is scary again...
dayZ Street Lights