Main Menu

Script - custom ammo crate

Started by smilodon, December 19, 2014, 09:04:46 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

smilodon

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]
smilodon
Whatever's gone wrong it's not my fault.

smilodon

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.
smilodon
Whatever's gone wrong it's not my fault.

TwoBad

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.
The Battle of Damnation Alley, 25th January 2015
\'You are hereby awarded the Military Cross, posthumously, for an act of exemplary gallantry during active operations against the enemy on land.\'
[SIGPIC][/SIGPIC]

smilodon

Thanks, that was a typo that I missed.
smilodon
Whatever's gone wrong it's not my fault.