Jump to content

Recommended Posts

gf-auto-loot-script-version-11-2_4.pnggf-auto-loot-script-version-11-3_4.pnggf-auto-loot-script-version-11-5_4.png

gf-auto-loot-script-version-11-1_4.png

GF Auto Loot Script - Mod

by

 

GEORGE FLOROS [GR]

 

 

Description:

GF Auto Loot Script , will detect the enable Mods , without editing lists.
You are free to do anything but i would like to give me Credits for this!
Simple and easy to use and adapt .
Have Fun !

 


Installation / Usage:

For usage instructions and information of how to use the GF Auto Loot Script please refer to the included documentation and/or example mission.

Place in your mission the files . There is everything included , in the initServer.sqf , to copy paste in your mission .

https://community.bistudio.com/wiki/SQF_syntax
Don't try to open this with the simple notepad.

For everything that is with comment // in front or between /*
means that it is disabled , so there is no need to delete the extra lines.

You can open this ex:
with notepad++
https://notepad-plus-plus.org/

and also use the extra pluggins
(this way will be better , it will give also some certain colours to be able to detect ex. problems )
http://www.armaholic.com/page.php?id=8680

or use any other program for editing .

For the Compilation List of my GF Scripts , you can search in:

https://forums.bohemia.net/forums/topic/215850-compilation-list-of-my-gf-scripts/

 


Notes:

GF Auto Loot Script , will detect the enabled Mods , without editing lists.
There are 4 options available :
1 = Load every Mod + Bohemia Items , 2 = Load every Mod - No Bohemia Items , 3 = Load Bohemia Items Only , 4 = Custom items only

There is a Possibility option available.
There are Blacklist Zones available , 5 from default and
a safe distanse from players , to prevent the loot from spawn.
The loot will spawn also , at the spawned or placed in editor Buildings.
There is also included a mod version , posible to unpack and edit.

 


Credits and Thanks to :

Thanks to All script contributors
Thanks to everyone who tries to do the best for this game!
Thanks to BIS for such a great platform .
Thanks to BIS Community and BIS Community Forums .
Thanks to Armaholic Community and Forums .

 

 

Changelog:

v3.1
Fixed , working now also on Dedicated , with auto init.

 

v3.0
A lot of the previous code is reedited.
Added option for the spawned items number.
Code optimization.

 

v2.0
It is possible to add your custom item list.
There are 4 options available :
1 = Load every Mod + Bohemia Items , 2 = Load every Mod - No Bohemia Items , 3 = Load Bohemia Items Only , 4 = Custom items only
Changed the codes for the search of the configs.
Minor Fixes.

 

v1.0


Forum topic:
- Armaholic forums http://www.armaholic.com/forums.php?m=posts&q=40299

 

 

Armaholic

GF Auto Loot Script - Mod

 

On 12/8/2018 at 3:34 PM, GEORGE FLOROS GR said:

There is also available a Mod ,

with the settings available to adjust from a userconfig :

 

                                                   gf-auto-loot-with-userconfig-version-100

 

 

On 12/9/2018 at 12:12 AM, GEORGE FLOROS GR said:
On 12/8/2018 at 9:18 PM, Realthinged said:

exclude for example CUP

 

Thank you very much Realthinged , i hope you like it !

 

You can add  a case 4 :


