Jump to content
  • 0

Filling ammo box with array


chi

Question

I was wondering if there was a simpler way to add a certain number of items to this array by actually using a number, and not having to repeat the item so many times.

 

Spoiler

                _loot_lists = [
[
["M9SD"],
["15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","ItemWoodStairs","ItemWoodStairs","ItemWoodStairs","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks","MortarBucket","CinderBlocks"]
],
[
["M9SD"],
["15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","ItemWoodStairs","ItemWoodStairs","ItemWoodStairs","ItemWoodStairs","PartPlankPack","PartPlywoodPack","PartPlankPack","PartPlywoodPack","PartPlankPack","PartPlywoodPack","PartPlankPack","PartPlywoodPack","PartPlankPack","PartPlywoodPack","PartPlankPack","PartPlywoodPack","PartPlankPack","PartPlywoodPack","PartPlankPack","PartPlywoodPack","PartPlankPack","PartPlywoodPack","PartPlankPack","PartPlywoodPack","PartPlankPack","PartPlywoodPack","PartPlankPack","PartPlywoodPack","PartPlankPack","PartPlywoodPack","PartPlankPack","PartPlywoodPack","PartPlankPack","PartPlywoodPack","PartPlankPack","PartPlywoodPack","PartPlankPack","PartPlywoodPack","PartPlankPack","PartPlywoodPack","PartPlankPack","PartPlywoodPack","PartPlankPack","PartPlywoodPack","PartPlankPack","PartPlywoodPack"]
],
[
["M9SD"],
["15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor"]
],
[
["M9SD"],
["15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor"]
],
[
["M9SD"],
["15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","outhouse_kit","outhouse_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit"]
],
[
["M9SD"],
["15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","outhouse_kit","outhouse_kit","ItemWoodStairs","ItemWoodStairs","ItemWoodStairs","ItemWoodStairs","workbench_kit","ItemComboLock","ItemComboLock","ItemWoodWallLg","ItemWoodWallGarageDoor","ItemWoodWallWindowLg","ItemWoodWallLg","ItemWoodWallLg","ItemWoodWallLg"]
],
[
["M9SD"],
["15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","ItemWoodStairs","ItemWoodStairs","ItemWoodStairs","ItemWoodStairs","workbench_kit","ItemComboLock","ItemComboLock","ItemWoodWallLg","ItemWoodWallGarageDoor","ItemWoodWallWindowLg","ItemWoodWallLg","ItemWoodWallLg","ItemWoodWallLg"]
],
[
["M9SD"],
["15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","PartGeneric","metal_floor_kit","PartGeneric","metal_floor_kit","PartGeneric","metal_floor_kit","PartGeneric","metal_floor_kit","PartGeneric","metal_floor_kit","PartGeneric","metal_floor_kit","PartGeneric","metal_floor_kit","PartGeneric","metal_floor_kit","PartGeneric","metal_floor_kit","PartGeneric","metal_floor_kit","PartGeneric","metal_floor_kit","Itemvault"]
],
[
["M9SD"],
["15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","ItemWoodWallGarageDoor","ItemWoodWallWindowLg","ItemWoodWallLg","ItemWoodWallLg","ItemWoodWallLg","ItemWoodWallGarageDoor","ItemWoodWallWindowLg","ItemWoodWallLg","ItemWoodWallLg","ItemWoodWallLg","ItemWoodWallGarageDoor","ItemWoodWallWindowLg","ItemWoodWallLg","ItemWoodWallLg","ItemWoodWallLg","ItemWoodWallGarageDoor","ItemWoodWallWindowLg"]
],
[
["M9SD"],
["15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","workbench_kit","Itemvault","cinder_wall_kit","ItemComboLock","ItemComboLock","cinder_garage_kit","cinder_garage_kit","cinder_door_kit","cinder_door_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit","cinder_wall_kit"]
],
[
["M9SD"],
["15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","workbench_kit","ItemWoodStairs","ItemWoodStairs","ItemWoodStairs","wood_shack_kit","wood_shack_kit","wood_shack_kit","deer_stand_kit","deer_stand_kit","ItemWoodLadder","ItemWoodLadder","desert_net_kit","desert_net_kit","ItemWoodLadder","ItemWoodLadder","desert_net_kit","forest_net_kit","forest_net_kit","forest_net_kit","desert_net_kit","desert_net_kit","ItemSandbagLarge","ItemSandbagLarge","Itemvault","Itemvault"]
]
];
_loot = _loot_lists call BIS_fnc_selectRandom;

