Jump to content
Sign in to follow this  
tonic-_-

[ALPHA] ARMA 3 Crate Filler

Recommended Posts

That script goes in your mission folder, not your mission\scripts folder.

Reference here: nul = [this] execVM "fillCrate.sqf";

If it was to go in your scripts folder, it would say: nul = [this] execVM "scripts\fillCrate.sqf";

Share this post


Link to post
Share on other sites

@sbobovyc Yeah. Will try that. First I will make a game logic named "server" maybe this will help. I remeber some scripts in ArmA2 required that. Then I will test it whit removing that line.

Share this post


Link to post
Share on other sites

This one should reduce lag, and delay regarding ammo boxes.

It does hide the global box and creates same one locally (with same class,pos and rot), does also locally refill the box every 5 minutes.


_box = _this select 0; 

//Locally hide the crate for player
hideObject _box;

// Make new one localy with same classname, position and dir
_c = (typeof _box) createVehicleLocal [0,0,9001];
_c setPosATL (getPosATL _box);
_c setDir (getDir _box);

_box=_c;

while {alive _box} do
{

 // Remove the stock items from the crate
 clearMagazineCargo _box;
 clearWeaponCargo _box;
 clearItemCargo _box;
 clearBackpackCargo _box;


 _CfgWeapons = configFile >> "cfgWeapons"; 
 _weapons = []; 
 _items = []; 
 _misc = []; 

 for "_i" from 0 to (count _Cfgweapons)-1 do 
 { 
   _weapon = _CfgWeapons select _i; 

   if(isClass _weapon) then 
   { 
     _wep = configName _weapon; 
     _wep_type = getNumber(_weapon >> "type"); 
     _scope = getNumber(_weapon >> "scope"); 

     if(_scope == 2 && _wep_type != 65536) then 
     { 
       if(_wep_type in [1,2,4,5,4096] && _wep != "NVGoggles") then 
       { 
       _weapons set[count _weapons,_wep]; 
       } 
       else 
       { 
       _items set[count _items,_wep]; 
       }; 
     }; 
   }; 
 }; 

 //Build Throw/Put magazine array 
 {_misc=_misc+getArray (configFile/"CfgWeapons"/"Throw"/_x/"magazines")} forEach getArray (configFile/"CfgWeapons"/"Throw"/"muzzles"); 
 {_misc=_misc+getArray (configFile/"CfgWeapons"/"Put"/_x/"magazines")} forEach getArray (configFile/"CfgWeapons"/"Put"/"muzzles"); 

 { 
 _box addMagazineCargo [_x,100]; 
 } foreach _misc; 

   //Add weapons & Mags 
 { 
   _box addWeaponCargo [_x,100]; 
   diag_log format["Weapon %1 added", _x]; 

   _mags = getArray(configFile >> "CfgWeapons" >> _x >> "magazines"); 

   if(count _mags > 0) then 
   { 
     { 
         if(!(_x in ((getMagazineCargo _box) select 0))) then 
         { 
         _box addMagazineCargo [_x,100]; 
         diag_log format["Magazine %1 added", _x]; 
         }; 
     } foreach _mags; 
   }; 
 } foreach _weapons; 

 //Add Items 
 { 
   _box addItemCargo [_x,100]; 
 } foreach _items; 


 // Refill every 5 mins
 sleep 3000;
};

Edited by aeroson
fixed

Share this post


Link to post
Share on other sites

What Aeroson posted works HOWEVER there is a downside to that. Depends on how OCD you are about placement. When it re-creates it locally, sometimes it makes the ammo boxes floating, bounce around to a new location, or even destroyed when spawning in unless it is on 100% flat terrain. I've tested it extensively as he provided me with a similar script way back when.

Share this post


Link to post
Share on other sites
What Aeroson posted works HOWEVER there is a downside to that. Depends on how OCD you are about placement. When it re-creates it locally, sometimes it makes the ammo boxes floating, bounce around to a new location, or even destroyed when spawning in unless it is on 100% flat terrain. I've tested it extensively as he provided me with a similar script way back when.

Replacing getPos with getPosATL and setPos with setPosATL seems to have fixed the floating/bouncing problem.

Share this post


Link to post
Share on other sites

Yup i had a brain fart and meant to put that into my message haha

Share this post


Link to post
Share on other sites

So i should replace this with original crate filler or schould i add this at the and line ?

// Locally hide the crate for player

_box = _this select 0;

hideObject _box;

// Make new one localy with same classname, position and dir

_c = (typeof _box) createVehicleLocal (position _box);

_c setPosATL (getPosATL _box);

_c setDir (getDir _box);

while {alive _box} do