case 4 : {

/*
________________	How to disable a certain mod :	________________
example 1 :

(!(getText( _x >> 'author' ) == 'The CUP Team'))

example 2 :
(!(getText( _x >> 'DLC' ) == 'CUP_Weapons'))
*/

//________________	Load every Mod / No CUP Loot	________________

_CfgWeapons = ("(!(getText( _x >> 'author' ) == 'The CUP Team')) && getNumber (_x>> 'scope') > 1" configClasses (configfile >> "CfgWeapons")) apply {configName _x};
"getNumber (_x >> 'scope') >= 2 && {getNumber (_x >> 'type') in [256,16,2*256,3*256,6*256] && {_CfgWeapons pushBack (configName _x);false}}"configClasses (configFile >> "CfgMagazines");
_CfgGlasses = ("(!(getText( _x >> 'author' ) == 'The CUP Team')) && getNumber (_x >> 'scope') > 1" configClasses (configfile >> "CfgGlasses")) apply {configName _x};
_cfgArray_backpack = ("(!(getText( _x >> 'author' ) == 'The CUP Team')) && getNumber (_x >> 'isbackpack') isEqualTo 1 && getNumber (_x>> 'scope') >1 && getNumber (_x>> 'maximumLoad') != 0" configClasses (configfile >> "CfgVehicles")) apply {configName _x};

_Loot_case = "Load every Mod - No CUP Loot";
_Select_Loot_Loaded = true;	
};

 

or if you want to exclude completely the weapons for example :

 

go to this line :

 


//________________	To disable the weapons completely , you can delete for example the: _CfgWeapons	________________
GF_Auto_Loot_with_userconfig_cfgArray = _CfgWeapons + _CfgGlasses + _cfgArray_backpack;

 

  • Like 2
  • Thanks 2

Share this post


Link to post
Share on other sites

THX 4 sharing - but unfortunately the DL link seems broken...:down:

  • Thanks 1

Share this post


Link to post
Share on other sites
36 minutes ago, tourist said:

DL link seems broken...:down:

 

I have upload this in armaholic and i'm waiting the release , it's not yet available !

Share this post


Link to post
Share on other sites

There is also available a Mod ,

with the settings available to adjust from a userconfig :

 

                                                   gf-auto-loot-with-userconfig-version-100

 

Share this post


Link to post
Share on other sites

Link @Armaholic DL Site worked fine ATTOW this! :hyper:

  • Like 1

Share this post


Link to post
Share on other sites

I have also some news !

 

I have implement this script to a new GF Crashsite Script !

 

Everything will be ready soon , i'm making some more fixes.

Share this post


Link to post
Share on other sites

Nice work. Just couple days ago i created similar thing but dynamic.

Call me if you interested about

  • Like 1

Share this post


Link to post
Share on other sites
5 hours ago, davidoss said:

Call me

 

Thank you very much davidoss !

 

Off course , i would like very much to check your script !

I 'm always checking and learning as well , from your posted codes  !  :thumb:

Share this post


Link to post
Share on other sites

we do not sleep because we are armaholics..

Dynamic version

Spoiler

/*
dynanic loot for whole world by DaVidoSS
usage:
if (isServer) then {
		 
	0 = [5,0.51,0.61] execVM "dynamicLoot.sqf";
	// 5 = time in min to pass after players leave area (loot deletion)
	// 0.51 = % of chance to spawn loot in building, range from 0 to 1
	// 0.61 = % of chance to spawn mags along with spawned weapon, range from 0 to 1
	
};
*/
params [["_loot_despawn_timeout",5,[0]],["_lootchance",0.51,[0]],["_hanceMagsSpawnWithGun",0.51,[0]]];
private _centerPosition = ATLtoASL [worldSize/2,worldSize/2,0];

_buildings = [];


	{
		_obj = _x;
		if !( (_obj buildingPos -1) isEqualTo []) then { 
			//gather enterable buildings
			_obj setVariable ["lootSpawned",false,false];
			_buildings pushBack _obj;
		};
	} 
	forEach nearestTerrainObjects 
	[
		_centerPosition, 
		["HOUSE","BUILDING"], 
		worldSize/2, 
		false
	];

fnc_arrRandSeq = {

	params [ ["_array",[],[[]]], ["_indexcnt",1,[0]]];
	private ["_return_array","_randindex"];
	if (_array isEqualTo []) exitWith {_array};

	_return_array = [];

	if (_indexcnt isEqualTo 0) then {_indexcnt = 1};
	if (_indexcnt > (count _array)) then {_indexcnt = count _array};
	if (_indexcnt isEqualTo (count _array)) exitWith {
	_return_array = _array call BIS_fnc_arrayShuffle;
	_return_array
	};

	for "_i" from 1 to _indexcnt do {

	_randindex = selectRandom _array;
	_return_array pushBack _randindex;
	_array = _array - [_randindex];
	};

	(_return_array)
};