Thanks to whoever can help me out here.

Link to comment
Share on other sites

14 answers to this question

Recommended Posts

  • 0

here thers an example:

Spoiler

_distance = 500;
_boxtype = "USVehicleBox_EP1";
_unit = player;
_getPos = getPos _unit;
_position = [_getPos select 0, _getPos select 1, 25];
_box = _boxtype createVehicle _position;
_box setVariable ["Mission",1,true];
_box setVariable ["permaLoot",1,true];
_box setVariable ["ObjectID",""];
_chute = createVehicle ["ParachuteMediumEast", getPos _box, [], 0, "FLY"];
_box attachTo [_chute, [0,0,3]];
_smoke = "SmokeShellBlue" createVehicle (getPos _box);
_smoke attachTo [_box, [0,0,0]];
_var = floor((random 2) + 1);

 

//display text to alert user
_textt = format ["\nPackage from air!",10];
titleText [_textt,"PLAIN DOWN"];

//define items

_tools = ["ItemEtool","ItemKnife","ItemFishingPole","ItemHatchet_DZE","ItemMatchbox_DZE","ItemCrowbar"];
_items = ["ItemSodaPepsi","ItemMorphine","FoodNutmix","ItemBloodbag","FoodCanSardines","ItemKiloHemp"];


//weapon lists
_weapon = "DMR";
_weapon2 = "AK_47_M";
_weapon3 = "BAF_L85A2_RIS_Holo";
_weapon4 = "RPK_74";
_weapon5 = "M14_EP1";
_weapon6 = "M249_DZ";
_giveWep = [_weapon,_weapon2,_weapon3,_weapon4,_weapon5,_weapon6] call BIS_fnc_selectRandom;
_possibleMags = getArray (configfile >> "cfgWeapons" >> _giveWep >> "magazines");
_mag = _possibleMags select 0;

//select arrays to use
_crateItems = [_items] call BIS_fnc_selectRandom;
uisleep 1;

clearweaponcargoglobal _box;
clearmagazinecargoglobal _box;

uisleep 1;

{_box addMagazineCargoGlobal [_x, _var];} forEach _crateItems;
{_box addWeaponCargoGlobal [_x, 1];} forEach _tools;
_box addMagazineCargoGlobal [_mag, _var];
_box addWeaponCargoGlobal [_giveWep, 1];

uisleep 1;

waitUntil {(player distance _box) > _distance};
deleteVehicle _box;
deleteVehicle _chute;

 

Link to comment
Share on other sites

  • 0

Thats awesome. Thanks for the reply.

I was hoping for something like

[M9sd,1]

[[Cinderwall,4],[mortarbucket,1]] etc.

Excuse my coding ignorance, lol. Just trying to learn a little something.

Thanks again for the reply juandayz.

Link to comment
Share on other sites

  • 0
_loot_build = ["MortarBucket","MortarBucket","ItemCorrugated","ItemCorrugated","ItemCorrugatedLg","CinderBlocks","jerrycan_epoch","VehicleRepairLg","VehicleRepair","CircuitParts","ItemScraps","ItemScraps","KitShelf","KitWoodFloor","KitWoodStairs"];
_this addMagazineCargoGlobal [(_loot_build call BIS_fnc_selectRandom),(10 + floor(random 2))];

try it.

Link to comment
Share on other sites

  • 0

So...

I've learned a lot about spawning items just from this thread, but just to get on your nerves a little more.....

Spoiler

                _loot_lists = 
[

[["M9SD"],["15Rnd_9x19_M9SD",2],["ItemWoodStairs",2]]

];
                
_loot = _loot_lists call BIS_fnc_selectRandom;
                {
                _SupplyBox addWeaponCargoGlobal [_x,1];
                } forEach (_loot select 0);
                {
                _SupplyBox addMagazineCargoGlobal [_x,1];
                } forEach (_loot select 1);

 

This is something like i want, but of course this doesn't work. It only spawns the weapon, and then only 1 of whichever magazine it picks.

 

Of course I would want more than one array for it to pick from also. Maybe like this??

Spoiler

                _loot_lists = 