{

// Remove the stock items from the crate

clearMagazineCargo _c;

clearWeaponCargo _c;

clearItemCargo _c;

clearBackpackCargo _c;

clearWeaponCargo _box;

clearMagazineCargo _box;

clearItemCargo _box;

clearBackpackCargo _box;

_CfgWeapons = configFile >> "cfgWeapons";

_weapons = [];

_items = [];

_misc = [];

for "_i" from 0 to (count _Cfgweapons)-1 do

{

_weapon = _CfgWeapons select _i;

if(isClass _weapon) then

{

_wep = configName _weapon;

_wep_type = getNumber(_weapon >> "type");

_scope = getNumber(_weapon >> "scope");

if(_scope == 2 && _wep_type != 65536) then

{

if(_wep_type in [1,2,4,5,4096] && _wep != "NVGoggles") then

{

_weapons set[count _weapons,_wep];

}

else

{

_items set[count _items,_wep];

};

};

};

};

//Build Throw/Put magazine array

{_misc=_misc+getArray (configFile/"CfgWeapons"/"Throw"/_x/"magazines")} forEach getArray (configFile/"CfgWeapons"/"Throw"/"muzzles");

{_misc=_misc+getArray (configFile/"CfgWeapons"/"Put"/_x/"magazines")} forEach getArray (configFile/"CfgWeapons"/"Put"/"muzzles");

{

_box addMagazineCargo [_x,100];

} foreach _misc;

//Add weapons & Mags

{

_box addWeaponCargo [_x,100];

diag_log format["Weapon %1 added", _x];

_mags = getArray(configFile >> "CfgWeapons" >> _x >> "magazines");

if(count _mags > 0) then

{

{

if(!(_x in ((getMagazineCargo _box) select 0))) then

{

_box addMagazineCargo [_x,100];

diag_log format["Magazine %1 added", _x];

};

} foreach _mags;

};

} foreach _weapons;

//Add Items

{

_box addItemCargo [_x,100];

} foreach _items;

// Refill every 5 mins

sleep 3000;

};

Share this post


Link to post
Share on other sites

Well, due to locality issues with gear boxes in Arma 3 i'll be doing what aeroson is doing in the next update along side that all errors of missing entries will be removed, all magazine types will be added along side backpacks and options to fill certain ammo boxes with just certain things i.e one box is guns & ammo, another is backpacks, another is items.

Edited by Tonic-_-

Share this post


Link to post
Share on other sites
Well, due to locality issues with gear boxes in Arma 3 i'll be doing what aeroson is doing in the next update along side that all errors of missing entries will be removed, all magazine types will be added along side backpacks and options to fill certain ammo boxes with just certain things i.e one box is guns & ammo, another is backpacks, another is items.

That would be great. Now my crates fly away or if they stand still there are nothing inside...

Share this post


Link to post
Share on other sites

(UPDATED) ARMA 3 Crate Filler v0.2



by Tonic aka TAW_Tonic

Code:

/*
@file Version: v0.2
@file name: fillCrate.sqf
@file Author: TAW_Tonic
@file edit: 3/8/2013
@file Description: Automatically fill ammo box with everything in the game depending on paramenters
@params: [box,type,bool (optional),seconds(optional default: 5min)] execVM "fillCrate.sqf
@examples:
nul = [this,0,true] execVM "fillCrate.sqf"; //Fill ammo crate with everything - resupply enabled
nul = [this,1,true] execVM "fillCrate.sqf"; //Fill ammo crate with weapons & magazines - resupply enabled
nul = [this,2] execVM "fillCrate.sqf"; //Fill ammo crate with items - resupply disabled
nul = [this,3,true,(60 * 2)] execVM "fillCrate.sqf"; //Fill ammo crate with backpacks - resupply enabled - resupply every 2 minutes
*/
private["_box","_type","_boxn","_bType","_bType","_bPos","_boxn","_cfgweapons","_weapons","_magazines","_cur_wep","_classname","_wep_type","_scope","_picture","_items","_backpacks"];
_box = _this select 0;
_type = _this select 1;
_resupply = if(count _this > 2) then {_this select 2;} else {false;};
_resupply_time = if(count _this > 3) then {_this select 3;} else {60 * 5};

_bType = typeOf _box;
_bPos = getPos _box;

//Hide the global ammo box & create a local one *temp fix for locality issues).
if(!local _box) then
{
_box hideObject true;
_boxn = _bType createVehicleLocal [0,0,0];
_boxn setPosATL [_bPos select 0,_bPos select 1,0];

}
else
{
_boxn = _box;
};

clearWeaponCargo _boxn;
clearMagazineCargo _boxn;
clearItemCargo _boxn;
clearBackpackCargo _boxn;

