
RANDOM LOOT SPAWN IN BUILDINGS
To make random weapons/items spawn (DayZ style) inside house (already on map or added), follow theses steps :
​
STEP 1 : Create loot.sqf inside your mission folder and past following code :
​
​
​
_markerPos = getMarkerPos "lootMarker";
_weaponArray = [
"srifle_DMR_05_blk_F",
"arifle_Katiba_F",
"srifle_DMR_06_olive_F",
"arifle_Mk20_F",
"arifle_MX_SW_F",
"hgun_PDW2000_F",
"LMG_Zafir_F"
];
_itemBoxArray = [];
_houseArray = _markerPos nearObjects ["house",100];
{
_buildingPositions = [_x] call BIS_fnc_buildingPositions;
{
_weapon = _weaponArray select (floor (random (count _weaponArray)));
_itemBox = "WeaponHolderSimulated" createVehicle [0,0,0];
_itemBox setPos _x;
_itemBox addWeaponCargoGlobal [_weapon,1];
_magazines = getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines");
_mag = _magazines select (floor (random (count _magazines)));
_itemBox addMagazineCargoGlobal [_mag,5];
_itemBoxArray = _itemBoxArray + [_itemBox];
} forEach _buildingPositions;
} forEach _houseArray;
sleep 120;
{
deleteVehicle _x;
} forEach _itemBoxArray;
​
​
Note :
items : place, change, delete, adds items there, its the list of items that will spawn in houses
lootMarker : aroud this marker, spawn will be effective
100 : in the houses presents in the 100 meters around lootMarker , items will spawn
​
​
​
​
STEP 2 : Create init.sqf inside your mission folder and past following code :
​
​
​
nul=[] execVM "loot.sqf";
​
​
​
STEP 3 : go to the editor and on your mission, place empty marker named lootMarker
​
Place this marker close to house already placed on the map or add buildings in 100 meters around the lootMaker
​
​
​
​
Launch your mission and you will see objects/weapons spawn in lootMaker sector
​