[

[["M9SD"],["15Rnd_9x19_M9SD",2],["ItemWoodStairs",2]],
[["ItemSledge"],["MortarBucket",4],["Cinderblocks",8]]

];
                
_loot = _loot_lists call BIS_fnc_selectRandom;
                {
                _SupplyBox addWeaponCargoGlobal [_x,1];
                } forEach (_loot select 0);
                {
                _SupplyBox addMagazineCargoGlobal [_x,1];
                } forEach (_loot select 1);

 

Can you help me to get this to work? Or is it possible.

 

I want it this way so that the boxes will spawn "packages". Like maybe building stuff one time, and rare weapons and ammo the next.

 

Thanks in advance.

Link to comment
Share on other sites

  • 0

 

example crate

Spoiler

if (isServer) then {
///##VARIABLES##//
_positionArray=[[1677.587, 7417.2876],[1682.7095, 7416.1377]];// Chi ,use your own coords here
_pos= floor random count _positionArray;//this gonna make a random on your coords and pick one
_position = _positionArray select _pos;

_cratemodels=["USBasicWeapons_EP1","LocalBasicAmmunitionBox"] call BIS_fnc_selectRandom; //Add any other kind of crates ids

//bellow put your items id. ///structure: _variable_name ["","","",""];


_items = ["bulk_ItemWire","ItemBriefcase100oz"]; 
_tools = ["ItemToolbox","ItemGPS"];//add any other kind of tools// toolbelt items is taked as weapons so when you fill the crate needs use addWeaponCargoGlobal
_weapons = ["M24_des_EP1","M14_EP1","M14_EP1"];//add more weapons if u want
_backpacks = ["DZ_GunBag_EP1","DZ_British_ACU"];//add more backpacks ids  

//add more variables for items if you want just take care items with items weapons with weapons. ["M24_des_EP1","bulk_ItemWire"];WRONG!//////["M24_des_EP1","ItemGPS"];FINE!!


//this spawn the box

 _crate1 = objNull;
             if (true) then {
                _this = createVehicle [_cratemodels, _position, [], 0, "CAN_COLLIDE"]; //here your saying  _this = create a box using random _cratemodels in random _positions
                _crate1 = _this;// for now on your name box is _crate1
				_crate1 setVariable ["permaLoot",true];//to prevent  lost content of box after an x time
				
				 clearWeaponCargoGlobal _crate1; //deleting all default weapon content of the box (_crate1)
                 clearMagazineCargoGlobal _crate1;  //same of above but this del ammo and items
				 clearBackpackCargoGlobal _crate1; //delete backpacks if crate have for default
				 
				 //FILLING THE CRATE///
				 ///STRUCTURE: _name_of_box /the add function for specific class items/ [(_item array name defined in variables section//call Randomly _item array),(10=ammount of items to make the random + floor(random _Numer of items to add))]  
				 
				 
				_crate1 addMagazineCargoGlobal [(_items call BIS_fnc_selectRandom),(8 + floor(random 6))];
				_crate1 addWeaponCargoGlobal [(tools call BIS_fnc_selectRandom),(10 + floor(random 3))];
				_crate1 addWeaponCargoGlobal [(_weapons call BIS_fnc_selectRandom),(2 + floor(random 5))];
				_crate1  addBackpackCargoGlobal [(_backpacks call BIS_fnc_selectRandom),(10 + floor(random 2))];
				
				/////////////////ADD MORE FILLS IF U WANT
				_crate1 addMagazineCargoGlobal [(_items call BIS_fnc_selectRandom),(10 + floor(random 2))];
				_crate1 addMagazineCargoGlobal [(_items call BIS_fnc_selectRandom),(10 + floor(random 2))];
				
				
				};//END OF CRATE
};

 

if u need delete the crate after x time add at bottom after END OF CRATE

sleep 180; //tiime in seconds 180/60 = 3 minutes  this gonna  sleep 3 minutes and then run the code bellow

deleteVehicle _crate1; 

Also you can delete it by player vs distance of this box

//define another vriable

_distance = 50; //mts

waitUntil {(player distance _crate1) > _distance};
deleteVehicle _crate1;

Or using server time:

waituntil {(round(time)) > 300};

