Ammo Box script: need help

All right after whole night of testing i made it this far and im still having a few bugs!
Install
Step 1-


Also exe in the init.sqf
Under is dedicated

Code:
    //Spawn ammo boxes
    [] execVM "scripts\ammobox.sqf";

step 2-
open up server_cleanup.sfm

find this
Code:
"{" \n
"    _keep = _x getVariable [""permaLoot"",false];" \n
"    _nearby = {isPlayer _x} count (_x nearEntities [[""CAManBase""], 250]);" \n
"" \n

and change it too.....
Code:
"{" \n
"    _keep = _x getVariable [""permaLoot"",false];" \n
"    _krixKeep = _x getVariable [""KrixKeep"",false];" \n
"    _nearby = {isPlayer _x} count (_x nearEntities [[""CAManBase""], 250]);" \n
"" \n

find this line....
Code:
"    if ( (!_keep) && (_nearby==0) && (_age > 60) ) then {" \n

change it too....
Code:
"    if ( (!_keep) && (_nearby==0) && (_age > 60) && (!_krixKeep) ) then {" \n

step 3-
Make the sqf called ammbox.sqf
and paste the following code in it!

BUGS:
some boxes spawn some don't-
some boxes spawn on top of each other
The content won't set correctly
The boxes will have wrong loot set

MY CODE:


thanks to some help from kirx

Code:
//Ammo box spawn script by ghostphantom172
//Currently working on 1.7.7.1
//---------------------The CODE---------------------
//Box Models
    _ammoBoxModel = ["USBasicAmmunitionBox", "GuerillaCacheBox"] call BIS_fnc_selectRandom;
 
//---------Spawn Boxes------------
 
//-------Box 1 Information--------
//Box attributes
    //box positions
    _boxPos1 = [8110,9149,0]; //Change postion of ammo box one
    _boxPos2 = [5380,5581,0]; //Change postion of ammo box two
    _boxPos3 = [8120,9149,0]; //Change postion of ammo box three
 
//-------Box spawn in--------
 
//Ammo box spawning
 
    //Spawning the box
    _boxtype = _ammoBoxModel;
    _ammoBox = createVehicle [_boxtype, _boxPos1, [], 0, "CAN_COLLIDE"], createVehicle [_boxtype, _boxPos2, [], 0, "CAN_COLLIDE"], createVehicle [_boxtype, _boxPos3, [], 0, "CAN_COLLIDE"];
    _ammoBox setDir 0.0;
 
//----------Box Contents----------
// sleep for a second
    sleep 5;
 
//Clear Items
    clearMagazineCargoGlobal _ammoBox;
    clearWeaponCargoGlobal _ammoBox;
 
//-------Ammo box 1--------------
//standard box
if (_ammoBoxModel == "USBasicAmmunitionBox") then {
    //add items
    _ammoBox addWeaponCargoGlobal ["M16A2", 1]; // for the weapons
    _ammoBox addMagazineCargoGlobal ["30Rnd_556x45_Stanag", 2]; // for the ammo
    _ammoBox addBackpackCargoGlobal ['DZ_Assault_Pack_EP1', 1];
    }
else {
    //add items
    _ammoBox addWeaponCargoGlobal ["DMR", 1]; // for the weapons
    _ammoBox addMagazineCargoGlobal ["20Rnd_762x51_DMR", 2]; // for the ammo
    _ammoBox addBackpackCargoGlobal ['DZ_Backpack_EP1', 1];
    };
 
//-------Set Variable------------
//set variable
    _ammoBox setVariable ["KrixKeep",true,true];

step 4-
add the boxes to your creatvehicle.txt in battleeye should be line #2

Code:
5 "box" !="MedBox0" !="AmmoBoxSmall_556" !="AmmoBoxSmall_762" !="ItemMatchbox" !="ItemToolbox" !="CardBoardBox" !="FoodBox1" !="FoodBox2" !="FoodBox3" !="USBasicAmmunitionBox" !="GuerillaCacheBox"

step 5-
add the boxes to safe objects in variables

and it should be set up for testing
PLEASE I NEED SOME HELP I LAID THE GROUND WORK I JUST NEED SOME HELP!
 
Back
Top