fnc_getLoot = {

	params [["_types","",[""]]];

	private _array = [];
	private _config = "";
	private _type = [];
	private _class = "";
	private _cfgPath = "";
	private _exit = false;
	private _mags = [];
	private _inherit  = "";

	switch (true) do {
		case (_types == "weapon"): {_config = "CfgWeapons";_type = ["rifle","launcher","pistol","mgun","binocular"]};
		case (_types == "ammo"): {_config = "CfgMagazines";_type = ["ca_magazine"]};
		case (_types == "item"): {_config = "CfgWeapons";_type = ["itemcore"]};
		case (_types == "bag"): {_config = "CfgVehicles";_type = ["bag_base"]};
		default {_exit = true};
	};
	if (_exit) exitWith {_array};

	{
		_cfgPath = _x;
		_class = (configName _x);
		{
			if ((_class isKindOf [_x, configFile >> _config]) && {(getNumber (_cfgPath >> "scope")) isEqualTo 2}) then {
				if (_types == "ammo") then {
					if !(_class isKindOf ["VehicleMagazine", configfile >> _config]) exitWith {_array pushBack _class};
				} else {
					if (_types == "weapon") exitWith {_mags = (getArray (_cfgPath >> "magazines")); _array pushBack [_class,_mags]};
					if (_types == "bag") exitWith {
						_inherit = configName (inheritsFrom (_cfgPath));
						if (getNumber (configFile >> _config >> _inherit >> "scope") == 2) then {_array pushBack _inherit} else {_array pushBack _class};
					};
					_array pushBack _class;
				};	
			};
		} forEach _type;
	} forEach ("isClass _x" configClasses (configfile >> _config));

	(_array)
};	

fnc_checkForPlayers = {
	params [["_pos", [], [[],objNull]], ["_area", 0, [0]]];
	private _stdOut = false;
	private _players = [] call BIS_fnc_listPlayers;
	{if ((_pos distance2D _x) < _area) exitWith {_stdOut = true}} forEach _players;
	(_stdOut)
};

fnc_spawnLoot = {

	params [["_building",objNull,[objNull]],["_chance",1,[0]],["_chanceAmmo",1,[0]]];

	private _weaponHolders = [];
	private _weaponHolder = objNull;
	private _buldingPosition = [];
	private _type = "";
	private _buldingPositions = _building buildingPos -1;
	if (count _buldingPositions > 3) then {
		_buldingPosition = [_buldingPositions, (floor random [1,2,4])] call fnc_arrRandSeq;
	} else {
		_buldingPosition pushBack (selectRandom _buldingPositions);
	};
	{
		_type = selectRandom ["item","weapon","ammo","item","item","bag","item","item","ammo"];
		if (random 1 < _chance) then {
		
			switch _type do {
				case "weapon": {
					
					private _randomGun = selectRandom (allweapons call BIS_fnc_arrayShuffle);
					_randomGun params ["_gun","_ammo"];
					_weaponHolder = createVehicle ["WeaponHolderSimulated", _x, [], 0, "CAN_COLLIDE"];
					_weaponHolder setPosATL _x;
					if (random 1 < _chanceAmmo) then {
						_weaponHolder addMagazineCargoGlobal [selectRandom _ammo, floor (random [1,2,4])];
					};
					_weaponHolder addWeaponCargoGlobal [_gun, 1];
				};
				case "item": {
				
					private _itemarray = [(allitems call BIS_fnc_arrayShuffle), floor (random [1,2,4])] call fnc_arrRandSeq;
					_weaponHolder = createVehicle ["WeaponHolderSimulated", _x, [], 0, "CAN_COLLIDE"];
					_weaponHolder setPosATL _x;
					{_weaponHolder addItemCargoGlobal [_x, 1]} forEach _itemarray;
				
				};
				case "bag": {
			
					private _bag = selectRandom (allbackpack call BIS_fnc_arrayShuffle);
					_weaponHolder = createVehicle ["WeaponHolderSimulated", _x, [], 0, "CAN_COLLIDE"];
					_weaponHolder setPosATL _x;
					_weaponHolder addBackpackCargoGlobal [_bag, 1];
				};
				case "ammo": {
			
					private _ammoarray = [(allmagazines call BIS_fnc_arrayShuffle), floor (random [1,2,4])] call fnc_arrRandSeq;
					_weaponHolder = createVehicle ["WeaponHolderSimulated", _x, [], 0, "CAN_COLLIDE"];
					_weaponHolder setPosATL _x;
					{_weaponHolder addMagazineCargoGlobal [_x, 1]} forEach _ammoarray;
				};
				default {};
			};
		};
		_weaponHolders pushBack _weaponHolder;
	} forEach _buldingPosition;
(_weaponHolders)
};

