Jump to content

DayZ Epoch Server add custom loot crate


Adaaam95

Recommended Posts

Hello,

I'm very new to scripting and I've been trying to get this to work for a while now. I recently got my first dayz epoch server up and running and I've started to customize the map and add new buildings etc. I'm trying to add a custom loot crate to my server which spawns a set list of items from an array or whatever but I can't seem to find a way to get it to work. All of the tutorials and posts about it I've seen are outdated or they are just too confusing to follow. I just want a simple guide on where I need to put each line of code in order to get this to work. I have WAI on my server which I think is for AI missions and apparently you can edit the config files to spawn custom loot crates but I'm really not sure.

If someone could help me out that would be great

Thanks,

Adam

 

Link to comment
Share on other sites

if (isServer) then {


		_vehicle_999999 = objNull;
		
		if (true) then
		{
		  _this = createVehicle ["TKVehicleBox_EP1", [16434.813,18326.1,4.5776367e-005], [], 0, "CAN_COLLIDE"];
		  _vehicle_999999 = _this;
		  _this setDir 20;
		  _vehicle_999999 setVariable ["ObjectID","1",true];
          _vehicle_999999 setVariable ["permaLoot",true];

		  clearWeaponCargoGlobal _this;
		  clearMagazineCargoGlobal _this;

		  
		  _this addMagazineCargoGlobal ["ItemBriefcase100oz",10];
		};
};

Change this for the co-ords of where you want your box to spawn : [16434.813,18326.1,4.5776367e-005]

Change this to whatever type of box you want : "TKVehicleBox_EP1"

Change this to alter what spawns in the box :  _this addMagazineCargoGlobal ["ItemBriefcase100oz",10];

You can add more lines for more items : 

_this addMagazineCargoGlobal ["ItemBriefcase100oz",10];

_this addMagazineCargoGlobal ["ItemBriefcase100oz",10];

_this addMagazineCargoGlobal ["ItemBriefcase100oz",10];

_this addMagazineCargoGlobal ["ItemBriefcase100oz",10];

If it's a weapon, you'll need to change addMagazineCargoGlobal to addWeaponCargoGlobal

Save that whole thing as lootbox.sqf (or whatever you like)

Stick it in a "custom" folder in the server.pbo and add this line to the bottom of your server_monitor.sqf (above publicVariable "sm_done";) to spawn it :     [] ExecVM "\z\addons\dayz_server\custom\lootbox.sqf";

Link to comment
Share on other sites

  • 1 year later...
On 2/11/2016 at 9:14 AM, ElDubya said:

if (isServer) then {


		_vehicle_999999 = objNull;
		
		if (true) then
		{
		  _this = createVehicle ["TKVehicleBox_EP1", [16434.813,18326.1,4.5776367e-005], [], 0, "CAN_COLLIDE"];
		  _vehicle_999999 = _this;
		  _this setDir 20;
		  _vehicle_999999 setVariable ["ObjectID","1",true];
          _vehicle_999999 setVariable ["permaLoot",true];

		  clearWeaponCargoGlobal _this;
		  clearMagazineCargoGlobal _this;

		  
		  _this addMagazineCargoGlobal ["ItemBriefcase100oz",10];
		};
};

Change this for the co-ords of where you want your box to spawn : [16434.813,18326.1,4.5776367e-005]

Change this to whatever type of box you want : "TKVehicleBox_EP1"

Change this to alter what spawns in the box :  _this addMagazineCargoGlobal ["ItemBriefcase100oz",10];

You can add more lines for more items : 

_this addMagazineCargoGlobal ["ItemBriefcase100oz",10];

_this addMagazineCargoGlobal ["ItemBriefcase100oz",10];

_this addMagazineCargoGlobal ["ItemBriefcase100oz",10];

_this addMagazineCargoGlobal ["ItemBriefcase100oz",10];

If it's a weapon, you'll need to change addMagazineCargoGlobal to addWeaponCargoGlobal

Save that whole thing as lootbox.sqf (or whatever you like)

Stick it in a "custom" folder in the server.pbo and add this line to the bottom of your server_monitor.sqf (above publicVariable "sm_done";) to spawn it :     [] ExecVM "\z\addons\dayz_server\custom\lootbox.sqf";

I wonder if its working for 1.0.6.1? 

 

I had something that I was able to put a couple marker so box spawn different place each restart but I don't find it and I don't remember how to do it, can we do that with the one you use? And how?

Link to comment
Share on other sites

1 hour ago, lwbuk said:

There is dzai hotspots which puts a certain number of markers on the map and one of the markers has a loot box guarded by ai. 

Works fine on 1061, just edit the config files to reflect any class name changes. 

Well DZMS hot spot. 

