Jump to content
Sign in to follow this  
J. Schmidt

Custom Ammo Box Script Undefined Variable?

Recommended Posts

I've been trying to get this script to work for at least a week now, and I keep getting an error of Undefined Variable, and I've tried many different things and still no luck. Here is the script:

AmmoBox.sqf:

private ["_refreshTime", "_crate"];
_refreshTime = 360; // refill every 5 minutes
_crate = _this select 0;

_crate allowDamage true;

// Loop forever
while {alive _crate} do
{

// Clear Crate
clearWeaponCargo _crate;
clearMagazineCargo _crate;

// Fill Crate
// Automatic Rifle
// Weapons
	_crate addWeaponCargo ["ACE_M249_AIM", 4];
	_crate addWeaponCargo ["M249_EP1", 4];

// Magazines
	_crate addMagazineCargo ["200Rnd_556x45_M249", 48];
	_crate addMagazineCargo ["ACE_200Rnd_556x45_T_M249", 48];

// Rifle
// Weapons
	_crate addWeaponCargo ["ACE_M16A4_GL_UP", 4];
	_crate addWeaponCargo ["ACE_M16A4_Iron", 4];
	_crate addWeaponCargo ["ACE_M4A1_GL_UP", 4];
	_crate addWeaponCargo ["M4A1", 4];

// Magazines
	_crate addMagazineCargo ["30Rnd_556x45_Stanag", 96];
	_crate addMagazineCargo ["ACE_1Rnd_HE_M203", 48];

// Sniper
// Weapons
	_crate addWeaponCargo ["ACE_M109", 2];
	_crate addWeaponCargo ["m107", 2];
	_crate addWeaponCargo ["M24", 2];

// Magazines
	_crate addMagazineCargo ["ACE_5Rnd_25x59_HEDP_Barrett", 12];
	_crate addMagazineCargo ["10Rnd_127x99_m107", 12];
	_crate addMagazineCargo ["5Rnd_762x51_M24", 12];

// Pistol
// Weapons
	_crate addWeaponCargo ["M9", 16];

// Magazines
	_crate addMagazineCargo ["15Rnd_9x19_M9", 88];

// Launcher
// Weapons
	_crate addWeaponCargo ["ACE_Javelin_Direct", 4];
	_crate addWeaponCargo ["ACE_Javelin_CLU", 4];
	_crate addWeaponCargo ["M136", 4];

// Magazines
	_crate addMagazineCargo ["ACE_Javelin_Direct", 8];
	_crate addMagazineCargo ["M136", 8];

// Equipment
// Weapons
	_crate addWeaponCargo ["Binocular", 16];
	_crate addWeaponCargo ["NVGoggles", 16];
	_crate addWeaponCargo ["Laserdesignator", 8];
	_crate addWeaponCargo ["ACE_Rangefinder_OD", 8];

// Magazines
	_crate addMagazineCargo ["HandGrenade_West", 32];
	_crate addMagazineCargo ["SmokeShell", 32];
	_crate addMagazineCargo ["SmokeShellPurple", 32];
	_crate addMagazineCargo ["SmokeShellGreen", 32];
	_crate addMagazineCargo ["SmokeShellRed", 32];
	_crate addMagazineCargo ["ACE_Flashbang", 32];
	_crate addMagazineCargo ["ACE_M7A3", 32];
	_crate addMagazineCargo ["ACE_Knicklicht_R", 32];
	_crate addMagazineCargo ["ACE_Knicklicht_G", 32];
	_crate addMagazineCargo ["ACE_Battery_Rangefinder", 16];
	_crate addMagazineCargo ["Laserbatteries", 16];
	_crate addMagazineCargo ["ACE_C4_M", 8];
	_crate addMagazineCargo ["ACE_CLAYMORE_M", 8];
	_crate addMagazineCargo ["TimeBomb", 8];


// Item
// Weapons
	_crate addWeaponCargo ["ACE_DAGR", 16];
	_crate addWeaponCargo ["ACE_Earplugs", 16];
	_crate addWeaponCargo ["ACE_GlassesGasMask_US", 16];
	_crate addWeaponCargo ["ACE_GlassesLHD_glasses", 16];
	_crate addWeaponCargo ["ACE_KeyCuffs", 16];
	_crate addWeaponCargo ["ACE_Map", 16];
	_crate addWeaponCargo ["ACE_Map_Tools", 16];
	_crate addWeaponCargo ["ACE_SpottingScope", 16];
	_crate addWeaponCargo ["ItemCompass", 16];
	_crate addWeaponCargo ["ItemWatch", 16];
	_crate addWeaponCargo ["ACE_MineMarkers", 16];
	_crate addWeaponCargo ["ACE_GlassesBalaklava", 16];
	_crate addWeaponCargo ["ACE_Kestrel4500", 8];
	_crate addWeaponCargo ["ACE_SpareBarrel", 4];

// Medical Equipment
// Magazines
	_crate addMagazineCargo ["ACE_Bandage", 40];
	_crate addMagazineCargo ["ACE_Epinephrine", 40];
	_crate addMagazineCargo ["ACE_IV", 40];
	_crate addMagazineCargo ["ACE_LargeBandage", 40];
	_crate addMagazineCargo ["ACE_Medkit", 40];
	_crate addMagazineCargo ["ACE_Morphine", 40];
	_crate addMagazineCargo ["ACE_Plasma", 40];
	_crate addMagazineCargo ["ACE_Splint", 40];
	_crate addMagazineCargo ["ACE_Tourniquet", 40];
	_crate addMagazineCargo ["ACE_Bodybag", 40];
// Ruck
// Weapons
	_crate addWeaponCargo ["ACE_AssaultPack_BAF", 16];

sleep 1800;
};