allweapons = ["weapon"] call fnc_getLoot;
allmagazines = ["ammo"] call fnc_getLoot;
allitems = ["item"] call fnc_getLoot;
allbackpack = ["bag"] call fnc_getLoot;
loot_despawn_timeout = _loot_despawn_timeout*60;

private _aktivebuildings = [];
private ["_building","_lootSpawned","_weaponHolder"];
while {true} do {

    _aktivebuildings = _buildings select {[_x, 100] call fnc_checkForPlayers};
	if !(_aktivebuildings isEqualTo []) then {
		{
		
			_building = _x;
			_lootSpawned = _building getVariable "lootSpawned";
			if (!_lootSpawned) then {
				_weaponHolder = [_building,_lootchance,_hanceMagsSpawnWithGun] call fnc_spawnLoot;
				_building setVariable ["lootSpawned",true,false];
				
				0 = [_building,_weaponHolder] spawn {
					params [["_house",objNull,[objNull]],["_loot",[],[[]]]];
					waitUntil {sleep 5; !([_house, 100] call fnc_checkForPlayers)};
					private _time = (time + loot_despawn_timeout);
					waitUntil {sleep 5; !([_house, 100] call fnc_checkForPlayers) && {time >= _time}};
					{if (isNull _x) then {deleteVehicle _x}} forEach _loot;
					_house setVariable ["lootSpawned",false,false];
				};
			};
		} forEach _aktivebuildings;
	};
	
	sleep 5;
};

 

 

  • Haha 1

Share this post


Link to post
Share on other sites
1 hour ago, yanoukovytsch said:

Do you sleep sometimes George?

 

#Haha !

 

Thank you very much yanoukovytsch !  :f:

Share this post


Link to post
Share on other sites
1 hour ago, davidoss said:

we do not sleep because we are armaholics..

 

I'm pretty sure , that the arma has turned a lot of years now to an actual Virus !

Pretty difficult to get rid of this !

 

Thank you very much davidoss for sharing this !  :thumbs-up:

PS: Very nice !

Share this post


Link to post
Share on other sites

Changelog:

 

v2.0
It is possible to add your custom item list.
There are 4 options available :
1 = Load every Mod + Bohemia Items , 2 = Load every Mod - No Bohemia Items , 3 = Load Bohemia Items Only , 4 = Custom items only
Changed the codes for the search of the configs.
Minor Fixes.

Share this post


Link to post
Share on other sites
2 minutes ago, foxhound said:

The Armaholic mirror has been updated with the new version:

 

Thank you very much Foxhound for all the support !

 

Share this post


Link to post
Share on other sites

I'm testing this and it seems a couple things are not working quite right. 

 

1. Loot seems to spawn automatically regardless whether the player is nearby or not (script and mod version)

2. Loot DOES NOT spawn in military areas. I'm guessing because none of the military buildings are classified as "house"?