switch (_type) do
{
//Master ammo crate (EVERYTHING).
case 0:
{	
	_cfgweapons = configFile >> "CfgWeapons";
	_weapons = [];

	for "_i" from 0 to (count _cfgWeapons)-1 do
	{
		_cur_wep = _cfgweapons select _i;

		if(isClass _cur_wep) then
		{
			_classname = configName _cur_wep;
			_wep_type = getNumber(_cur_wep >> "type");
			_scope = getNumber(_cur_wep >> "scope");
			_picture = getText(_cur_wep >> "picture");
			if(_scope >= 2 && _wep_type in [1,2,4,4096] && _picture != "" && !(_classname in _weapons) && _classname != "NVGoggles") then
			{
				//diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
				_weapons set[count _weapons, _classname];
			};
		};
	};

	_cfgweapons = configFile >> "CfgMagazines";
	_magazines = [];

	for "_i" from 0 to (count _cfgWeapons)-1 do
	{
		_cur_wep = _cfgweapons select _i;

		if(isClass _cur_wep) then
		{
			_classname = configName _cur_wep;
			//_wep_type = getNumber(_cur_wep >> "type");
			_scope = getNumber(_cur_wep >> "scope");
			_picture = getText(_cur_wep >> "picture");
			if(_scope >= 2 && _picture != "" && !(_classname in _magazines)) then
			{
				_magazines set[count _magazines, _classname];
			};
		};
	};

	{ _boxn addWeaponCargo [_x,50]; } foreach _weapons;
	{ _boxn addMagazineCargo [_x,50]; }foreach _magazines;

	_cfgweapons = configFile >> "CfgWeapons";
	_items = [];

	for "_i" from 0 to (count _cfgWeapons)-1 do
	{
		_cur_wep = _cfgweapons select _i;

		if(isClass _cur_wep) then
		{
			_classname = configName _cur_wep;
			_wep_type = getNumber(_cur_wep >> "type");
			_scope = getNumber(_cur_wep >> "scope");
			_picture = getText(_cur_wep >> "picture");
			//diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
			if(_scope >= 2 && _wep_type in [131072,4096] && _picture != "" && !(_classname in _items) && _classname != "Binocular") then
			{
				//diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
				_items set[count _items, _classname];
			};
		};
	};

	{ _boxn addItemCargo [_x,50]; } foreach _items;

		_cfgweapons = configFile >> "CfgVehicles";
	_backpacks = [];

	for "_i" from 0 to (count _cfgWeapons)-1 do
	{
		_cur_wep = _cfgweapons select _i;

		if(isClass _cur_wep) then
		{
			_classname = configName _cur_wep;
			_wep_type = getText(_cur_wep >> "vehicleClass");
			_scope = getNumber(_cur_wep >> "scope");
			_picture = getText(_cur_wep >> "picture");
			if(_scope >= 2 && _wep_type == "Backpacks" && _picture != "" && !(_classname in _backpacks)) then
			{
				//diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
				_backpacks set[count _backpacks, _classname];
			};
		};
	};

	{ _boxn addBackPackCargo [_x,5]; } foreach _backpacks;
};
//Fill box with Guns & Ammo only
case 1:
{
	_cfgweapons = configFile >> "CfgWeapons";
	_weapons = [];

	for "_i" from 0 to (count _cfgWeapons)-1 do
	{
		_cur_wep = _cfgweapons select _i;

		if(isClass _cur_wep) then
		{
			_classname = configName _cur_wep;
			_wep_type = getNumber(_cur_wep >> "type");
			_scope = getNumber(_cur_wep >> "scope");
			_picture = getText(_cur_wep >> "picture");
			if(_scope >= 2 && _wep_type in [1,2,4,4096] && _picture != "" && !(_classname in _weapons) && _classname != "NVGoggles") then
			{
				//diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
				_weapons set[count _weapons, _classname];
			};
		};
	};

	_cfgweapons = configFile >> "CfgMagazines";
	_magazines = [];

	for "_i" from 0 to (count _cfgWeapons)-1 do
	{
		_cur_wep = _cfgweapons select _i;

		if(isClass _cur_wep) then
		{
			_classname = configName _cur_wep;
			//_wep_type = getNumber(_cur_wep >> "type");
			_scope = getNumber(_cur_wep >> "scope");
			_picture = getText(_cur_wep >> "picture");
			if(_scope >= 2 && _picture != "" && !(_classname in _magazines)) then
			{
				_magazines set[count _magazines, _classname];
			};
		};
	};

	{ _boxn addWeaponCargo [_x,50]; } foreach _weapons;
	{ _boxn addMagazineCargo [_x,50]; }foreach _magazines;
};

//Items only
case 2:
{	
	_cfgweapons = configFile >> "CfgWeapons";
	_items = [];

	for "_i" from 0 to (count _cfgWeapons)-1 do
	{
		_cur_wep = _cfgweapons select _i;

		if(isClass _cur_wep) then
		{
			_classname = configName _cur_wep;
			_wep_type = getNumber(_cur_wep >> "type");
			_scope = getNumber(_cur_wep >> "scope");
			_picture = getText(_cur_wep >> "picture");
			//diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
			if(_scope >= 2 && _wep_type in [131072,4096] && _picture != "" && !(_classname in _items) && _classname != "Binocular") then
			{
				//diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
				_items set[count _items, _classname];
			};
		};
	};

	{ _boxn addItemCargo [_x,50]; } foreach _items;
};

case 3:
{

	_cfgweapons = configFile >> "CfgVehicles";
	_backpacks = [];

	for "_i" from 0 to (count _cfgWeapons)-1 do
	{
		_cur_wep = _cfgweapons select _i;

		if(isClass _cur_wep) then
		{
			_classname = configName _cur_wep;
			_wep_type = getText(_cur_wep >> "vehicleClass");
			_scope = getNumber(_cur_wep >> "scope");
			_picture = getText(_cur_wep >> "picture");
			if(_scope >= 2 && _wep_type == "Backpacks" && _picture != "" && !(_classname in _backpacks)) then
			{
				//diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
				_backpacks set[count _backpacks, _classname];
			};
		};
	};

	{ _boxn addBackPackCargo [_x,5]; } foreach _backpacks;
};
};

if(_resupply) then
{
sleep _resupply_time;
[_boxn,_type,_resupply,_resupply_time] execVM "fillCrate.sqf";
};

Parameters:

[box,type (number),bool,seconds] execVM "fillCrate.sqf";

Examples:

nul = [this,0,true] execVM "fillCrate.sqf"; //Fill ammo crate with everything - resupply enabled
nul = [this,1,true] execVM "fillCrate.sqf"; //Fill ammo crate with weapons & magazines - resupply enabled
nul = [this,2] execVM "fillCrate.sqf"; //Fill ammo crate with items - resupply disabled
nul = [this,3,true,(60 * 2)] execVM "fillCrate.sqf"; //Fill ammo crate with backpacks - resupply enabled - resupply every 2 minutes