if (time > 300) then {

deleteVehicle _crate1;

   [nil,nil,rTitleText,"_crate1 was removed", "PLAIN",10] call RE; //text format for all players

   //titleText [" _crate1 was removed ", "PLAIN DOWN"];titleFadeOut 5;// Text format only for player who spawn the box

//[format["<t align='center' size='0.75' color='#ff5200'>%1 _crate1 was removed.</t>",(name player)],0,0,2,2]spawn

BIS_fnc_dynamicText; //text format only for who spawn the box but more beauty :D with colors and sizes

};

 

 

 

Link to comment
Share on other sites

  • 0
12 hours ago, juandayz said:

 

example crate

  Hide contents


if (isServer) then {
///##VARIABLES##//
_positionArray=[[1677.587, 7417.2876],[1682.7095, 7416.1377]];// Chi ,use your own coords here
_pos= floor random count _positionArray;//this gonna make a random on your coords and pick one
_position = _positionArray select _pos;

_cratemodels=["USBasicWeapons_EP1","LocalBasicAmmunitionBox"] call BIS_fnc_selectRandom; //Add any other kind of crates ids

//bellow put your items id. ///structure: _variable_name ["","","",""];


_items = ["bulk_ItemWire","ItemBriefcase100oz"]; 
_tools = ["ItemToolbox","ItemGPS"];//add any other kind of tools// toolbelt items is taked as weapons so when you fill the crate needs use addWeaponCargoGlobal
_weapons = ["M24_des_EP1","M14_EP1","M14_EP1"];//add more weapons if u want
_backpacks = ["DZ_GunBag_EP1","DZ_British_ACU"];//add more backpacks ids  

//add more variables for items if you want just take care items with items weapons with weapons. ["M24_des_EP1","bulk_ItemWire"];WRONG!//////["M24_des_EP1","ItemGPS"];FINE!!


//this spawn the box

 _crate1 = objNull;
             if (true) then {
                _this = createVehicle [_cratemodels, _position, [], 0, "CAN_COLLIDE"]; //here your saying  _this = create a box using random _cratemodels in random _positions
                _crate1 = _this;// for now on your name box is _crate1
				_crate1 setVariable ["permaLoot",true];//to prevent  lost content of box after an x time
				
				 clearWeaponCargoGlobal _crate1; //deleting all default weapon content of the box (_crate1)
                 clearMagazineCargoGlobal _crate1;  //same of above but this del ammo and items
				 clearBackpackCargoGlobal _crate1; //delete backpacks if crate have for default
				 
				 //FILLING THE CRATE///
				 ///STRUCTURE: _name_of_box /the add function for specific class items/ [(_item array name defined in variables section//call Randomly _item array),(10=ammount of items to make the random + floor(random _Numer of items to add))]  
				 
				 
				_crate1 addMagazineCargoGlobal [(_items call BIS_fnc_selectRandom),(8 + floor(random 6))];
				_crate1 addWeaponCargoGlobal [(tools call BIS_fnc_selectRandom),(10 + floor(random 3))];
				_crate1 addWeaponCargoGlobal [(_weapons call BIS_fnc_selectRandom),(2 + floor(random 5))];
				_crate1  addBackpackCargoGlobal [(_backpacks call BIS_fnc_selectRandom),(10 + floor(random 2))];
				
				/////////////////ADD MORE FILLS IF U WANT
				_crate1 addMagazineCargoGlobal [(_items call BIS_fnc_selectRandom),(10 + floor(random 2))];
				_crate1 addMagazineCargoGlobal [(_items call BIS_fnc_selectRandom),(10 + floor(random 2))];
				
				
				};//END OF CRATE
};

 

if u need delete the crate after x time add at bottom after END OF CRATE

sleep 180; //tiime in seconds 180/60 = 3 minutes  this gonna  sleep 3 minutes and then run the code bellow

deleteVehicle _crate1; 

Also you can delete it by player vs distance of this box

//define another vriable

_distance = 50; //mts

waitUntil {(player distance _crate1) > _distance};
deleteVehicle _crate1;

Or using server time:

waituntil {(round(time)) > 300};

if (time > 300) then {

deleteVehicle _crate1;

   [nil,nil,rTitleText,"_crate1 was removed", "PLAIN",10] call RE; //text format for all players

   //titleText [" _crate1 was removed ", "PLAIN DOWN"];titleFadeOut 5;// Text format only for player who spawn the box

//[format["<t align='center' size='0.75' color='#ff5200'>%1 _crate1 was removed.</t>",(name player)],0,0,2,2]spawn

BIS_fnc_dynamicText; //text format only for who spawn the box but more beauty :D with colors and sizes

};

 

 

 