3. Loot continues to spawn in the same area which leads to loot spawning atop existing loot which leads to FPS lag. 

 

Any thoughts @GEORGE FLOROS GR?

  • Like 1

Share this post


Link to post
Share on other sites

Hello there JasonTheRed !

 

Thank you very much for the feadback and the ideas ,

but

well first of all , nothing of this is happening to be honest !!

 

1.The script will only work and spawn everything only once and not dynamic and this is what i wanted to create !

15 hours ago, JasonTheRed said:

2. Loot DOES NOT spawn in military areas

The loot will spawn to almost every building modded or not , since there are building positions .

So almost all the modded buildings as well have building positions.

The scripts will even work with spawned ( with script )  or edited ( with 3d editor ) buildings.

15 hours ago, JasonTheRed said:

3. Loot continues to spawn in the same area which leads to loot spawning atop existing loot which leads to FPS lag. 

The 3 thing cannot be done because imaging that every place for spawning , i just unique.

 

 

One think that needs to be done it's that i haven'yt update to the latest code as for the GF Crashites auto loot script , if you check in order to get a more optimised spawn of the items and a beter debug option.

 

 

Generally for anything that you might see and find i'm here to discuss it !

 

Thanks again  !

  • Like 1

Share this post


Link to post
Share on other sites

So the loot is not dynamic I see, but can it be limited to spawn for example 100 - 500m from the player, so it doesn't consume my entire fps? It's populating the entire Altis. I thought 'GF_Auto_Loot_WU_size = worldsize;' had to do something with it.

  • Like 1

Share this post


Link to post
Share on other sites

You can add certain markers as there is in the example mission - you don't need to change the marker size -  in oder to blacklist places and you can set the distance from the spawn.

Both are available with the script settings !

 

So imagine if you enable the debug you will see the number and the placed spawn of each certain type.

 

For the Fps imagine that with numbers like close to 3000 items there are not problems , if they exist , still and not spawning despawning , actually this can cause less fps , but generally everything depeds !

 

So it's working with DS houses ?

 

41 minutes ago, RZNUNKWN said:

It's populating the entire

 

It will spawn on random and in possibillity selection in almost every even moded , spawned or hand place by the 3d editor, building.

 

The spawn of the items is depending on "building positions" common to most building modders !

  • Like 1

Share this post


Link to post
Share on other sites

One thing that i want to do also in the next update is to also add as example a custom array!

Share this post


Link to post
Share on other sites
11 hours ago, GEORGE FLOROS GR said:

 

So it's working with DS houses ?

 

1

It is indeed! Though sometimes loot clips into house items (in my case the carpet hid the AK74 haha) or into the floor, but you can never the less pick it up.  

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, RZNUNKWN said:

sometimes loot clips into house items (in my case the carpet hid the AK74 haha)

 

This is a little bit of dilemma actually ,

because if i script this differently , the most of the items will just float !

 

So , it's better to have an AK under the carpet !

  • Like 1

Share this post


Link to post
Share on other sites
31 minutes ago, GEORGE FLOROS GR said:

 

So , it's better to have an AK under the carpet !

 

That's the beauty of it! :icon_biggrin:

  • Haha 1

Share this post


Link to post
Share on other sites
On 12/9/2018 at 2:23 AM, davidoss said:

we do not sleep because we are armaholics..

Dynamic version

  Reveal hidden contents


/*
dynanic loot for whole world by DaVidoSS
usage:
if (isServer) then {
		 
	0 = [5,0.51,0.61] execVM "dynamicLoot.sqf";
	// 5 = time in min to pass after players leave area (loot deletion)
	// 0.51 = % of chance to spawn loot in building, range from 0 to 1
	// 0.61 = % of chance to spawn mags along with spawned weapon, range from 0 to 1
	
};
*/
params [["_loot_despawn_timeout",5,[0]],["_lootchance",0.51,[0]],["_hanceMagsSpawnWithGun",0.51,[0]]];
private _centerPosition = ATLtoASL [worldSize/2,worldSize/2,0];