Changelog:

Changed: Ammo box is now becomes local to the client to avoid locality issues within the end (temp fix).

Added: Backpacks

Added: All magazine types

Added: Various parameter options to make super crates, weapon/ammo crates,item crates and backpack only crates.

Added: Resupply Option with optional time adjustment (in seconds).

Fixed: Cleaned up code to remove bad config entries returning No Entry for certain items although the no entry cows is related to a gun and is a problem in bis's configs.

Thanks/Credits:

unknownx9 - For Backpack code

Download:

ARMA 3 Crate Filler v0.2

Edited by Tonic-_-

Share this post


Link to post
Share on other sites

I just end up with empty crates....

Running a listen server - 2 crates, one for gear, one for weapons with ....

nul = [this,1,true] execVM "fillCrate.sqf";

and

nul = [this,2,true] execVM "fillCrate.sqf";

respectively in their init lines. no errors in RPT, file is located in mission root folder (alongside mission.sqm).

Share this post


Link to post
Share on other sites

Fixed after removing "_boxn" from the private ["_bType","_bType",...] inside case:

Looks like it created it again empty within the case's scope, there might be some problems with other re-privated vars as well.

Edited by aeroson

Share this post


Link to post
Share on other sites

Let me look into it, when I ran the test I had three ammo boxes on the map and it seemed to work, although I removed the excessive privates and merged them into one so I don't know why the other private variables are showing up but that may be causing the issue. Might not of copied over the script properly.

*Edit* Yeah, the extra private[] were breaking it, the weird thing was what I pasted and uploaded wasn't what was saved to the file :s

Here is the proper one.

/*
@file Version: v0.2
@file name: fillCrate.sqf
@file Author: TAW_Tonic
@file edit: 3/8/2013
@file Description: Automatically fill ammo box with everything in the game depending on paramenters
@params: [box,type,bool (optional),seconds(optional default: 5min)] execVM "fillCrate.sqf
@examples:
nul = [this,0,true] execVM "fillCrate.sqf"; //Fill ammo crate with everything - resupply enabled
nul = [this,1,true] execVM "fillCrate.sqf"; //Fill ammo crate with weapons & magazines - resupply enabled
nul = [this,2] execVM "fillCrate.sqf"; //Fill ammo crate with items - resupply disabled
nul = [this,3,true,(60 * 2)] execVM "fillCrate.sqf"; //Fill ammo crate with backpacks - resupply enabled - resupply every 2 minutes
*/
private["_box","_type","_boxn","_bType","_bType","_bPos","_boxn","_cfgweapons","_weapons","_magazines","_cur_wep","_classname","_wep_type","_scope","_picture","_items","_backpacks"];
_box = _this select 0;
_type = _this select 1;
_resupply = if(count _this > 2) then {_this select 2;} else {false;};
_resupply_time = if(count _this > 3) then {_this select 3;} else {60 * 5};

_bType = typeOf _box;
_bPos = getPos _box;

//Hide the global ammo box & create a local one *temp fix for locality issues).
if(!local _box) then
{
_box hideObject true;
_boxn = _bType createVehicleLocal [0,0,0];
_boxn setPosATL [_bPos select 0,_bPos select 1,0];

}
else
{
_boxn = _box;
};

clearWeaponCargo _boxn;
clearMagazineCargo _boxn;
clearItemCargo _boxn;
clearBackpackCargo _boxn;