WOW! Now thats detail! Thanks @juandayz! You are the best!!

Link to comment
Share on other sites

  • 0

also u can make a lil function with this and leave server alone to spawn crates each X time. see:

 

example_crate.sqf   (paste into MPMISSIONS/Your instance)

Spoiler

spawn_chi_crate = {
private ["_cratemodels","_items","_tools","_weapons","_backpacks","_positionArray","_pos","_position"]; 
///##VARIABLES##//
_positionArray=[[1677.587, 7417.2876],[1682.7095, 7416.1377]];// Chi ,use your own coords here
_pos= floor random count _positionArray;//this gonna make a random on your coords and pick one
_position = _positionArray select _pos;

_cratemodels=["USBasicWeapons_EP1","LocalBasicAmmunitionBox"] call BIS_fnc_selectRandom; //Add any other kind of crates ids

//bellow put your items id. ///structure: _variable_name ["","","",""];


_items = ["bulk_ItemWire","ItemBriefcase100oz"]; 
_tools = ["ItemToolbox","ItemGPS"];//add any other kind of tools// toolbelt items is taked as weapons so when you fill the crate needs use addWeaponCargoGlobal
_weapons = ["M24_des_EP1","M14_EP1","M14_EP1"];//add more weapons if u want
_backpacks = ["DZ_GunBag_EP1","DZ_British_ACU"];//add more backpacks ids  

//add more variables for items if you want just take care items with items weapons with weapons. ["M24_des_EP1","bulk_ItemWire"];WRONG!//////["M24_des_EP1","ItemGPS"];FINE!!


//this spawn the box

 _crate1 = objNull;
             if (true) then {
                _this = createVehicle [_cratemodels, _position, [], 0, "CAN_COLLIDE"]; //here your saying  _this = create a box using random _cratemodels in random _positions
                _crate1 = _this;// for now on your name box is _crate1
				_crate1 setVariable ["permaLoot",true];//to prevent  lost content of box after an x time
				
				 clearWeaponCargoGlobal _crate1; //deleting all default weapon content of the box (_crate1)
                 clearMagazineCargoGlobal _crate1;  //same of above but this del ammo and items
				 clearBackpackCargoGlobal _crate1; //delete backpacks if crate have for default
				 
				 //FILLING THE CRATE///
				 ///STRUCTURE: _name_of_box /the add function for specific class items/ [(_item array name defined in variables section//call Randomly _item array),(10=ammount of items to make the random + floor(random _Numer of items to add))]  
				 
				 
				_crate1 addMagazineCargoGlobal [(_items call BIS_fnc_selectRandom),(8 + floor(random 6))];
				_crate1 addWeaponCargoGlobal [(tools call BIS_fnc_selectRandom),(10 + floor(random 3))];
				_crate1 addWeaponCargoGlobal [(_weapons call BIS_fnc_selectRandom),(2 + floor(random 5))];
				_crate1  addBackpackCargoGlobal [(_backpacks call BIS_fnc_selectRandom),(10 + floor(random 2))];
				
				/////////////////ADD MORE FILLS IF U WANT
				_crate1 addMagazineCargoGlobal [(_items call BIS_fnc_selectRandom),(10 + floor(random 2))];
				_crate1 addMagazineCargoGlobal [(_items call BIS_fnc_selectRandom),(10 + floor(random 2))];
				
				
				};//END OF CRATE
 sleep 400;
 deleteVehicle _crate1;   
};

//////////SERVER COUNT TIME

//////FIRST SECUENSE
 waituntil {(round(time)) > 300};

 
    if (time > 300) then {
    [nil,nil,rTitleText,"New Random Crates", "PLAIN",10] call RE;
    call spawn_chi_crate;
    };   
/////SECOND 
waituntil {(round(time)) > 900};

 
    if (time > 900) then {
    [nil,nil,rTitleText,"New Random Crates", "PLAIN",10] call RE;
    call spawn_chi_crate;
    };   

//////////////3rd
waituntil {(round(time)) > 1900};

 
    if (time > 1900) then {
    [nil,nil,rTitleText,"New Random Crates", "PLAIN",10] call RE;
    call spawn_chi_crate;
    };   

////////////ADD MORE SECUENSES JUST CHANGE THE TIME

 

