Construction-Packages for DayZ+

Grafzahl

Valued Member!
I gues nearly every DayZ+ Serverowner knows this: Big Bases are only build because of duping the shit out of every material... i think this kind of sucks. We had to ban the half server because of this.

So i thought about finding away to give the players some kind of "Construction-Package", which spawn like random helicrashs, like the carepackages on namalsk.

I did, and it works great... Clans can now search for these Packages like they search for helicrashs... its a cargo-net container which has all the building-materials around it it. Sandbags, Netting-Materials, Scrapmetal, Wire-Fencing, Woot.

Here a short howto:
Unpack your dayz_server.pbo.
Create a new file in the compile-folder, named server_construction_ckg_dzn.sqf

Put this Code into the file:
Code:
private["_position","_veh","_num","_config","_itemType","_itemChance","_weights","_index","_iArray"];
 
waitUntil{!isNil "BIS_fnc_selectRandom"};
if (isDedicated) then {
    _position = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos;
    diag_log("DEBUG: Spawning a construction package at " + str(_position));
    _veh = createVehicle ["Misc_cargo_cont_net1",_position, [], 0, "CAN_COLLIDE"];
    dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_veh];
    _veh setVariable ["ObjectID",1,true];
   
    _num = rand(10)+4;
    _itemType =
        [["PartGeneric","magazine"],
        ["ItemSandbag","magazine"],
        ["ItemWire","magazine"],
        ["Skin_Net_DZ","magazine"],
        ["PartWoodPile","magazine"]];   
    _itemChance =
        [0.01,
        0.01,
        0.01,
        0.01,
        0.01];
   
    waituntil {!isnil "fnc_buildWeightedArray"};
   
    _weights = [];
    _weights =        [_itemType,_itemChance] call fnc_buildWeightedArray;
    //diag_log ("DW_DEBUG: _weights: " + str(_weights));   
    for "_x" from 1 to _num do {
        //create loot
        _index = _weights call BIS_fnc_selectRandom;
        sleep 1;
        if (count _itemType > _index) then {
            //diag_log ("DW_DEBUG: " + str(count (_itemType)) + " select " + str(_index));
            _iArray = _itemType select _index;
            _iArray set [2,_position];
            _iArray set [3,5];
            _iArray call spawn_loot;
            _nearby = _position nearObjects ["WeaponHolder",20];
            {
                _x setVariable ["permaLoot",true];
            } forEach _nearBy;
        };
    };
};

_num says how many loot-piles should be build around the container, in this case, it could be something between 4(minimum) and 14 (10 random + 4fixed) items.

_itemType and _itemChance are the classnames and the spawnchance of each spawnable item. In this case every item has the same chance of spawning in.

Next go to init/server_functions.sqf, search for this line...
Code:
server_updateNearbyObjects =    compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_updateNearbyObjects.sqf";
Create a new line under it with this content:
Code:
server_construction_ckg_dzn =            compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_construction_ckg_dzn.sqf";
Now open system/server_monitor.sqf and add this code at the bottom of the file
Code:
for "_x" from 1 to 6 do {
 
    _id = [] spawn server_construction_ckg_dzn;
 
};
In this case this will spawn 6 random packages, just change the number as you want...

Repack your PBO and exchange it...

Sorry for my bad english, hope this still helps anyone... i gues thats a better solution for getting stuff then allowing duping or lootpiling.
 
There seems to be a syntax error with this when we try it on our server, any input on this? It seems to be coded correctly, but still comes up with a syntax error
 
This is the error we are getting.


Code:
12:52:37 Error in expression <riable ["ObjectID",1,true];
 
_num = rand(10)+4;
_itemType =
[["PartGeneric","mag>
12:52:37  Error position: <(10)+4;
_itemType =
[["PartGeneric","mag>
12:52:37  Error Missing ;
12:52:37 File z\addons\dayz_server\compile\server_construction_ckg_dzn.sqf, line 11
12:52:37 Error in expression <riable ["ObjectID",1,true];
 
_num = rand(10)+4;
_itemType =
[["PartGeneric","mag>
12:52:37  Error position: <(10)+4;
_itemType =
[["PartGeneric","mag>
12:52:37  Error Missing ;
12:52:37 File z\addons\dayz_server\compile\server_construction_ckg_dzn.sqf, line 11
 
Very Strange, are you sure you copied this 1:1? Tried the code again on my server, no problems at all...

Anyone else is getting a syntax error?
 
Is there a github or something up that has the construction file already created? I don't know if it's a formatting issue through copy and pasting the code from here.
 
usually you floor a random variable.

another note:

BIS_fnc_selectRandom
is buggy. I recommend to write your own :)
 
Back
Top