Jump to content
Ethan_B73

Adding Loot to Multiple Crates

Recommended Posts

Hi Guys,

 

I'm having trouble with the second part of my script , I'm hoping someone with more scripting knowledge could give me a hand with this.

My overall goal is to place random markers on the map which will spawn in the objects that I defined in  my script.

So my problem comes when a crate is spawned, no loot is being added to it.

I believe its from the addweaponCargo and addItemCargo.... 

Here is  my script

 

_RdmMapPos = [] call BIS_fnc_randomPos;

for "_i" from 1 to selectRandom [8, 13, 15, 18, 20] do {
      _RdmMapPos = [] call BIS_fnc_randomPos;
            _mkrstr = createMarker [str _RdmMapPos, _RdmMapPos];
            _mkrstr setmarkerShape "ICON";
            _mkrstr setmarkerType "mil_marker";
            _mkrstr setMarkerSize  [1, 1];
};    
{
    _mkrType = getMarkerType _x; 
    switch (_mkrType) do {
        case "mil_marker" : {
            _object = selectRandom ["B_Quadbike_01_F", "Land_WoodenCrate_01_F"];
            createVehicle [_object, getMarkerPos _x, [], 0, "CAN_COLLIDE"];
        };
    };
} forEach allMapMarkers;
{
_crateArray = ["Land_WoodenCrate_01_F"];

 

_gunsArray = ["hgun_P07_F","hgun_ACPC2_snds_F","hgun_P07_F"]; 
 
_ItemsArray = ["rvg_plasticBottle", 
                        "rvg_plasticBottlePurified", 
                        "rvg_canOpener", 
                        "rvg_spirit", 
                        "rvg_franta", 
                        "rvg_beans", 
                        "rvg_bacon", 
                        "rvg_milk", 
                        "rvg_rice", 
                        "rvg_plasticBottleEmpty", 
                        "rvg_canteenEmpty", 
                        "rvg_plasticBottle", 
                        "rvg_plasticBottlePurified", 
                        "rvg_spirit", 
                        "rvg_franta", 
                        "rvg_beans", 
                        "rvg_bacon", 
                        "rvg_milk", 
                        "rvg_rice", 
                        "rvg_money", 
                        "rvg_money", 
                        "rvg_money", 
                        "rvg_money"
                  ];                      
       _crateArray addWeaponCargo [selectRandom _gunsArray, round(random 2)]; 
       _crateArray addItemCargo [selectrandom _ItemsArray, round(random 2)];

};

 

Cheers in advance.

 

Share this post


Link to post
Share on other sites

Hi Spacehippo,

 

thanks for the comment, but unfortunately it hasn't worked for me. I just changed the bottom half of my script to :

 

_crateArray addWeaponCargoGlobal [selectRandom _gunsArray, round(random 2)]; 

_crateArray addItemCargoGlobal [selectrandom _ItemsArray, round(random 2)];

 

please correct me if i'm wrong. 

 

I'm not sure as to what i'm doing wrong 😕.

 

cheers

 

 

 

 

Share this post


Link to post
Share on other sites

Start your script with:

private "_mkrType";

then, when you want to fill your crates:

{

  _x addWeaponCargoGlobal [selectRandom _gunsArray, selectRandom [0,1]]; 
  _x addItemCargoGlobal [selectrandom _ItemsArray, selectRandom [0,1]];

} forEach _crateArray;

An array is an array, even with one unique element.

 

Share this post


Link to post
Share on other sites

Hi pierremgi,

 

thanks for jumping in , I did as you stated above but I'm still not getting any loot inside.

 

this is what i changed:

 

private "_mkrType";

_RdmMapPos = [] call BIS_fnc_randomPos;

