Dead Men Walking

Forum Archive 2023 => ARMA => dMw Gaming => Gaming Archive => Map Editors => Topic started by: smilodon on December 19, 2014, 09:04:46 AM

Title: Script - custom ammo crate
Post by: smilodon on December 19, 2014, 09:04:46 AM
I finally found an ammo box script that works on our server. You can use it with any type of ammo box as the script first strips out any existing gear before adding your list in.

In the editor Initialisation box for the ammo crate add the call to the script. I've used a script called ammo_box.sqf but of course you can name your script anything you like that's meaningful
[COLOR=#333333]nul =[this] execVM "ammo_box.sqf";[/COLOR]
Then add the following to a text file and save as an .sqf file in the missions folder. The example empties an ammo box and adds fifty demo charges and fifty first aid kits. The last line repopulates the ammo crate with removed stuff so it always stays full. You can delete this if you want to limit the number of each item in the crate.

if (! isServer) exitWith {};

_crate = _this select 0;

while {alive _crate} do
{


clearMagazineCargoGlobal _crate;
clearWeaponCargoGlobal _crate;
clearItemCargoGlobal _crate;
clearBackpackCargoGlobal -crate;


_crate addMagazineCargoGlobal ["DemoCharge_Remote_Mag", 50];
_crate addItemCargoGlobal ["FirstAidKit", 50];

sleep 500; [COLOR=#333333]};[/COLOR]
Title: Script - custom ammo crate
Post by: smilodon on December 20, 2014, 12:21:34 PM
Quick update: This script doesn't work fully on our server. It adds the new items to the box but for some reason it won't empty the existing contents? My workaround is to use a large metal or plastic container which is already empty. I'm looking for a reason why the script that works fine on a local PC partially fails on a dedicated server, but no luck so far.
Title: Script - custom ammo crate
Post by: TwoBad on December 23, 2014, 09:11:34 AM
smilo

Still a small error which might be affecting things.clearBackpackCargoGlobal -crate;-crate should be _crate

Also, do you run with script errors shown? This may help.  In start up preferences add
Quote-showscripterrors
You may also like these to get things going a little quicker
Quote-noBenchmark -noLogs -noPause -noSplash -world=empty

Once you have -showscripterrors you might see an issue.  If the script runs before you're in the game proper just make one of the ammo boxes run the script off a trigger so once in the game you can just walk up to it and see what happens.
Title: Script - custom ammo crate
Post by: smilodon on December 23, 2014, 09:41:23 AM
Thanks, that was a typo that I missed.