now go to your init.sqf--  into if is server  section paste:

if (isServer) then {
    call compile preprocessFileLineNumbers "\z\addons\dayz_server\missions\DayZ_Epoch_11.Chernarus\dynamic_vehicle.sqf";
    _nil = [] execVM "\z\addons\dayz_server\missions\DayZ_Epoch_11.Chernarus\mission.sqf";

    _serverMonitor =     [] execVM "\z\addons\dayz_server\system\server_monitor.sqf";


    _example_crate = [] execVM "example_crates.sqf";
    
};

Link to comment
Share on other sites

  • 0

:D here u have another example, i use it in my server, its a little adapt of rubble town event.

this spawn a crate like an event, do you remember heli crash? well

call it chi_crate.sqf  paste into ....\@DayZ_Epoch_Server\addons\dayz_server\modules\

chi_crate.sqf 

Spoiler

private ["_spawnChance", "_spawnMarker", "_spawnRadius", "_markerRadius", "_item", "_debug", "_start_time", "_loot", "_loot_amount", "_loot_box", "_wait_time", "_spawnRoll", "_position", "_event_marker", "_loot_pos", "_debug_marker","_loot_box", "_hint"];
 
_spawnChance =  0.70; // Percentage chance of event happening
_markerRadius = 350; // Radius the loot can spawn and used for the marker
_debug = true; // Puts a marker exactly were the loot spawns
 
_loot_box = "USVehicleBox";
_loot_lists = [


[
["M9SD","FN_FAL","M4A3_CCO_EP1","AKS_74_kobra","Sa58V_RCO_EP1"],
["150Rnd_127x107_DSHKM","20Rnd_762x51_FNFAL","20Rnd_762x51_FNFAL","20Rnd_762x51_FNFAL","30Rnd_762x39_SA58","30Rnd_762x39_SA58","30Rnd_762x39_SA58","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_545x39_AK","30Rnd_545x39_AK","30Rnd_545x39_AK","15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","ItemToolbox","ItemEtool","ItemCrowbar","ItemKnife","ItemSledge","ItemCompass","Binocular","Binocular_Vector","NVGoggles","ItemGPS"]
],

[
["M9SD"],
["15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor"]
],

[
["M9SD"],
["15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor","metal_floor_kit","ItemWoodFloor"]
],

[
["ChainSaw"],
["ItemCorrugated","ItemCorrugated","ItemCorrugated","ItemCorrugated","ItemPole","ItemPole","ItemPole","ItemPole","ItemPole","ItemPole","ItemPole","ItemPole","ItemPole","ItemPole","ItemPole","ItemComboLock","ItemGenerator"]
],

[
["m240_scoped_EP1_DZE","Mk_48_DZ","M240_DZ","RPK_74"],
["100Rnd_762x51_M240","100Rnd_762x51_M240","200Rnd_556x45_M249","100Rnd_556x45_BetaCMag","100Rnd_762x51_M240","200Rnd_556x45_M249","100Rnd_556x45_BetaCMag","100Rnd_762x51_M240","200Rnd_556x45_M249","100Rnd_556x45_BetaCMag","100Rnd_762x51_M240","200Rnd_556x45_M249","100Rnd_556x45_BetaCMag","100Rnd_762x51_M240","200Rnd_556x45_M249","100Rnd_762x51_M240","100Rnd_762x51_M240","200Rnd_556x45_M249","2000Rnd_762x51_M134","2000Rnd_762x51_M134","ItemAVE","ItemLRK","ItemTNK","ItemARM","ItemORP","ItemSeaBassCooked","ItemSeaBassCooked","ItemSeaBassCooked","ItemSeaBassCooked","ItemSeaBassCooked","ItemSeaBassCooked","ItemSeaBassCooked","ItemSeaBassCooked","ItemSeaBassCooked","ItemSeaBassCooked"]
],


[
["M4A1_HWS_GL_SD_Camo","M16A2GL","M16A4","M16A4_GL","M16A4_ACG_GL","M16A4_ACG","M4A1","M4A1_HWS_GL","M4A1_HWS_GL_camo","M4A1_HWS_GL_SD_Camo","M4A1_RCO_GL","M4A1_Aim","M4A1_Aim_camo","M4A1_AIM_SD_camo"],
["30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","FoodCanFrankBeans","FoodCanFrankBeans","FoodCanBakedBeans","FoodMRE","HandGrenade_east","2000Rnd_762x51_M134","CinderBlocks","CinderBlocks","CinderBlocks","CinderBlocks"]
],


[
["VSS_vintorez","Saiga12K","M8_compact"],
["30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","HandGrenade_east","HandGrenade_east","FoodCanSardines","FoodMRE","FoodPistachio","FoodNutmix","FoodMRE","FoodPistachio","FoodNutmix","CinderBlocks","CinderBlocks","CinderBlocks","CinderBlocks","CinderBlocks"]
]


];
_loot = _loot_lists call BIS_fnc_selectRandom;
 