for "_i" from 1 to selectRandom [8, 13, 15, 18, 20] do {
      _RdmMapPos = [] call BIS_fnc_randomPos;
            _mkrstr = createMarker [str _RdmMapPos, _RdmMapPos];
            _mkrstr setmarkerShape "ICON";
            _mkrstr setmarkerType "mil_marker";
            _mkrstr setMarkerSize  [1, 1];
};    
{
    _mkrType = getMarkerType _x; 
    switch (_mkrType) do {
        case "mil_marker" : {
            _object = selectRandom ["B_Quadbike_01_F", "Land_WoodenCrate_01_F"];
            createVehicle [_object, getMarkerPos _x, [], 0, "CAN_COLLIDE"];
        };
    };
} forEach allMapMarkers;
{
 
 _crateArray = ["Land_WoodenCrate_01_F"];

 _gunsArray = ["hgun_P07_F","hgun_ACPC2_snds_F","hgun_P07_F"]; 
 
_ItemsArray = ["rvg_plasticBottle", 
                        "rvg_plasticBottlePurified", 
                        "rvg_canOpener", 
                        "rvg_spirit", 
                        "rvg_franta", 
                        "rvg_beans", 
                        "rvg_bacon", 
                        "rvg_milk", 
                        "rvg_rice", 
                        "rvg_plasticBottleEmpty", 
                        "rvg_canteenEmpty", 
                        "rvg_plasticBottle", 
                        "rvg_plasticBottlePurified", 
                        "rvg_spirit", 
                        "rvg_franta", 
                        "rvg_beans", 
                        "rvg_bacon", 
                        "rvg_milk", 
                        "rvg_rice", 
                        "rvg_money", 
                        "rvg_money", 
                        "rvg_money", 
                        "rvg_money"
                  ];
{
    _x addWeaponCargoGlobal [selectRandom _gunsArray, selectRandom [0,1]]; 
    _x addItemCargoGlobal [selectrandom _ItemsArray, selectRandom [0,1]];

} forEach _crateArray;
 


 

Share this post


Link to post
Share on other sites
_gunsArray = [ "hgun_P07_F", "hgun_ACPC2_snds_F", "hgun_P07_F" ]; 
 
_ItemsArray = [
	"rvg_plasticBottle", 
	"rvg_plasticBottle", 
	"rvg_plasticBottlePurified", 
	"rvg_plasticBottlePurified",
	"rvg_canOpener", 
	"rvg_spirit", 
	"rvg_spirit", 
	"rvg_franta",
	"rvg_franta",
	"rvg_beans", 
	"rvg_beans", 
	"rvg_bacon",
	"rvg_bacon",
	"rvg_milk",
	"rvg_milk",
	"rvg_rice",
	"rvg_rice",
	"rvg_plasticBottleEmpty", 
	"rvg_canteenEmpty", 
	"rvg_money",
	"rvg_money",
	"rvg_money",
	"rvg_money"
];

for "_i" from 1 to selectRandom[ 8, 13, 15, 18, 20 ] do {
	_RdmMapPos = [] call BIS_fnc_randomPos;
	_mkrstr = createMarker[ str _RdmMapPos, _RdmMapPos ];
	_mkrstr setMarkerShape "ICON";
	_mkrstr setMarkerType "mil_marker";
	_mkrstr setMarkerSize[ 1, 1 ];
	
	_objectType = selectRandom[ "B_Quadbike_01_F", "Land_WoodenCrate_01_F" ];
	_object = createVehicle[ _objectType, _RdmMapPos, [], 0, "CAN_COLLIDE" ]; 
	
	if ( _objectType == "Land_WoodenCrate_01_F" ) then {
		_object addWeaponCargoGlobal[ selectRandom _gunsArray, round(random 2)]; 
		_object addItemCargoGlobal[ selectRandom _ItemsArray, round(random 2)];
	};
};

 

  • Like 2

Share this post


Link to post
Share on other sites

Hi Larrow,

 

You're the man

 

Thank you very much,  you make it sound so easy 🙂.

 

Cheers

 

 

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

×