_buildings = [];


	{
		_obj = _x;
		if !( (_obj buildingPos -1) isEqualTo []) then { 
			//gather enterable buildings
			_obj setVariable ["lootSpawned",false,false];
			_buildings pushBack _obj;
		};
	} 
	forEach nearestTerrainObjects 
	[
		_centerPosition, 
		["HOUSE","BUILDING"], 
		worldSize/2, 
		false
	];

fnc_arrRandSeq = {

	params [ ["_array",[],[[]]], ["_indexcnt",1,[0]]];
	private ["_return_array","_randindex"];
	if (_array isEqualTo []) exitWith {_array};

	_return_array = [];

	if (_indexcnt isEqualTo 0) then {_indexcnt = 1};
	if (_indexcnt > (count _array)) then {_indexcnt = count _array};
	if (_indexcnt isEqualTo (count _array)) exitWith {
	_return_array = _array call BIS_fnc_arrayShuffle;
	_return_array
	};

	for "_i" from 1 to _indexcnt do {

	_randindex = selectRandom _array;
	_return_array pushBack _randindex;
	_array = _array - [_randindex];
	};

	(_return_array)
};

fnc_getLoot = {

	params [["_types","",[""]]];

	private _array = [];
	private _config = "";
	private _type = [];
	private _class = "";
	private _cfgPath = "";
	private _exit = false;
	private _mags = [];
	private _inherit  = "";

	switch (true) do {
		case (_types == "weapon"): {_config = "CfgWeapons";_type = ["rifle","launcher","pistol","mgun","binocular"]};
		case (_types == "ammo"): {_config = "CfgMagazines";_type = ["ca_magazine"]};
		case (_types == "item"): {_config = "CfgWeapons";_type = ["itemcore"]};
		case (_types == "bag"): {_config = "CfgVehicles";_type = ["bag_base"]};
		default {_exit = true};
	};
	if (_exit) exitWith {_array};

	{
		_cfgPath = _x;
		_class = (configName _x);
		{
			if ((_class isKindOf [_x, configFile >> _config]) && {(getNumber (_cfgPath >> "scope")) isEqualTo 2}) then {
				if (_types == "ammo") then {
					if !(_class isKindOf ["VehicleMagazine", configfile >> _config]) exitWith {_array pushBack _class};
				} else {
					if (_types == "weapon") exitWith {_mags = (getArray (_cfgPath >> "magazines")); _array pushBack [_class,_mags]};
					if (_types == "bag") exitWith {
						_inherit = configName (inheritsFrom (_cfgPath));
						if (getNumber (configFile >> _config >> _inherit >> "scope") == 2) then {_array pushBack _inherit} else {_array pushBack _class};
					};
					_array pushBack _class;
				};	
			};
		} forEach _type;
	} forEach ("isClass _x" configClasses (configfile >> _config));

	(_array)
};	

fnc_checkForPlayers = {
	params [["_pos", [], [[],objNull]], ["_area", 0, [0]]];
	private _stdOut = false;
	private _players = [] call BIS_fnc_listPlayers;
	{if ((_pos distance2D _x) < _area) exitWith {_stdOut = true}} forEach _players;
	(_stdOut)
};