I don't wanna use that, I want a crate in my bandit town that will change position every restart. I had something before but I can't find it anymore.

Link to comment
Share on other sites

7 hours ago, Petite said:

Well DZMS hot spot. 

I don't wanna use that, I want a crate in my bandit town that will change position every restart. I had something before but I can't find it anymore.

do you wanna spawn a crate into a bandit town? in diferents locations after each server restar, but allways into the area of this bandit town?

if is it.. first you will need define some coords to mark the center of this bandit town.. for example

Spoiler

_positionArray=[
[1677.587, 7417.2876],
[1682.7095, 7416.1377],
[1638.1494, 7402.5869, 0],
[1614.4928, 7447.8296, -0.032172654],
[1688.9667, 7443.4146, 0],
[1672.4465, 7364.9146, -9.1552734e-005]
];
//////All cords from above are defined in a same area.

_pos= floor random count _positionArray;
_position = _positionArray select _pos;

_crate = createVehicle ["USBasicWeapons_EP1", _position, [], 0, "CAN_COLLIDE"];
clearWeaponCargoGlobal _crate;
clearMagazineCargoGlobal _crate;  

//define the loot insiide
_loot_on_crate = [
[
["ChainSaw"],
["equip_herb_box","transfusionKit","bloodTester"]
],

[
["Revolver_DZ"],
["6Rnd_45ACP","Skin_Soldier_Bodyguard_AA12_PMC_DZ","ItemMixOil","ItemComboLock","ItemFuelcan","ItemAntibacterialWipe"]
]
];
_loot = _loot_on_crate call BIS_fnc_selectRandom;  


// Add loot to the crate
{
_crate addWeaponCargoGlobal [_x,1];
} forEach (_loot select 0);
{
_crate addMagazineCargoGlobal [_x,1];
} forEach (_loot select 1);

 

 

but if u wanna spawn this crate in some random location around the map then i guess u can use the sytax of epoch events

Spoiler



_spawnR = 5000;
_spawnM = 'center';

_position = [getMarkerPos "center",0,5500,10,0,2000,0] call BIS_fnc_findSafePos;
_positionarray = [
[(_position select 0) - 14.5, (_position select 1) - 21,-0.012],
[(_position select 0) - 20, (_position select 1) - 20,-0.012],
[(_position select 0) + 25, (_position select 1) + 5,-0.012],
[(_position select 0) + 16, (_position select 1) - 14,-0.012],
[(_position select 0) + 49, (_position select 1) + 17.5,-0.012],
[(_position select 0) + 38.5, (_position select 1) - 16,-0.012]
];
_mainpos = _positionarray call BIS_fnc_selectRandom;



// Create ammo box
_box = createVehicle ["USBasicWeapons_EP1",_mainpos,[], 0, "NONE"];
clearMagazineCargoGlobal _box;
clearWeaponCargoGlobal _box;


//define the loot insiide
_loot_on_crate = [
[
["ChainSaw"],
["equip_herb_box","transfusionKit","bloodTester"]
],

[
["Revolver_DZ"],
["6Rnd_45ACP","Skin_Soldier_Bodyguard_AA12_PMC_DZ","ItemMixOil","ItemComboLock","ItemFuelcan","ItemAntibacterialWipe"]
]
];
_loot = _loot_on_crate call BIS_fnc_selectRandom;  
_loot2 = _loot_on_crate call BIS_fnc_selectRandom;  


// Add loot
{
_box addWeaponCargoGlobal [_x,1];
} forEach (_loot select 0);
{
_box addMagazineCargoGlobal [_x,1];
} forEach (_loot select 1);
{
_box addWeaponCargoGlobal [_x,1];
} forEach (_loot2 select 0);
{
_box addMagazineCargoGlobal [_x,1];
} forEach (_loot2 select 1);
 

 

 

Link to comment
Share on other sites

1 minute ago, juandayz said:

do you wanna spawn a crate into a bandit town? in diferents locations after each server restar, but allways into the area of this bandit town?

if is it.. first you will need define some coords to mark the center of this bandit town.. for example

  Hide contents


_positionArray=[
[1677.587, 7417.2876],
[1682.7095, 7416.1377],
[1638.1494, 7402.5869, 0],
[1614.4928, 7447.8296, -0.032172654],
[1688.9667, 7443.4146, 0],
[1672.4465, 7364.9146, -9.1552734e-005]
];
//////All cords from above are defined in a same area.

_pos= floor random count _positionArray;
_position = _positionArray select _pos;

_crate = createVehicle ["USBasicWeapons_EP1", _position, [], 0, "CAN_COLLIDE"];
clearWeaponCargoGlobal _crate;
clearMagazineCargoGlobal _crate;  