switch (_type) do
{
//Master ammo crate (EVERYTHING).
case 0:
{	
	_cfgweapons = configFile >> "CfgWeapons";
	_weapons = [];

	for "_i" from 0 to (count _cfgWeapons)-1 do
	{
		_cur_wep = _cfgweapons select _i;

		if(isClass _cur_wep) then
		{
			_classname = configName _cur_wep;
			_wep_type = getNumber(_cur_wep >> "type");
			_scope = getNumber(_cur_wep >> "scope");
			_picture = getText(_cur_wep >> "picture");
			if(_scope >= 2 && _wep_type in [1,2,4,4096] && _picture != "" && !(_classname in _weapons) && _classname != "NVGoggles") then
			{
				//diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
				_weapons set[count _weapons, _classname];
			};
		};
	};

	_cfgweapons = configFile >> "CfgMagazines";
	_magazines = [];

	for "_i" from 0 to (count _cfgWeapons)-1 do
	{
		_cur_wep = _cfgweapons select _i;

		if(isClass _cur_wep) then
		{
			_classname = configName _cur_wep;
			//_wep_type = getNumber(_cur_wep >> "type");
			_scope = getNumber(_cur_wep >> "scope");
			_picture = getText(_cur_wep >> "picture");
			if(_scope >= 2 && _picture != "" && !(_classname in _magazines)) then
			{
				_magazines set[count _magazines, _classname];
			};
		};
	};

	{ _boxn addWeaponCargo [_x,50]; } foreach _weapons;
	{ _boxn addMagazineCargo [_x,50]; }foreach _magazines;

	_cfgweapons = configFile >> "CfgWeapons";
	_items = [];

	for "_i" from 0 to (count _cfgWeapons)-1 do
	{
		_cur_wep = _cfgweapons select _i;

		if(isClass _cur_wep) then
		{
			_classname = configName _cur_wep;
			_wep_type = getNumber(_cur_wep >> "type");
			_scope = getNumber(_cur_wep >> "scope");
			_picture = getText(_cur_wep >> "picture");
			//diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
			if(_scope >= 2 && _wep_type in [131072,4096] && _picture != "" && !(_classname in _items) && _classname != "Binocular") then
			{
				//diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
				_items set[count _items, _classname];
			};
		};
	};

	{ _boxn addItemCargo [_x,50]; } foreach _items;

		_cfgweapons = configFile >> "CfgVehicles";
	_backpacks = [];

	for "_i" from 0 to (count _cfgWeapons)-1 do
	{
		_cur_wep = _cfgweapons select _i;

		if(isClass _cur_wep) then
		{
			_classname = configName _cur_wep;
			_wep_type = getText(_cur_wep >> "vehicleClass");
			_scope = getNumber(_cur_wep >> "scope");
			_picture = getText(_cur_wep >> "picture");
			if(_scope >= 2 && _wep_type == "Backpacks" && _picture != "" && !(_classname in _backpacks)) then
			{
				//diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
				_backpacks set[count _backpacks, _classname];
			};
		};
	};

	{ _boxn addBackPackCargo [_x,5]; } foreach _backpacks;
};
//Fill box with Guns & Ammo only
case 1:
{
	_cfgweapons = configFile >> "CfgWeapons";
	_weapons = [];

	for "_i" from 0 to (count _cfgWeapons)-1 do
	{
		_cur_wep = _cfgweapons select _i;

		if(isClass _cur_wep) then
		{
			_classname = configName _cur_wep;
			_wep_type = getNumber(_cur_wep >> "type");
			_scope = getNumber(_cur_wep >> "scope");
			_picture = getText(_cur_wep >> "picture");
			if(_scope >= 2 && _wep_type in [1,2,4,4096] && _picture != "" && !(_classname in _weapons) && _classname != "NVGoggles") then
			{
				//diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
				_weapons set[count _weapons, _classname];
			};
		};
	};

	_cfgweapons = configFile >> "CfgMagazines";
	_magazines = [];

	for "_i" from 0 to (count _cfgWeapons)-1 do
	{
		_cur_wep = _cfgweapons select _i;

		if(isClass _cur_wep) then
		{
			_classname = configName _cur_wep;
			//_wep_type = getNumber(_cur_wep >> "type");
			_scope = getNumber(_cur_wep >> "scope");
			_picture = getText(_cur_wep >> "picture");
			if(_scope >= 2 && _picture != "" && !(_classname in _magazines)) then
			{
				_magazines set[count _magazines, _classname];
			};
		};
	};

	{ _boxn addWeaponCargo [_x,50]; } foreach _weapons;
	{ _boxn addMagazineCargo [_x,50]; }foreach _magazines;
};

//Items only
case 2:
{	
	_cfgweapons = configFile >> "CfgWeapons";
	_items = [];

	for "_i" from 0 to (count _cfgWeapons)-1 do
	{
		_cur_wep = _cfgweapons select _i;

		if(isClass _cur_wep) then
		{
			_classname = configName _cur_wep;
			_wep_type = getNumber(_cur_wep >> "type");
			_scope = getNumber(_cur_wep >> "scope");
			_picture = getText(_cur_wep >> "picture");
			//diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
			if(_scope >= 2 && _wep_type in [131072,4096] && _picture != "" && !(_classname in _items) && _classname != "Binocular") then
			{
				//diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
				_items set[count _items, _classname];
			};
		};
	};

	{ _boxn addItemCargo [_x,50]; } foreach _items;
};

case 3:
{

	_cfgweapons = configFile >> "CfgVehicles";
	_backpacks = [];

	for "_i" from 0 to (count _cfgWeapons)-1 do
	{
		_cur_wep = _cfgweapons select _i;

		if(isClass _cur_wep) then
		{
			_classname = configName _cur_wep;
			_wep_type = getText(_cur_wep >> "vehicleClass");
			_scope = getNumber(_cur_wep >> "scope");
			_picture = getText(_cur_wep >> "picture");
			if(_scope >= 2 && _wep_type == "Backpacks" && _picture != "" && !(_classname in _backpacks)) then
			{
				//diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
				_backpacks set[count _backpacks, _classname];
			};
		};
	};

	{ _boxn addBackPackCargo [_x,5]; } foreach _backpacks;
};
};

if(_resupply) then
{
sleep _resupply_time;
[_boxn,_type,_resupply,_resupply_time] execVM "fillCrate.sqf";
};

Link is updated as well.

Edited by Tonic-_-

Share this post


Link to post
Share on other sites

How difficult would it be to add s section just for attachments? Like I'd like to have a box for just for just basic weapons, no attachments all ammo types, then a separate box for the attachments.

Nvm i saw that you were gonna do that in the future....

Edited by BHCSAVAGE

Share this post


Link to post
Share on other sites
How difficult would it be to add s section just for attachments? Like I'd like to have a box for just for just basic weapons, no attachments all ammo types, then a separate box for the attachments.

Nvm i saw that you were gonna do that in the future....

v0.2 supports adding gear specific items to a ammo box.

[this,0,true] execVM "fillCrate.sqf";

0 = Everything in one ammo box

1 = Weapons / Magazines in one ammo box

2 = Items / attachments in one ammo box

3 = Backpacks only in the ammo box