_loot_amount = 75;
_wait_time = 900;
 
// Dont mess with theses unless u know what yours doing
_start_time = time;
_spawnRadius = 5000;
_spawnMarker = 'center';
 
if (isNil "EPOCH_EVENT_RUNNING") then {
EPOCH_EVENT_RUNNING = false;
};
 
// Check for another event running
if (EPOCH_EVENT_RUNNING) exitWith {
diag_log("Event already running");
};

EPOCH_EVENT_RUNNING = true;

// Random chance of event happening
_spawnRoll = random 1;
if (_spawnRoll > _spawnChance and !_debug) exitWith {};
 
// Random location
_position = [getMarkerPos _spawnMarker,0,_spawnRadius,10,0,2000,0] call BIS_fnc_findSafePos;
 
diag_log(format["Spawning loot event at %1", _position]);
 
_event_marker = createMarker [ format ["loot_event_marker_%1", _start_time], _position];
_event_marker setMarkerShape "ELLIPSE";
_event_marker setMarkerColor "ColorBlue";
_event_marker setMarkerAlpha 0.5;
_event_marker setMarkerSize [(_markerRadius + 50), (_markerRadius + 50)];
 
_loot_pos = [_position,0,(_markerRadius - 100),10,0,2000,0] call BIS_fnc_findSafePos;
 
if (_debug) then {
_debug_marker = createMarker [ format ["loot_event_debug_marker_%1", _start_time], _loot_pos];
_debug_marker setMarkerText "RED CROSS EVENT";
_debug_marker setMarkerShape "ICON";
_debug_marker setMarkerType "mil_dot";
_debug_marker setMarkerColor "ColorBlue";
_debug_marker setMarkerAlpha 1;
};
 
diag_log(format["Creating ammo box at %1", _loot_pos]);
 
// Create ammo box
_loot_box = createVehicle [_loot_box,_loot_pos,[], 0, "NONE"];
clearMagazineCargoGlobal _loot_box;
clearWeaponCargoGlobal _loot_box;
 
// Cut the grass around the loot position
_clutter = createVehicle ["ClutterCutter_small_2_EP1", _loot_pos, [], 0, "CAN_COLLIDE"];
_clutter setPos _loot_pos;
// cut the grass    end
 
// Add loot
{
_loot_box addWeaponCargoGlobal [_x,1];
} forEach (_loot select 0);
{
_loot_box addMagazineCargoGlobal [_x,1];
} forEach (_loot select 1);
 
// Send Top Right message to users , requires Remote message script
//_hint = parseText format["<t align='center' color='#0D00FF' shadow='2' size='1.75'>Supply Crate</t><br/><t align='center' color='#ffffff'> RED CROSS DROPS A CRATE FOR SURVIVORS!, Check your Map for the Location! , Check your Map for the Location!</t>"];
//customRemoteMessage = ['hint', _hint];
//publicVariable "customRemoteMessage";

// Send center message to users
[nil,nil,rTitleText,"RED CROSS DROPS A CRATE FOR SURVIVORS!, Check your Map for the Location!", "PLAIN",10] call RE;
diag_log(format["Loot event setup, waiting for %1 seconds", _wait_time]);

// Wait
sleep _wait_time;
 
// Clean up
EPOCH_EVENT_RUNNING = false;
deleteVehicle _loot_box;
deleteMarker _event_marker;
if (_debug) then {
deleteMarker _debug_marker;
};

 

open your init.sqf paste lines in red

Spoiler

EpochEvents = [["any","any","any","any",30,"crash_spawner"],["any","any","any","any",0,"crash_spawner"],["any","any","any","any",15,"supply_drop"],["any","any","any","any",55,"chi_crate"]];
 

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Discord

×
×
  • Create New...