fnc_spawnLoot = {

	params [["_building",objNull,[objNull]],["_chance",1,[0]],["_chanceAmmo",1,[0]]];

	private _weaponHolders = [];
	private _weaponHolder = objNull;
	private _buldingPosition = [];
	private _type = "";
	private _buldingPositions = _building buildingPos -1;
	if (count _buldingPositions > 3) then {
		_buldingPosition = [_buldingPositions, (floor random [1,2,4])] call fnc_arrRandSeq;
	} else {
		_buldingPosition pushBack (selectRandom _buldingPositions);
	};
	{
		_type = selectRandom ["item","weapon","ammo","item","item","bag","item","item","ammo"];
		if (random 1 < _chance) then {
		
			switch _type do {
				case "weapon": {
					
					private _randomGun = selectRandom (allweapons call BIS_fnc_arrayShuffle);
					_randomGun params ["_gun","_ammo"];
					_weaponHolder = createVehicle ["WeaponHolderSimulated", _x, [], 0, "CAN_COLLIDE"];
					_weaponHolder setPosATL _x;
					if (random 1 < _chanceAmmo) then {
						_weaponHolder addMagazineCargoGlobal [selectRandom _ammo, floor (random [1,2,4])];
					};
					_weaponHolder addWeaponCargoGlobal [_gun, 1];
				};
				case "item": {
				
					private _itemarray = [(allitems call BIS_fnc_arrayShuffle), floor (random [1,2,4])] call fnc_arrRandSeq;
					_weaponHolder = createVehicle ["WeaponHolderSimulated", _x, [], 0, "CAN_COLLIDE"];
					_weaponHolder setPosATL _x;
					{_weaponHolder addItemCargoGlobal [_x, 1]} forEach _itemarray;
				
				};
				case "bag": {
			
					private _bag = selectRandom (allbackpack call BIS_fnc_arrayShuffle);
					_weaponHolder = createVehicle ["WeaponHolderSimulated", _x, [], 0, "CAN_COLLIDE"];
					_weaponHolder setPosATL _x;
					_weaponHolder addBackpackCargoGlobal [_bag, 1];
				};
				case "ammo": {
			
					private _ammoarray = [(allmagazines call BIS_fnc_arrayShuffle), floor (random [1,2,4])] call fnc_arrRandSeq;
					_weaponHolder = createVehicle ["WeaponHolderSimulated", _x, [], 0, "CAN_COLLIDE"];
					_weaponHolder setPosATL _x;
					{_weaponHolder addMagazineCargoGlobal [_x, 1]} forEach _ammoarray;
				};
				default {};
			};
		};
		_weaponHolders pushBack _weaponHolder;
	} forEach _buldingPosition;
(_weaponHolders)
};

allweapons = ["weapon"] call fnc_getLoot;
allmagazines = ["ammo"] call fnc_getLoot;
allitems = ["item"] call fnc_getLoot;
allbackpack = ["bag"] call fnc_getLoot;
loot_despawn_timeout = _loot_despawn_timeout*60;

private _aktivebuildings = [];
private ["_building","_lootSpawned","_weaponHolder"];
while {true} do {

    _aktivebuildings = _buildings select {[_x, 100] call fnc_checkForPlayers};
	if !(_aktivebuildings isEqualTo []) then {
		{
		
			_building = _x;
			_lootSpawned = _building getVariable "lootSpawned";
			if (!_lootSpawned) then {
				_weaponHolder = [_building,_lootchance,_hanceMagsSpawnWithGun] call fnc_spawnLoot;
				_building setVariable ["lootSpawned",true,false];
				
				0 = [_building,_weaponHolder] spawn {
					params [["_house",objNull,[objNull]],["_loot",[],[[]]]];
					waitUntil {sleep 5; !([_house, 100] call fnc_checkForPlayers)};
					private _time = (time + loot_despawn_timeout);
					waitUntil {sleep 5; !([_house, 100] call fnc_checkForPlayers) && {time >= _time}};
					{if (isNull _x) then {deleteVehicle _x}} forEach _loot;
					_house setVariable ["lootSpawned",false,false];
				};
			};
		} forEach _aktivebuildings;
	};
	
	sleep 5;
};

 

 

@davidoss do you mind if I use your loot spawner in a mission I'm publishing? The fact it spawns loot around players (and deletes it) is great! Just making sure before I enable it. I've given you credit BTW. 

  • Like 1

Share this post


Link to post
Share on other sites

I have no problem with.

I posted it for GF as example of another point of view and performance.

I could make my own release but the code has no development state of any kind  because i have no time to support it

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×