//define the loot insiide
_loot_on_crate = [
[
["ChainSaw"],
["equip_herb_box","transfusionKit","bloodTester"]
],

[
["Revolver_DZ"],
["6Rnd_45ACP","Skin_Soldier_Bodyguard_AA12_PMC_DZ","ItemMixOil","ItemComboLock","ItemFuelcan","ItemAntibacterialWipe"]
]
];
_loot = _loot_on_crate call BIS_fnc_selectRandom;  


// Add loot to the crate
{
_crate addWeaponCargoGlobal [_x,1];
} forEach (_loot select 0);
{
_crate addMagazineCargoGlobal [_x,1];
} forEach (_loot select 1);

 

 

but if u wanna spawn this crate in some random location around the map then i guess u can use the sytax of epoch events

  Reveal hidden contents




_spawnR = 5000;
_spawnM = 'center';

_position = [getMarkerPos "center",0,5500,10,0,2000,0] call BIS_fnc_findSafePos;
_positionarray = [
[(_position select 0) - 14.5, (_position select 1) - 21,-0.012],
[(_position select 0) - 20, (_position select 1) - 20,-0.012],
[(_position select 0) + 25, (_position select 1) + 5,-0.012],
[(_position select 0) + 16, (_position select 1) - 14,-0.012],
[(_position select 0) + 49, (_position select 1) + 17.5,-0.012],
[(_position select 0) + 38.5, (_position select 1) - 16,-0.012]
];
_mainpos = _positionarray call BIS_fnc_selectRandom;



// Create ammo box
_box = createVehicle ["USBasicWeapons_EP1",_mainpos,[], 0, "NONE"];
clearMagazineCargoGlobal _box;
clearWeaponCargoGlobal _box;


//define the loot insiide
_loot_on_crate = [
[
["ChainSaw"],
["equip_herb_box","transfusionKit","bloodTester"]
],

[
["Revolver_DZ"],
["6Rnd_45ACP","Skin_Soldier_Bodyguard_AA12_PMC_DZ","ItemMixOil","ItemComboLock","ItemFuelcan","ItemAntibacterialWipe"]
]
];
_loot = _loot_on_crate call BIS_fnc_selectRandom;  
_loot2 = _loot_on_crate call BIS_fnc_selectRandom;  


// Add loot
{
_box addWeaponCargoGlobal [_x,1];
} forEach (_loot select 0);
{
_box addMagazineCargoGlobal [_x,1];
} forEach (_loot select 1);
{
_box addWeaponCargoGlobal [_x,1];
} forEach (_loot2 select 0);
{
_box addMagazineCargoGlobal [_x,1];
} forEach (_loot2 select 1);
 

 

 

Yes i only want it in the bandit town but in different place. I already have my coords. Where do I put that, I'm gonna give a try?

Link to comment
Share on other sites

4 minutes ago, Petite said:

Yes i only want it in the bandit town but in different place. I already have my coords. Where do I put that, I'm gonna give a try?

use this code

Spoiler

_positionArray=[
[1677.587, 7417.2876],
[1682.7095, 7416.1377],
[1638.1494, 7402.5869, 0],
[1614.4928, 7447.8296, -0.032172654],
[1688.9667, 7443.4146, 0],
[1672.4465, 7364.9146, -9.1552734e-005]
];
//////All cords from above are defined in a same area.

_pos= floor random count _positionArray;
_position = _positionArray select _pos;

_crate = createVehicle ["USBasicWeapons_EP1", _position, [], 0, "CAN_COLLIDE"];
clearWeaponCargoGlobal _crate;
clearMagazineCargoGlobal _crate;  

//define the loot insiide
_loot_on_crate = [
[
["ChainSaw"],
["equip_herb_box","transfusionKit","bloodTester"]
],

[
["Revolver_DZ"],
["6Rnd_45ACP","Skin_Soldier_Bodyguard_AA12_PMC_DZ","ItemMixOil","ItemComboLock","ItemFuelcan","ItemAntibacterialWipe"]
]
];
_loot = _loot_on_crate call BIS_fnc_selectRandom;  


// Add loot to the crate
{
_crate addWeaponCargoGlobal [_x,1];
} forEach (_loot select 0);
{
_crate addMagazineCargoGlobal [_x,1];
} forEach (_loot select 1);

 

and put your coords here:

_positionArray=[
[1677.587, 7417.2876],
[1682.7095, 7416.1377],
[1638.1494, 7402.5869, 0],
[1614.4928, 7447.8296, -0.032172654],
[1688.9667, 7443.4146, 0],
[1672.4465, 7364.9146, -9.1552734e-005]
];

 

Link to comment
Share on other sites

1 minute ago, juandayz said:

use this code

  Hide contents


