Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
" !"_x setVariable [\"cleared\",true,true];";" !"_x setVariable [\"cleared\",false,true];";" !"_item setVariable [\"permaloot\",true,true];"
EDIT:
Approach 1: Server-Side loot spawn on Init
Create the following sqf in dayz_server/compile/
What do we name this file? server_spawnLoot.sqf?
Code:private["_positions","_iArray","_iPos","_item","_obj","_type","_nearBy","_itemType","_itemChance","_lootChance","_weights","_index"]; _obj = _this select 0; _type = typeOf _obj; _config = configFile >> "CfgBuildingLoot" >> _type; _positions = [] + getArray (_config >> "lootPos"); _lootChance = getNumber (_config >> "lootChance"); _itemType = [] + getArray (_config >> "itemType"); _itemChance = [] + getArray (_config >> "itemChance"); { _iPos = _obj modelToWorld _x; _rnd = random 1; //Place something at each position if (player distance _iPos > 5) then { if (_rnd < _lootChance) then { _nearBy = nearestObjects [_iPos, ["WeaponHolder","WeaponHolderBase"],1]; if (count _nearBy == 0) then { _weights = [_itemType,_itemChance] call fnc_buildWeightedArray; _index = _weights call BIS_fnc_selectRandom; if (_index >= 0) then { _iArray = +(_itemType select _index); _iArray set [2,_iPos]; _iArray set [3,0]; _iArray call spawn_loot; _iArray = []; //diag_log ("LOOTSPAWN"); }; _item setVariable ["created",(DateToNumber date),true]; _item setVariable ["permaloot",true,true]; }; }; }; } forEach _positions;
Then add this to dayz_server/init/server_functions.sqf:
Code:server_spawnPermaLoot = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_spawnLoot.sqf";
I'm not sure if this is needed, to be honest, but in dayz_code_system/building_monitor.sqf, you may have to comment this line out (I changed the system around a few times until it worked so I'm not sure, but objects marked with the permaloot variable may be immune to this):
Code:{deleteVehicle _x;} forEach _items;
Then create an sqf named "server_permaLoot.sqf" in dayz_server/compile/ with the following:
Code:private["_center","_allBldngs","_type","_config","_canLoot","_cleared"]; if (isServer) then { _center = getMarkerPos "center"; _allBldngs = _center nearObjects ["building",8500]; // (root(225000) / 2) + 1000 should get everything in Chernarus { _type = typeOf _x; _config = configFile >> "CfgBuildingLoot" >> _type; _canLoot = isClass (_config); _cleared = (_x getVariable ["cleared",true]); if (_canLoot) then { if (isNil("_cleared")) then { _x setVariable ["cleared",true,true]; _cleared = true }; if (_cleared) then { [_x] call server_spawnLoot; _x setVariable ["cleared",false,true]; }; }; } forEach _allBldngs; };
Last, add the following to the bottom of dayz_server/system/server_monitor.sqf below the heli wreck spawns:
I do not have the above file. Please advise.
I do not have this file. Is this the same as the one further up, but misnamed?
Code:_id = call server_spawnPermaLoot;
What do I need to remove and from which init.sqf?
To get loot to spawn from these objects with the above script, I'm calling it at the end of this one, so you will have to remove it from init.sqf if using this, as well.
Do I change anything if I want to spawn everything (just want vanilla DayZ with all loot spawned?
If you want to only spawn specific objects or stop some from spawning, take a look at the commented if statement
Create a new sqf named server_fillLocs.sqf in dayz_server/compile/ with the following:
Code:private ["_configBase","_tempList"]; if (isServer) then { _tempList = ["Chernogorsk","Elektrozavodsk","Balota","Komarovo","Kamenka","Kamyshovo","Prigorodki","Kabanino","Solnichniy","StarySobor","NovySobor","SouthernAirport","NorthernAirport","Berezino","Lopatino","GreenMountain","Zelenogorsk","Nadezhdino","Kozlovka","Mogilevka","Pusta","Bor","Pulkovo","Vyshnoye","Drozhino","Pogorevka","Rogovo","Guglovo","Staroye","Pavlovo","Shakhovka","Sosnovka","Msta","Pustoshka","Dolina","Myshkino","Tulga","Vybor","Polana","Gorka","Orlovets","Grishino","Dubrovka","Nizhnoye","Gvozdno","Petrovka","Khelm","Krasnostav","Olsha"]; for "_j" from 0 to ((count _tempList) - 1) do { _configBase = configFile >> "CfgTownGenerator" >> (_tempList select _j); for "_i" from 0 to ((count _configBase) - 1) do { private ["_config","_type","_position","_dir","_onFire","_object"]; _config = (_configBase select _i); if (isClass(_config)) then { //filter: _type = getText (_config >> "type"); //if (((getText (_config >> "type")) != "Body1") and ((getText (_config >> "type")) != "Body2")) then { _position = [] + getArray (_config >> "position"); _dir = getNumber (_config >> "direction"); _onFire = getNumber (_config >> "onFire"); _object = _type createVehicle _position; _object setPos _position; _object setDir _dir; _object allowDamage false; //diag_log format["CreateObj: %1 / %2",_type,_position]; /* if (_onFire > 0) then { nul=[_object,_onFire,time,false,false] spawn BIS_Effects_Burn; }; */ //}; }; sleep 0.1; // for longer load, but better startup performance }; //sleep 0.5; //comment the other sleep and uncomment this for faster load but slower startup performance diag_log ("Creating Objects: " + str(_configBase)); }; //diag_log ("Spawning all loot."); _id = [] call server_permaLootInit; };
add it to server_functions
Code:server_fillLocs = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_fillLocs.sqf";
Remove it from the server_fillLocs.sqf that we just made? If so, is it spawning itself (spawn server_fillLocs)?
remove "_id = [] call server_permaLootInit;" from server_monitor from above post, and replace it with
Code:_id = [] spawn server_fillLocs;
Have fun, it's been pretty entertaining so far having to actually go from town to town to get supplies.
Weird, the server monitor should be there if nothing changed recently, especially since it's referenced in your server_init. The helicrash code in init is just the function that gets called in the monitor to actually spawn them, so the code never got executed when you put it there.
What method of pbo extraction do you use? I had issues with some files not extracting with one of the tools out there (not sure which, may have been cpbo), so would try using another tool. I'm using a command-line tool called extractpbo.
With the Bliss manual install, it creates the dayz_server.pbo during installation. So, I'm not sure what to do about that. What server version are you running (bliss, Pwnoz0r's, etc.)?
Thanks for all of your help, isathar!I'm also using bliss. Take a look in the bliss install folder under (folder)/util/dayz_server/