Jump to content
Sign in to follow this  
aced170

Need help with ammo box script.

Recommended Posts

I'm attempting to make a script that creates a local ammo box on a marker, then calls a different filler script. I've gotten this far but I'm doing something wrong because the box wont even spawn. This is hacked up domi code by the way.

Here is the code that calls the script in the init

x_playerammobox                 = compile preprocessFile "extern\x_playerammobox.sqf";

The script that should make the box.

private ["_box","_box_array"];

_box = "USVehicleBox_EP1" createVehicleLocal (getMarkerPos "ammobox");

_box allowdamage false;

nul=[_box] execVM "extern\x_weaponcargo_oa_ace.sqf";

The filler script

private "_box";

#define __awc(wtype,wcount) _box addWeaponCargo [#wtype,wcount];
#define __amc(mtype,mcount) _box addMagazineCargo [#mtype,mcount];

clearMagazineCargo _box;
clearWeaponCargo _box;
__awc(M9,1)
__awc(M9SD,1)
etc...

So what have I FUBAR'd?

I also posted this at ARMA Stack, but that seems dead now.

Share this post


Link to post
Share on other sites

create a marker on map called Ammocrate_start.

init.sqf

execvm "Ammoboxjip.sqf";

Ammoboxjip.sqf

_Ammocrate_0 = "USBasicWeapons_EP1" createvehiclelocal (getMarkerPos "Ammocrate_start");
_Ammocrate_0 allowdamage false;
nul=[_Ammocrate_0] execVM "weaponsfiller.sqf";

weaponsfiller.sqf

if (!isdedicated) then                                   //not run on the dedicated server - client side 
{

waituntil {!isnull player};
_ammostuff = _this select 0;
clearmagazineCargoglobal _ammostuff;
//ammo
_ammostuff addMagazineCargoGlobal ["8Rnd_B_Beneli_74Slug",40];
_ammostuff addMagazineCargoGlobal ["NLAW",10];
_ammostuff addMagazineCargoGlobal ["30Rnd_545x39_AK",40];
//weapons
_ammostuff addWeaponCargoglobal [sCAR_L_STD_Mk4CQT,10]; 
};

have run this code with ranking system - works well :)

previous post http://forums.bistudio.com/showthread.php?121955-Ranked-Ammo-crate-and-multiplayer-issues

Share this post


Link to post
Share on other sites

Thanks I got it to work with what you suggested. Is there a way to refresh the contents of the box every ten or so minutes?

Share this post


Link to post
Share on other sites

Yes.


if (!isDedicated) then
{
waitUntil {!isnull player};

_ammostuff = _this select 0;
_refreshdelay = 600;

while {alive _ammostuff} do {
	clearmagazineCargoglobal _ammostuff;
	//ammo
	_ammostuff addMagazineCargoGlobal ["8Rnd_B_Beneli_74Slug",40];
	_ammostuff addMagazineCargoGlobal ["NLAW",10];
	_ammostuff addMagazineCargoGlobal ["30Rnd_545x39_AK",40];

	//weapons
	 _ammostuff addWeaponCargoGlobal [sCAR_L_STD_Mk4CQT,10]; 

	//sleep until refresh
	 sleep _refreshdelay;
};
};

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  

×