Although I have some dreadful news for MP mission makers using this. Apparently regardless of the server adding ammo to the ammo box or the ammo box being local to the client it creates mass server network issues. This seems to be a very serious bug within the Arma 3 engine its self, for some odd reason even when creating the ammo box local you are still sending the ammo box and gear contents cross the network resulting in extremely high bandwidth usage. Basically each player was sending about 2000Kbps to the server. So with 7 players Server incoming bandwidth will be around 8520Kbps.

Edited by Tonic-_-

Share this post


Link to post
Share on other sites
Although I have some dreadful news for MP mission makers...

Thats a bloody shame, might explain some of the "choppiness" we've been having.

Share this post


Link to post
Share on other sites

Here a recursive code to get base weapons without any attachments, notice dexterity check instead of type.

private["_box","_type","_boxn","_bType","_bType","_bPos","_boxn","_cfgweapons","_weapons","_magazines","_cur_wep","_classname","_wep_type","_scope","_picture","_items","_backpacks"];  

_boxn = _this select 0;

clearWeaponCargo _boxn;
clearMagazineCargo _boxn;
clearItemCargo _boxn;
clearBackpackCargo _boxn;




_cfgweapons = configFile >> "CfgWeapons";
_weapons = [];

get = {
 private["_cur_wep","_classname","_wep_type","_scope","_picture","_parent"];
 _cur_wep=_this select 0;
 _classname = configName _cur_wep;
 _scope = getNumber(_cur_wep >> "scope");
 _picture = getText(_cur_wep >> "picture");
 _dexterity = getNumber(_cur_wep >> "dexterity");
 if(_scope >= 2  && _picture != "" && _dexterity>0) then {
   if(!(_classname in _weapons)) then {
     _parent=inheritsFrom(_cfgWeapons>>_classname);
     if(0==([_parent] call get)) then {
       0; // parent was added, all good        
     } else {
       diag_log format["Class: %1 - Dexterity: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_dexterity,_scope,_picture,_cur_wep];
       _weapons set[count _weapons, _classname]; // parent was not added, do add child
       0;
     };
   }
   else {
     0; // parent does match but was already added
   }
 } else {
   1; // parent does not match our neeed, do add child
 };
};  

for "_i" from 0 to (count _cfgWeapons)-1 do
{
   _cur_wep = _cfgweapons select _i;    
   if(isClass _cur_wep) then
   {
       [_cur_wep] call get;
   };
};





diag_log format["%1",_weapons];
hint format ["%1 %2",time,_weapons];
{ _boxn addWeaponCargo [_x,50]; } foreach _weapons; 

Output:

_weapons == ["launch_NLAW_F","launch_RPG32_F","srifle_EBR_F","LMG_Mk200_F","hgun_P07_F","hgun_Rook40_F","arifle_Khaybar_F","arifle_Khaybar_C_F","arifle_Khaybar_GL_F","arifle_MXC_F","arifle_MX_F","arifle_MX_GL_F","arifle_MX_SW_F","arifle_MXM_F","arifle_SDAR_F","arifle_TRG21_F","arifle_TRG20_F","arifle_TRG21_GL_F"]"

Edited by aeroson

Share this post


Link to post
Share on other sites

If you guys want something that works in multiplayer, and I am saying this VERY cautiously as I have not tested it myself, there are actually specific commands called "addWeaponCargoGlobal" etc.

You simply make the script run only on the server, and then use the global commands. AFAIK this is effective, modeled after a script somebody else had used.

Click this spoiler to see the version I mean (does not use config files, but instead uses manually typed lists of items):

/* Arma 3 Weapon Crate Filler
MP Compatible.
Loops when using default quantities.
Does not loop with optional args set.

 Updated:  7 March 2013

 Authors:  Riouken
           Pzar
    dwringer

 Arguments: [box 
  (&optional numBag 
      numItem 
      numMod 
      numWeapon 
      numAmmo)]
*/

if (!isServer) exitWith {};

///init
private ["_box", "_loop", "_wait",
 "_numWeapon", "_numAmmo", "_numMod", "_numItem", "_numBag",
 "_natoWeapons", "_opforWeapons", "_launchers", "_oculars",
 "_cartAmmo", "_launcherAmmo", "_glAmmo", "_manAmmo",
 "_attachments", "_items", "_hats", "_dress", "_chest",
 "_backpacks"];

_box = _this select 0; 
_loop = true; 
// Defaults:
_wait = 500;
_numBag = 0;
_numItem = 50;
_numMod = 50;
_numWeapon = 50;
_numAmmo = 200;

switch (count _this) do { 
case 2 : {
	_numBag = _this select 1;};
case 3 : {
	_numBag = _this select 1;
	_numItem = _this select 2;};
case 4 : {
	_numBag = _this select 1;
	_numItem = _this select 2;
	_numMod = _this select 3;};
case 5 : {
	_numBag = _this select 1;
	_numItem = _this select 2;
	_numMod = _this select 3;
	_numWeapon = _this select 4;};
case 6 : {
	_numBag = _this select 1;
	_numItem = _this select 2;
	_numMod = _this select 3;
	_numWeapon = _this select 4;
	_numAmmo = _this select 5;};};

_natoWeapons = [
"arifle_MX_F",
"arifle_MX_GL_F",
"arifle_MX_SW_F",
"arifle_MXC_F",
"arifle_MXM_F",
"arifle_SDAR_F",
"arifle_TRG20_F",
"arifle_TRG21_F",
"arifle_TRG21_GL_F",
"hgun_P07_F",
"LMG_Mk200_F",
"srifle_EBR_F"
];	

_opforWeapons = [
"arifle_Khaybar_C_F",
"arifle_Khaybar_F",
"arifle_Khaybar_GL_F",
"hgun_Rook40_F"
];

_launchers = [
"launch_NLAW_F",
"launch_RPG32_F"
];

_oculars = [
"Binocular"
];


_cartAmmo = [
"30Rnd_65x39_caseless_green",
"30Rnd_65x39_caseless_green_mag_Tracer",
"30Rnd_65x39_caseless_mag",
"30Rnd_65x39_caseless_mag_Tracer",
"100Rnd_65x39_caseless_mag",
"100Rnd_65x39_caseless_mag_Tracer",
"20Rnd_762x45_mag",
"20Rnd_556x45_UW_mag",
"30Rnd_556x45_Stanag",
"30Rnd_65x39_case_mag",
"30Rnd_65x39_case_mag_Tracer",
"16Rnd_9x21_Mag",
"30Rnd_9x21_Mag",
"200Rnd_65x39_cased_box",
"200Rnd_65x39_cased_box_Tracer"
];

_launcherAmmo = [
"NLAW_F",
"RPG32_F",
"RPG32_AA_F"
];

_glAmmo = [
"1Rnd_HE_Grenade_shell",
"UGL_FlareWhite_F",
"UGL_FlareGreen_F",
"UGL_FlareRed_F",
"UGL_FlareYellow_F",
"UGL_FlareCIR_F",
"1Rnd_Smoke_Grenade_shell",
"1Rnd_SmokeRed_Grenade_shell",
"1Rnd_SmokeGreen_Grenade_shell",
"1Rnd_SmokeYellow_Grenade_shell",
"1Rnd_SmokePurple_Grenade_shell",
"1Rnd_SmokeBlue_Grenade_shell",
"1Rnd_SmokeOrange_Grenade_shell",
"3Rnd_HE_Grenade_shell",
"3Rnd_UGL_FlareWhite_F",
"3Rnd_UGL_FlareGreen_F",
"3Rnd_UGL_FlareRed_F",
"3Rnd_UGL_FlareYellow_F",
"3Rnd_UGL_FlareCIR_F",
"3Rnd_Smoke_Grenade_shell",
"3Rnd_SmokeRed_Grenade_shell",
"3Rnd_SmokeGreen_Grenade_shell",
"3Rnd_SmokeYellow_Grenade_shell",
"3Rnd_SmokePurple_Grenade_shell",
"3Rnd_SmokeBlue_Grenade_shell",
"3Rnd_SmokeOrange_Grenade_shell"
];
// Omitted FlareGreen_F, FlareRed_F, FlareWhite_F, FlareYellow_F, because while they -do- work
//  and load up, I was unable to find a launcher for these ones yet.

_manAmmo = [
"APERSBoundingMine_Range_Mag",
"APERSMine_Range_Mag",
"ATMine_Range_Mag",
"Chemlight_blue",
"Chemlight_green",
"Chemlight_red",
"Chemlight_yellow",
"ClaymoreDirectionalMine_Remote_Mag",
"DemoCharge_Remote_Mag",
"HandGrenade",
"HandGrenade_Stone",
"MiniGrenade",
"SatchelCharge_Remote_Mag",
"SLAMDirectionalMine_Wire_Mag",
"SmokeShell",
"SmokeShellBlue",
"SmokeShellGreen",
"SmokeShellOrange",
"SmokeShellPurple",
"SmokeShellRed",
"SmokeShellYellow"
];


_attachments = [
"acc_flashlight",
"acc_pointer_IR",
"muzzle_snds_B",
"muzzle_snds_H",
"muzzle_snds_H_MG",
"muzzle_snds_L",
"optic_Aco",
"optic_ACO_grn",
"optic_Arco",
"optic_Hamr",
"optic_Holosight"
];
// (I omitted Zasleh2 because it comes up as a blank box for me)

_items = [
"FirstAidKit",
"ItemCompass",
"ItemGPS",
"ItemMap",
"ItemRadio",
"ItemWatch",
"Medikit",
"MineDetector",
"NVGoggles",
"ToolKit"
];

_hats = [
"H_Cap_blu",
"H_Cap_brn_SERO",
"H_Cap_headphones",
"H_Cap_red",
"H_HelmetB",
"H_HelmetB_light",
"H_HelmetB_paint",
"H_HelmetO_ocamo",
"H_MilCap_mcamo",
"H_MilCap_ocamo",
"H_PilotHelmetHeli_B",
"H_PilotHelmetHeli_O"
];
// (left the booniehats out due to no textures)

_dress = [
"U_B_CombatUniform_mcam",
"U_B_CombatUniform_mcam_tshirt",
"U_B_CombatUniform_mcam_vest",
"U_B_HeliPilotCoveralls",
"U_B_Wetsuit",
"U_BasicBody",
"U_C_Commoner1_1",
"U_C_Commoner1_2",
"U_C_Commoner1_3",
"U_C_Poloshirt_blue",
"U_C_Poloshirt_burgundy",
"U_C_Poloshirt_redwhite",
"U_C_Poloshirt_salmon",
"U_C_Poloshirt_stripped",
"U_C_Poloshirt_tricolour",
"U_OI_CombatUniform_ocamo",
"U_OI_PilotCoveralls",
"U_OI_Wetsuit"
//	"U_Rangemaster"
];
// (Note you can only wear your faction's clothing, and I'm not sure 
//  who can even wear rangemaster, so it is commented out)

_chest = [
"V_BandollierB_cbr",
"V_BandollierB_khk",
"V_BandollierB_rgr",
"V_Chestrig_khk",
"V_ChestrigB_rgr",
"V_HarnessO_brn",
"V_HarnessOGL_brn",
"V_PlateCarrier1_cbr",
"V_PlateCarrier1_rgr",
"V_PlateCarrier2_rgr",
"V_PlateCarrierGL_rgr",
"V_Rangemaster_belt",
"V_RebreatherB",
"V_RebreatherIR",
"V_TacVest_brn",
"V_TacVest_khk",
"V_TacVest_oli"
];


_backpacks = [
"B_AssaultPack_Base",
"B_AssaultPack_blk",
"B_AssaultPack_blk_DiverExp",
"B_AssaultPack_blk_DiverTL",
"B_AssaultPack_cbr",
"B_AssaultPack_dgtl",
"B_AssaultPack_khk",
"B_AssaultPack_khk_holder",
"B_AssaultPack_mcamo",
"B_AssaultPack_ocamo",
"B_AssaultPack_rgr",
"B_AssaultPack_rgr_Medic",
"B_AssaultPack_rgr_Repair",
"B_AssaultPack_sgg",
"B_Bergen_Base",
"B_Bergen_sgg",
"B_Bergen_sgg_Exp",
"B_Carryall_Base",
"B_Carryall_ocamo",
"B_Carryall_oucamo",
"B_Carryall_oucamo_Exp",
"B_FieldPack_Base",
"B_FieldPack_blk",
"B_FieldPack_blk_DiverExp",
"B_FieldPack_blk_DiverTL",
"B_FieldPack_cbr",
"B_FieldPack_cbr_AT",
"B_FieldPack_cbr_Repair",
"B_FieldPack_ocamo",
"B_FieldPack_ocamo_Medic",
"B_FieldPack_oucamo",
"B_Kitbag_Base",
"B_Kitbag_cbr",
"B_Kitbag_mcamo",
"B_Kitbag_sgg",
"Bag_Base"
];
// (B_Mk6, B_Mk6Mortar_Support, B_Mk6Mortar_Wpn, and Weapon_Bag_Base omitted due to acting funny, also note 
//  that the *_Medic *_AT etc bags come with stuff in them, and who doesn't like free stuff. Also, *_Base just 
//  comes up as a generic bag, but it does work)



///run
while {_loop && (alive _box)} 
do {
clearMagazineCargo _box;
clearWeaponCargo _box;
clearItemCargoGlobal _box;

{_box addWeaponCargoGlobal [_x, _numWeapon];} 
	forEach (_natoWeapons + _opforWeapons + _launchers + _oculars);

{_box addMagazineCargoGlobal [_x, _numAmmo];} 
	forEach (_cartAmmo + _launcherAmmo + _glAmmo + _manAmmo);

{_box addItemCargoGlobal [_x, _numMod];} 
	forEach (_attachments);

{_box addItemCargoGlobal [_x, _numItem];} 
	forEach (_items + _hats + _dress + _chest);

{_box addBackpackCargoGlobal [_x, _numBag];} 
	forEach (_backpacks);

if ((count _this) > 1) then {
	_loop = false;}
else {
	sleep _wait;};
};



// Also Glasses, I could not get these into a box, so you have to set them on something (or more correctly, 
//  someone!) with a glasses/goggles slot, this also overrides any they have set in preferences, and 
//  interestingly enough, none is implemented as an object, instead of just deleting them:

//this addGoggles "G_Diving";
//this addGoggles "G_Shades_Black";
//this addGoggles "G_Shades_Blue";
//this addGoggles "G_Sport_Blackred";
//this addGoggles "G_Tatical_Clear";
//this addGoggles "None";

<The classname aggregation was done by Pzar, and the multiplayer aspect by Riouken>

To use, save as box_filler.sqf in the mission dir and then in the init field of the box, put :

_handle = [this] execVM "box_filler.sqf"; ;; creates a box with default numbers of everything (50 items, 200 ammo, no bags). refill loops with a default cycle of 500s.

_handle = [this, 5] ;; uses default qty's, but 5 of each bag. no loop.

_handle = [this, 0, 5] ;; uses default qty's, but 5 of each special item. no loop.

. . .

_handle = [this, A, B, C, D, E]; <-where A,B,C,D,E are integers, spawns a crate with A of each bag, B of each item, C of each mod/attachment, D of each weapon type, and E magazines. no loop.

Edited by dwringer

Share this post


Link to post
Share on other sites

Thanks, Tonic, for putting this together and continued work on it.

Do think this bandwidth issue is only for the full version (#0)? Would it be incrementally less bad with smaller things, like the backpack only version (#3)? Would decreasing the number of each object in the crate help?

Share this post


Link to post
Share on other sites

Used a Supply Crate [blue], init line: nul = [this,0,true] execVM "fillCrate.sqf";

added the script to the mission folder,

Tryed in SP: works fine. Tryed in MP/Coop: produces huge ping for other player, the see the crate lying on the side, burning and dissapearing.

Removed crate in MP: everything works fine again.

Whats the problem here? Any solution?

EDIT: @dwringer:

Tried your scripts but they didnt work somehow. Did exactly as the instruction said.

Edited by Dar

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
Sign in to follow this  

×