_positionArray=[
[1677.587, 7417.2876],
[1682.7095, 7416.1377],
[1638.1494, 7402.5869, 0],
[1614.4928, 7447.8296, -0.032172654],
[1688.9667, 7443.4146, 0],
[1672.4465, 7364.9146, -9.1552734e-005]
];
//////All cords from above are defined in a same area.

_pos= floor random count _positionArray;
_position = _positionArray select _pos;

_crate = createVehicle ["USBasicWeapons_EP1", _position, [], 0, "CAN_COLLIDE"];
clearWeaponCargoGlobal _crate;
clearMagazineCargoGlobal _crate;  

//define the loot insiide
_loot_on_crate = [
[
["ChainSaw"],
["equip_herb_box","transfusionKit","bloodTester"]
],

[
["Revolver_DZ"],
["6Rnd_45ACP","Skin_Soldier_Bodyguard_AA12_PMC_DZ","ItemMixOil","ItemComboLock","ItemFuelcan","ItemAntibacterialWipe"]
]
];
_loot = _loot_on_crate call BIS_fnc_selectRandom;  


// Add loot to the crate
{
_crate addWeaponCargoGlobal [_x,1];
} forEach (_loot select 0);
{
_crate addMagazineCargoGlobal [_x,1];
} forEach (_loot select 1);

 

and put your coords here:


_positionArray=[
[1677.587, 7417.2876],
[1682.7095, 7416.1377],
[1638.1494, 7402.5869, 0],
[1614.4928, 7447.8296, -0.032172654],
[1688.9667, 7443.4146, 0],
[1672.4465, 7364.9146, -9.1552734e-005]
];

 

Thanks I will give it a try.

Link to comment
Share on other sites

12 minutes ago, Petite said:

Thanks I will give it a try.

And if u wanna have control over the time when the crate spawn and send msg to the players.. you can do the following.

use this code with your own coords

spanwcrate.sqf  (mpmissions\your instance\custom\)

Spoiler

fn_spawn {
_usemarker = true; //spawn marker in crate position
_delmarker = 600; //time in seconds to despawn the marker
_positionArray=[
[1677.587, 7417.2876],
[1682.7095, 7416.1377],
[1638.1494, 7402.5869, 0],
[1614.4928, 7447.8296, -0.032172654],
[1688.9667, 7443.4146, 0],
[1672.4465, 7364.9146, -9.1552734e-005]
];
//////All cords from above are defined in a same area.

_pos= floor random count _positionArray;
_position = _positionArray select _pos;

_crate = createVehicle ["USBasicWeapons_EP1", _position, [], 0, "CAN_COLLIDE"];
clearWeaponCargoGlobal _crate;
clearMagazineCargoGlobal _crate;  

//define the loot insiide
_loot_on_crate = [
[
["ChainSaw"],
["equip_herb_box","transfusionKit","bloodTester"]
],

[
["Revolver_DZ"],
["6Rnd_45ACP","Skin_Soldier_Bodyguard_AA12_PMC_DZ","ItemMixOil","ItemComboLock","ItemFuelcan","ItemAntibacterialWipe"]
]
];
_loot = _loot_on_crate call BIS_fnc_selectRandom;  


// Add loot to the crate
{
_crate addWeaponCargoGlobal [_x,1];
} forEach (_loot select 0);
{
_crate addMagazineCargoGlobal [_x,1];
} forEach (_loot select 1);
//spawn marker if _usemarker is set as true in the very top
if (_usemarker) then {
_precisemarker_marker = createMarker ["BanditTownCrate",_position];
_precisemarker_marker setMarkerText "BanditTownCrate";
_precisemarker_marker setMarkerShape "ICON";
_precisemarker_marker setMarkerType "Strongpoint";
_precisemarker_marker setMarkerColor "ColorRed";
_precisemarker_marker setMarkerAlpha 1;
_precisemarker_marker setMarkerSize [0.5,0.5];
sleep _delmarker;
deleteMarker _precisemarker_marker;
};
};

///Define the time after server restart when the crate gonna spawn
waituntil {(round(time)) > 200};
if (time > 200) then {
call fn_spawn;
 [nil,nil,rTitleText,"New Crate in Bandit Town", "PLAIN",10] call RE; 
};   
waituntil {(round(time)) > 1000};
if (time > 1000) then {
call fn_spawn;
[nil,nil,rTitleText,"New Crate in Bandit Town", "PLAIN",10] call RE; 
    };   
//Add more times if u want

 

now open your init.sqf

find:

call compile preprocessFileLineNumbers "\z\addons\dayz_server\system\server_monitor.sqf";

below paste:

//customcrate
_spawncrate = [] execVM "custom\spawncrate.sqf";
//
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Discord

×
×
  • Create New...