---------- Post added at 06:38 PM ---------- Previous post was at 06:00 PM ----------

Solved. After playing around with the script a bit more I was able to get it to work.

Ammo.sqf

_refreshTime = 360; // refill every 5 minutes
_this allowDamage true;

// Loop forever
while {true} do
{

// Clear Crate
clearWeaponCargo _this;
clearMagazineCargo _this;

// Fill Crate
// Automatic Rifle
// Weapons
	_this addWeaponCargo ["ACE_M249_AIM", 4];
	_this addWeaponCargo ["M249_EP1", 4];

// Magazines
	_this addMagazineCargo ["200Rnd_556x45_M249", 48];
	_this addMagazineCargo ["ACE_200Rnd_556x45_T_M249", 48];

// Rifle
// Weapons
	_this addWeaponCargo ["ACE_M16A4_GL_UP", 4];
	_this addWeaponCargo ["ACE_M16A4_Iron", 4];
	_this addWeaponCargo ["ACE_M4A1_GL_UP", 4];
	_this addWeaponCargo ["M4A1", 4];

// Magazines
	_this addMagazineCargo ["30Rnd_556x45_Stanag", 96];
	_this addMagazineCargo ["ACE_1Rnd_HE_M203", 48];

// Sniper
// Weapons
	_this addWeaponCargo ["ACE_M109", 2];
	_this addWeaponCargo ["m107", 2];
	_this addWeaponCargo ["M24", 2];

// Magazines
	_this addMagazineCargo ["ACE_5Rnd_25x59_HEDP_Barrett", 12];
	_this addMagazineCargo ["10Rnd_127x99_m107", 12];
	_this addMagazineCargo ["5Rnd_762x51_M24", 12];

// Pistol
// Weapons
	_this addWeaponCargo ["M9", 16];

// Magazines
	_this addMagazineCargo ["15Rnd_9x19_M9", 88];

// Launcher
// Weapons
	_this addWeaponCargo ["ACE_Javelin_Direct", 4];
	_this addWeaponCargo ["ACE_Javelin_CLU", 4];
	_this addWeaponCargo ["M136", 4];

// Magazines
	_this addMagazineCargo ["ACE_Javelin_Direct", 8];
	_this addMagazineCargo ["M136", 8];

// Equipment
// Weapons
	_this addWeaponCargo ["Binocular", 16];
	_this addWeaponCargo ["NVGoggles", 16];
	_this addWeaponCargo ["Laserdesignator", 8];
	_this addWeaponCargo ["ACE_Rangefinder_OD", 8];

// Magazines
	_this addMagazineCargo ["HandGrenade_West", 32];
	_this addMagazineCargo ["SmokeShell", 32];
	_this addMagazineCargo ["SmokeShellPurple", 32];
	_this addMagazineCargo ["SmokeShellGreen", 32];
	_this addMagazineCargo ["SmokeShellRed", 32];
	_this addMagazineCargo ["ACE_Flashbang", 32];
	_this addMagazineCargo ["ACE_M7A3", 32];
	_this addMagazineCargo ["ACE_Knicklicht_R", 32];
	_this addMagazineCargo ["ACE_Knicklicht_G", 32];
	_this addMagazineCargo ["ACE_Battery_Rangefinder", 16];
	_this addMagazineCargo ["Laserbatteries", 16];
	_this addMagazineCargo ["ACE_C4_M", 8];
	_this addMagazineCargo ["ACE_CLAYMORE_M", 8];
	_this addMagazineCargo ["TimeBomb", 8];


// Item
// Weapons
	_this addWeaponCargo ["ACE_DAGR", 16];
	_this addWeaponCargo ["ACE_Earplugs", 16];
	_this addWeaponCargo ["ACE_GlassesGasMask_US", 16];
	_this addWeaponCargo ["ACE_GlassesLHD_glasses", 16];
	_this addWeaponCargo ["ACE_KeyCuffs", 16];
	_this addWeaponCargo ["ACE_Map", 16];
	_this addWeaponCargo ["ACE_Map_Tools", 16];
	_this addWeaponCargo ["ACE_SpottingScope", 16];
	_this addWeaponCargo ["ItemCompass", 16];
	_this addWeaponCargo ["ItemWatch", 16];
	_this addWeaponCargo ["ACE_MineMarkers", 16];
	_this addWeaponCargo ["ACE_GlassesBalaklava", 16];
	_this addWeaponCargo ["ACE_Kestrel4500", 8];
	_this addWeaponCargo ["ACE_SpareBarrel", 4];

// Medical Equipment
// Magazines
	_this addMagazineCargo ["ACE_Bandage", 40];
	_this addMagazineCargo ["ACE_Epinephrine", 40];
	_this addMagazineCargo ["ACE_IV", 40];
	_this addMagazineCargo ["ACE_LargeBandage", 40];
	_this addMagazineCargo ["ACE_Medkit", 40];
	_this addMagazineCargo ["ACE_Morphine", 40];
	_this addMagazineCargo ["ACE_Plasma", 40];
	_this addMagazineCargo ["ACE_Splint", 40];
	_this addMagazineCargo ["ACE_Tourniquet", 40];
	_this addMagazineCargo ["ACE_Bodybag", 40];
// Ruck
// Weapons
	_this addWeaponCargo ["ACE_AssaultPack_BAF", 16];

sleep _refreshTime;
};

And in the Init Box of the AmmoBox I put:

_Handle = this execVM "scr\ammo.sqf";

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  

×