Jump to content
Chuc

Random Vehicle loot Script

Recommended Posts

So i have made a half arsed script to spawn loot into vehicles. It works quite well. Any vehicle on the map that defines as a "car" will have my random array of loot spawn into it. You get 4 guns with random amount of ammo, sometimes not for the guns in the car. You get some clothes, vests, food, items and backpacks all random amounts. The problem i have it that each car will have the exact same Guns in them but everything else will be different. I have another script that spawns random cars all over, i went to a few of them each time i ran a test and they all had the same guns but everything else was different. I edited the loot script alot but still cant seem to figure out why the guns are all the same. So im here to see if anyone can help me.

 

Original Script. Didnt work to good

Spoiler

here is my script. Its not very good and could probably have been done better but i did it most of it my self. Basically butchered 2 loot scripts i had found to spawn loot on the ground to make my vehicle loot but theres not much left of them. 

Well here you go my script, after a few hours i rewrote the thing from scratch and cant figure out why all cars get the same guns and only the guns.

 

if (isServer) then {
    pistolLoot =
                    [
                         //Bnae Pistols
                        "bnae_r1_virtual",
                        "bnae_r1_e_virtual",
                        "bnae_r1_t_virtual",
                        "bnae_saa_virtual",
                        "rhsusf_weap_m9",
                        "bnae_l35_c_virtual",
                        "rhsusf_weap_m1911a1",
                        "CUP_hgun_Colt1911",
                        "rhsusf_weap_glock17g4",
                        "rhsusf_weap_m1911a1"
                    ];


    ShotGunLoot =
                    [
                          //Bnae shotguns
                        "bnae_m97_virtual",
                        "bnae_m97_camo1_virtual",
                        "bnae_spr220_virtual",
                        "bnae_spr220_camo1_virtual",
                        "bnae_spr220_so_virtual",
                        "bnae_spr220_so_camo1_virtual",
                        "rhs_weap_M590_8RD",
                        "rhs_weap_M590_5RD",
                        "CUP_sgun_M1014"
                    ];

    foodLoot =
                    [
                        //Ravage Items
                        "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"
                    ];


    itemsLoot =
                    [
                        //Vanilla items
                        "Item_optic_LRPS",
                        "Item_bipod_01_F_khk",
                        //RHS Items
                        "rhsusf_acc_M8541",
                        "rhsusf_acc_premier",
                        "rhsusf_acc_LEUPOLDMK4",
                        "rhsusf_acc_LEUPOLDMK4_2",
                        "rhsusf_acc_harris_bipod",
                        //CUP Items
                        "CUP_optic_LeupoldMk4",
                        "CUP_optic_Leupold_VX3",
                        "CUP_bipod_Harris_1A2_L",
                        "CUP_bipod_VLTOR_Modpod",
                        //Ravage Items
                        "Binocular",
                        "FirstAidKit",
                        "Medikit",
                        "ItemMap",
                           "rvg_canisterFuel_Empty",
                        "rvg_toolkit",
                        "rvg_tire",
                        "rvg_money",
                        "rvg_docFolder",
                        "rvg_money",
                        "rvg_hose",
                        "rvg_guttingKnife",
                        "rvg_foldedTent",
                        "rvg_matches",
                        "rvg_foldedTent"
                    ];

    clothesLoot =
                    [
                           "U_C_Journalist",
                           "U_C_Poloshirt_blue",
                           "U_C_Poloshirt_burgundy",
                           "U_C_Poloshirt_salmon",
                           "U_C_Poloshirt_stripped",
                           "U_C_Poloshirt_tricolour",
                           "U_C_Poor_1",
                           "U_C_Poor_2",
                           "U_C_Poor_shorts_1",
                           "U_C_Scientist",
                           "U_OrestesBody",
                           "U_Rangemaster",
                           "U_NikosAgedBody",
                           "U_NikosBody",
                           "U_Competitor",
                           "U_I_G_resistanceLeader_F",
                           "U_C_man_sport_1_F",
                           "U_C_man_sport_2_F",
                           "U_C_man_sport_3_F",
                           "U_C_Man_casual_1_F",
                           "U_C_Man_casual_2_F",
                           "U_C_Man_casual_3_F",
                           "U_C_Man_casual_4_F",
                           "U_C_Man_casual_5_F",
                           "U_C_Man_casual_6_F",
                           "H_Helmet_Skate",
                           "H_Hat_brown",
                           "rhs_Booniehat_ocp",
                           "rhs_beanie_green",
                           "U_B_T_FullGhillie_tna_F",
                        "U_IG_Guerilla1_1",
                           "U_IG_Guerilla2_1",
                           "U_IG_Guerilla2_2",
                           "U_IG_Guerilla2_3",
                           "U_IG_Guerilla3_1",
                           "U_BG_Guerilla2_1",
                           "U_IG_Guerilla3_2",
                           "U_BG_Guerrilla_6_1",
                           "U_BG_Guerilla1_1",
                           "U_BG_Guerilla2_2",
                           "U_BG_Guerilla2_3",
                           "U_BG_Guerilla3_1"
                    ];


    vestsLoot =
                    [
                        "V_Rangemaster_belt",
                        "rhs_vest_commander",
                        "rhs_vest_pistol_holster",
                        "Vest_V_Press_F",
                        "rhs_6sh46"
                    ];


    backpacksLoot =
                    [
                        "B_AssaultPack_rgr",
                        "B_Kitbag_rgr",
                        "B_TacticalPack_rgr",
                        "B_Respawn_Sleeping_bag_blue_F",
                        "B_Respawn_Sleeping_bag_brown_F",
                        "B_Respawn_TentDome_F",
                        "B_Respawn_Sleeping_bag_F",
                        "B_Respawn_TentA_F",
                        "rhs_sidor",
                        "B_Carryall_cbr",
                         "B_Carryall_khk",
                         "B_Carryall_mcamo",
                         "B_Carryall_ocamo",
                         "B_Carryall_oli",
                         "B_Carryall_oucamo"
                    ];

     _Rifle_Array =    [
                         //RHS Weapons
                         "rhs_weap_m14ebrri",
                         //Bnae Snipers
                         "bnae_mk1_virtual",
                         //CUP Rifles
                         "CUP_rifle_LeeEnfield",
                         "CUP_srifle_M14",
                         "CUP_smg_MP5A5",
                         "CUP_srifle_LeeEnfield_rail"
                 ]call BIS_fnc_selectRandom;

 

     _Sniper_Array = [
                        //CUP Weapons
                        "CUP_srifle_CZ550",
                        "CUP_srifle_M24_des_LeupoldMk4LRT",
                        "CUP_srifle_M24_wdl_LeupoldMk4LRT"
                     ]call BIS_fnc_selectRandom;

 

        private _ShotGun = selectRandom ShotGunLoot;
        private _config = [
            "cfgMagazines",
            "cfgWeapons"
            ] select (isClass (configFile >> "cfgWeapons" >> _ShotGun));

      

      private _ShotGun_magazines = [
            configFile >> _config >> _ShotGun >> "magazines",
            configFile >> _config >> _ShotGun
        ] select (_config isEqualTo "cfgMagazines");

     

   private _pistol = selectRandom pistolLoot;
        private _config = [
            "cfgMagazines",
            "cfgWeapons"
            ] select (isClass (configFile >> "cfgWeapons" >> _pistol));

   

    private _pistol_magazines = [
            configFile >> _config >> _pistol >> "magazines",
            configFile >> _config >> _pistol
        ] select (_config isEqualTo "cfgMagazines");

 

      _Rifle_magazines = getArray (configFile / "CfgWeapons" / _Rifle_Array / "magazines");
        _magazineClass_Rifle = _Rifle_magazines call Bis_fnc_selectRandom;

   

    _Sniper_magazines = getArray (configFile / "CfgWeapons" / _Sniper_Array / "magazines");
        _magazineClass_Sniper = _Sniper_magazines call Bis_fnc_selectRandom;

 

["Car", "init",
    {
         (_this select 0) addWeaponCargoGlobal [_ShotGun, 1];
          private _arr = getArray _ShotGun_magazines; // ShotGun Mags
         (_this select 0) addMagazineCargoGlobal [selectRandom _arr, round(random 2)];

 

       (_this select 0) addWeaponCargoGlobal [_pistol, 1];
          private _arr2 = getArray _pistol_magazines; // Pistol Mags
         (_this select 0) addMagazineCargoGlobal [selectRandom _arr2, round(random 2)];

  

       private _arr = getArray _pistol_magazines; // Pistol Mags
         (_this select 0) addMagazineCargoGlobal [[selectRandom _arr, _pistol] select (_arr isEqualTo []), round(random 1)];  // pistolLoot

        

       private _arr = getArray _ShotGun_magazines; // ShotGun Mags
         (_this select 0) addMagazineCargoGlobal [[selectRandom _arr, _ShotGun] select (_arr isEqualTo []), round(random 1)]; // ShotGunLoot

 

         (_this select 0) addWeaponCargoGlobal [_Sniper_Array, round(random 1)];
         (_this select 0) addWeaponCargoGlobal [_Rifle_Array, 1];

 

//       (_this select 0) addMagazineCargoGlobal [_magazineClass_Rifle, round(random 2)];  //_Rifle_magazines _Rifle_Array


         (_this select 0) addMagazineCargoGlobal [_magazineClass_Rifle, round(random 2)]; //_Rifle_magazines _Rifle_Array
         (_this select 0) addMagazineCargoGlobal [_magazineClass_Sniper, round(random 2)]; //_Sniper_magazines _Sniper_Array

 

         (_this select 0) addItemCargoGlobal [selectRandom foodLoot, ceil(random 3)];
         (_this select 0) addItemCargoGlobal [selectRandom foodLoot, round(random 3)];
         (_this select 0) addItemCargoGlobal [selectRandom itemsLoot, 1];
         (_this select 0) addItemCargoGlobal [selectRandom itemsLoot, 1];
         (_this select 0) addItemCargoGlobal [selectRandom clothesLoot, round(random 1)];
         (_this select 0) addItemCargoGlobal [selectRandom clothesLoot, 1];
         (_this select 0) addItemCargoGlobal [selectRandom vestsLoot, 0 + (random 1)];
         (_this select 0) addItemCargoGlobal [selectRandom vestsLoot, 1];
         (_this select 0) addBackpackCargoGlobal [selectRandom backpacksLoot, round(random 2)];
    }, true, [], true] call CBA_fnc_addClassEventHandler;
};

 

 

Any help would be great. Really dont want every car to have the same guns, that wouldn't be very fun. 

 

Anyone can feel free to use this if they would like, doesn't worry me at all. I searched high and low and couldn't find any script that gave vehicles loot.

 

THis is an edited one that will weapons form there arrays at random and add ammo for them. Should be random for each car.

Spoiler

if (isServer) then {
    _pistolLoot =
                    [
                         //Bnae Pistols
                        "bnae_r1_virtual",
                        "bnae_r1_e_virtual",
                        "bnae_r1_t_virtual",
                        "bnae_saa_virtual",
                        "rhsusf_weap_m9",
                        "bnae_l35_c_virtual",
                        "CUP_hgun_Colt1911",
                        "rhsusf_weap_glock17g4",
                        "CUP_hgun_TaurusTracker455"
                    ];


    _ShotGunLoot =
                    [
                          //Bnae shotguns
                        "bnae_m97_virtual",
                        "bnae_m97_camo1_virtual",
                        "bnae_m97_s_virtual",
                        "bnae_spr220_virtual",
                        "bnae_spr220_camo1_virtual",
                        "bnae_spr220_so_virtual",
                        "bnae_spr220_so_camo1_virtual",
                        "bnae_spr220_so_virtual"
                    ];

    foodLoot =
                    [
                        //Ravage Items
                        "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"
                    ];


    itemsLoot =
                    [
                        "ryan_ruger77_optic_SOS",
                        "acc_flashlight",
                        //Dagger Items
                        "Dagger_10x_Round_Dot",
                        "Dagger_12x_Round_Dot_Gen2",
                        "Dagger_16x_Round_Dot",
                        //Bnae Items
                        "bnae_scope_blk_virtual",
                        "bnae_bipod_blk_virtual",
                        //Vanilla items
                        "Item_optic_LRPS",
                        "Item_bipod_01_F_khk",
                        //RHS Items
                        "rhsusf_acc_M8541",
                        "rhsusf_acc_premier",
                        "rhsusf_acc_LEUPOLDMK4",
                        "rhsusf_acc_LEUPOLDMK4_2",
                        "rhsusf_acc_harris_bipod",
                        //CUP Items
                        "CUP_optic_LeupoldMk4",
                        "CUP_optic_Leupold_VX3",
                        "CUP_bipod_Harris_1A2_L",
                        "CUP_bipod_VLTOR_Modpod",
                        //Ravage Items
                        "Binocular",
                        "FirstAidKit",
                        "Medikit",
                        "ItemMap",
                           "rvg_canisterFuel_Empty",
                        "rvg_toolkit",
                        "rvg_tire",
                        "rvg_money",
                        "rvg_docFolder",
                        "rvg_money",
                        "rvg_hose",
                        "rvg_guttingKnife",
                        "rvg_foldedTent",
                        "rvg_matches",
                        "rvg_foldedTent"
                    ];

    clothesLoot =
                    [
                           "U_C_Journalist",
                           "U_C_Poloshirt_blue",
                           "U_C_Poloshirt_burgundy",
                           "U_C_Poloshirt_salmon",
                           "U_C_Poloshirt_stripped",
                           "U_C_Poloshirt_tricolour",
                           "U_C_Poor_1",
                           "U_C_Poor_2",
                           "U_C_Poor_shorts_1",
                           "U_C_Scientist",
                           "U_OrestesBody",
                           "U_Rangemaster",
                           "U_NikosAgedBody",
                           "U_NikosBody",
                           "U_Competitor",
                           "U_I_G_resistanceLeader_F",
                           "U_C_man_sport_1_F",
                           "U_C_man_sport_2_F",
                           "U_C_man_sport_3_F",
                           "U_C_Man_casual_1_F",
                           "U_C_Man_casual_2_F",
                           "U_C_Man_casual_3_F",
                           "U_C_Man_casual_4_F",
                           "U_C_Man_casual_5_F",
                           "U_C_Man_casual_6_F",
                           "H_Helmet_Skate",
                           "H_Hat_brown",
                           "rhs_Booniehat_ocp",
                           "rhs_beanie_green",
                           "U_B_T_FullGhillie_tna_F",
                           "U_IG_Guerilla1_1",
                           "U_IG_Guerilla2_1",
                           "U_IG_Guerilla2_2",
                           "U_IG_Guerilla2_3",
                           "U_IG_Guerilla3_1",
                           "U_BG_Guerilla2_1",
                           "U_IG_Guerilla3_2",
                           "U_BG_Guerrilla_6_1",
                           "U_BG_Guerilla1_1",
                           "U_BG_Guerilla2_2",
                           "U_BG_Guerilla2_3",
                           "U_BG_Guerilla3_1"
                    ];


    vestsLoot =
                    [
                        "V_Rangemaster_belt",
                        "rhs_vest_commander",
                        "rhs_vest_pistol_holster",
                        "Vest_V_Press_F",
                        "rhs_6sh46",
                        "dgr_coat5",
                        "dgr_coat6",
                        "dgr_coat7",
                        "dgr_coat8"
                    ];


    backpacksLoot =
                    [
                        "B_AssaultPack_rgr",
                        "B_Kitbag_rgr",
                        "B_TacticalPack_rgr",
                        "B_Respawn_Sleeping_bag_blue_F",
                        "B_Respawn_Sleeping_bag_brown_F",
                        "B_Respawn_TentDome_F",
                        "B_Respawn_Sleeping_bag_F",
                        "B_Respawn_TentA_F",
                        "rhs_sidor",
                        "B_Carryall_cbr",
                         "B_Carryall_khk",
                         "B_Carryall_mcamo",
                         "B_Carryall_ocamo",
                         "B_Carryall_oli",
                         "B_Carryall_oucamo"
                    ];

     _Rifle_Array =    [
                         //RHS Weapons
                         "rhs_weap_m14ebrri",
                         //Bnae Snipers
                         "bnae_mk1_virtual",
                         //CUP Rifles
                         "CUP_srifle_M14",
                         "dgr_22",
                         "dgr_220",
                         "dgr_223",
                         "ryan_ruger77"
                 ];

     _Sniper_Array = [
                        //CUP Weapons
                        "CUP_srifle_CZ550",
                        "CUP_smg_MP5A5",
                        "CUP_srifle_M24_des_LeupoldMk4LRT",
                        "CUP_srifle_M24_wdl_LeupoldMk4LRT",
                        "bnae_falkor_blk_virtual",
                        "dgr_3006",
                        "dgr_257",
                        "dgr_270",
                        "dgr_300blk",
                        "dgr_308_m40_3",
                        "ryan_ruger77scope"
                     ];


["Car", "init",
    {
        _RndPistol = selectRandom _PistolLoot;
        _Pistol_Magazines = getArray (configFile / "CfgWeapons" / _RndPistol / "magazines");
        _MagazineClass_Pistol = _Pistol_Magazines call Bis_fnc_selectRandom;

 

        _RndShotGun = selectRandom _ShotGunLoot;
        _ShotGun_Magazines = getArray (configFile / "CfgWeapons" / _RndShotGun / "magazines");
        _MagazineClass_ShotGun = _ShotGun_Magazines call Bis_fnc_selectRandom;


        _RndRifle = selectRandom _Rifle_Array;
        _Rifle_Magazines = getArray (configFile / "CfgWeapons" / _RndRifle / "magazines");
        _MagazineClass_Rifle = _Rifle_Magazines call Bis_fnc_selectRandom;

 

        _RndSniper = selectRandom _Sniper_Array;
        _Sniper_Magazines = getArray (configFile / "CfgWeapons" / _RndSniper / "magazines");
        _MagazineClass_Sniper = _Sniper_Magazines call Bis_fnc_selectRandom;


         (_this select 0) addWeaponCargo [_RndPistol, 1];
         (_this select 0) addWeaponCargo [_RndShotGun, 1];
         (_this select 0) addWeaponCargo [_RndRifle, 1];
         (_this select 0) addWeaponCargo [_RndSniper, 1];

         (_this select 0) addMagazineCargoGlobal [_MagazineClass_Pistol, 1];
         (_this select 0) addMagazineCargoGlobal [_MagazineClass_ShotGun, 1];
         (_this select 0) addMagazineCargoGlobal [_MagazineClass_Rifle, 1];
         (_this select 0) addMagazineCargoGlobal [_MagazineClass_Sniper, 1];

         (_this select 0) addMagazineCargoGlobal [selectRandom _Sniper_Magazines, 1];

         (_this select 0) addItemCargoGlobal [selectRandom foodLoot, ceil(random 3)];
         (_this select 0) addItemCargoGlobal [selectRandom foodLoot, round(random 3)];
         (_this select 0) addItemCargoGlobal [selectRandom itemsLoot, 1];
         (_this select 0) addItemCargoGlobal [selectRandom itemsLoot, 1];
         (_this select 0) addItemCargoGlobal [selectRandom clothesLoot, round(random 1)];
         (_this select 0) addItemCargoGlobal [selectRandom clothesLoot, 1];
         (_this select 0) addItemCargoGlobal [selectRandom vestsLoot, 0 + (random 1)];
         (_this select 0) addItemCargoGlobal [selectRandom vestsLoot, 1];
         (_this select 0) addBackpackCargoGlobal [selectRandom backpacksLoot, round(random 2)];
    }, true, [], true] call CBA_fnc_addClassEventHandler;
};

 

 

This is my finished script that will spawn guns and ammo at random. Luck of the draw if you happen to get ammo with the guns in the car. Should be random for every car spawned or placed in editor

Spoiler


if (isServer) then {
    pistolLoot =
                    [
                         //Bnae Pistols
                        "bnae_r1_virtual",
                        "bnae_r1_e_virtual",
                        "bnae_r1_t_virtual",
                        "bnae_saa_virtual",
                        "rhsusf_weap_m9",
                        "bnae_l35_c_virtual",
                        "CUP_hgun_Colt1911",
                        "rhsusf_weap_glock17g4",
                        "CUP_hgun_TaurusTracker455"
 //                       "Hatchet",
 //                       "KA_knife",
 //                       "KA_dagger"
                    ];
    ShotGunLoot =
                    [
                          //Bnae shotguns
                        "bnae_m97_virtual",
                        "bnae_m97_camo1_virtual",
                        "bnae_m97_s_virtual",
                        "bnae_spr220_virtual",
                        "bnae_spr220_camo1_virtual",
                        "bnae_spr220_so_virtual",
                        "bnae_spr220_so_camo1_virtual"
                    ];
    // Set items: Weapon attachments, first-aid, Binoculars
    foodLoot =
                    [
                        //Ravage Items
                        "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"
                    ];
    itemsLoot =
                    [
                        "ryan_ruger77_optic_SOS",
                        "acc_flashlight",
                        //Dagger Items
                        "Dagger_10x_Round_Dot",
                        "Dagger_12x_Round_Dot_Gen2",
                        "Dagger_16x_Round_Dot",
                        //Bnae Items
                        "bnae_scope_blk_virtual",
                        "bnae_bipod_blk_virtual",
                        //Vanilla items
                        "Item_optic_LRPS",
                        "Item_bipod_01_F_khk",
                        //RHS Items
                        "rhsusf_acc_M8541",
                        "rhsusf_acc_premier",
                        "rhsusf_acc_LEUPOLDMK4",
                        "rhsusf_acc_LEUPOLDMK4_2",
                        "rhsusf_acc_harris_bipod",
                        //CUP Items
                        "CUP_optic_LeupoldMk4",
                        "CUP_optic_Leupold_VX3",
                        "CUP_bipod_Harris_1A2_L",
                        "CUP_bipod_VLTOR_Modpod",
                        //Ravage Items
                        "Binocular",
                        "FirstAidKit",
                        "Medikit",
                        "ItemMap",
                           "rvg_canisterFuel_Empty",
                        "rvg_toolkit",
                        "rvg_tire",
                        "rvg_money",
                        "rvg_docFolder",
                        "rvg_money",
                        "rvg_hose",
                        "rvg_guttingKnife",
                        "rvg_foldedTent",
                        "rvg_matches",
                        "rvg_foldedTent"
                    ];
    // Set Clothing: Hats, Helmets, Uniforms
    clothesLoot =
                    [
                           "U_C_Journalist",
                           "U_C_Poloshirt_blue",
                           "U_C_Poloshirt_burgundy",
                           "U_C_Poloshirt_salmon",
                           "U_C_Poloshirt_stripped",
                           "U_C_Poloshirt_tricolour",
                           "U_C_Poor_1",
                           "U_C_Poor_2",
                           "U_C_Poor_shorts_1",
                           "U_C_Scientist",
                           "U_OrestesBody",
                           "U_Rangemaster",
                           "U_NikosAgedBody",
                           "U_NikosBody",
                           "U_Competitor",
                           "U_I_G_resistanceLeader_F",
                           "U_C_man_sport_1_F",
                           "U_C_man_sport_2_F",
                           "U_C_man_sport_3_F",
                           "U_C_Man_casual_1_F",
                           "U_C_Man_casual_2_F",
                           "U_C_Man_casual_3_F",
                           "U_C_Man_casual_4_F",
                           "U_C_Man_casual_5_F",
                           "U_C_Man_casual_6_F",
                           "H_Helmet_Skate",
                           "H_Hat_brown",
                           "rhs_Booniehat_ocp",
                           "rhs_beanie_green",
                           "U_B_T_FullGhillie_tna_F",
                        "U_IG_Guerilla1_1",
                           "U_IG_Guerilla2_1",
                           "U_IG_Guerilla2_2",
                           "U_IG_Guerilla2_3",
                           "U_IG_Guerilla3_1",
                           "U_BG_Guerilla2_1",
                           "U_IG_Guerilla3_2",
                           "U_BG_Guerrilla_6_1",
                           "U_BG_Guerilla1_1",
                           "U_BG_Guerilla2_2",
                           "U_BG_Guerilla2_3",
                           "U_BG_Guerilla3_1"
 //                          "HITMAN_47_SUIT"
                    ];

    // Set Vests: Any vests
    vestsLoot =
                    [
                        "V_Rangemaster_belt",
                        "rhs_vest_commander",
                        "rhs_vest_pistol_holster",
                        "Vest_V_Press_F",
                        "rhs_6sh46",
//                        "HITMAN_47_Hidden_Vest",
                        "dgr_coat5",
                        "dgr_coat6",
                        "dgr_coat7",
                        "dgr_coat8"
                    ];

    // Set Backpacks: Any packpacks
    backpacksLoot =
                    [
                        "B_AssaultPack_rgr",
                        "B_Kitbag_rgr",
                        "B_TacticalPack_rgr",
                        "B_Respawn_Sleeping_bag_blue_F",
                        "B_Respawn_Sleeping_bag_brown_F",
                        "B_Respawn_TentDome_F",
                        "B_Respawn_Sleeping_bag_F",
                        "B_Respawn_TentA_F",
                        "rhs_sidor",
                        "B_Carryall_cbr",
                         "B_Carryall_khk",
                         "B_Carryall_mcamo",
                         "B_Carryall_ocamo",
                         "B_Carryall_oli",
                         "B_Carryall_oucamo"
                    ];

     RifleLoot =    [
                         //RHS Weapons
                         "rhs_weap_m14ebrri",
                         //Bnae Snipers
                         "bnae_mk1_virtual",
                         //CUP Rifles
                         "CUP_srifle_M14",
                         "dgr_22",
                         "dgr_220",
                         "dgr_223",
                         "ryan_ruger77"
                     ];

     SniperLoot =   [
                        //CUP Weapons
                        "CUP_srifle_CZ550",
                        "CUP_smg_MP5A5",
                        "CUP_srifle_M24_des_LeupoldMk4LRT",
                        "CUP_srifle_M24_wdl_LeupoldMk4LRT",
                        "bnae_falkor_blk_virtual",
 //                       "KA_crossbow_black",
 //                       "KA_crossbow_wood",
                        "dgr_3006",
                        "dgr_257",
                        "dgr_270",
                        "dgr_300blk",
                        "dgr_308_m40_3",
                        "ryan_ruger77scope"
                    ];

          ////////////// Magazines //////////////
     Mag_Rifle =    [
                        "rhsusf_20Rnd_762x51_m993_Mag",
                        "ryan_ruger77magazine",
                        "10Rnd_303_Magazine",
                        "CUP_20Rnd_762x51_DMR",
                        "20Rnd_762x51_Mag",

                        "DGR_22_Match_20Rnd",
                        "DGR_220_20Rnd",
                        "DGR_224_M193_10Rnd"
                    ];

     Mag_Sniper =   [
                        "ryan_ruger77magazine",
                        "10Rnd_300WM_Magazine",
                        "CUP_5x_22_LR_17_HMR_M",
                        "CUP_5Rnd_762x51_M24",
                        "CUP_30Rnd_9x19_MP5",
                        "DGR_257_10Rnd",
                        "DGR_270_10Rnd",
                        "DGR_300BLK_F_10Rnd",
                        "DGR_308_M80_10Rnd",
                        "DGR_3006M72_10Rnd"
                    ];

     Mag_Rare =    [
                        "rhsusf_mag_15Rnd_9x19_FMJ",
                        "8Rnd_45ACP_Magazine",
                        "8Rnd_45Super_Magazine",
                        "rhsusf_mag_17Rnd_9x19_FMJ",
                        "DGR_3006M22_10Rnd",
                        "DGR_3006M2_10Rnd",
                        "DGR_308_B416_10Rnd",
                        "DGR_308_M993_10Rnd",
                        "DGR_300BLK_S_10Rnd",
                        "DGR_300BLK_HP_10Rnd",
                        "DGR_224_SS109_10Rnd",
                        "DGR_224_MK318_10Rnd",
                        "DGR_224_MK262_10Rnd",
                        "DGR_224_M995_10Rnd",
                        "DGR_22_Subsonic_20Rnd",
                        "rhsusf_20Rnd_762x51_m118_special_Mag",
                        "rhsusf_20Rnd_762x51_m62_Mag",
                        "DGR_22_Stinger_20Rnd",
                        "DGR_224_VLD_10Rnd"
                    ];

     Mag_Pistol =   [
                        "8Rnd_45GAP_Magazine",
                        "6Rnd_357M_Magazine",
                        "8Rnd_9x19_Magazine",
                        "CUP_7Rnd_45ACP_1911",
                        "CUP_6Rnd_45ACP_M",
                        "rhsusf_mag_15Rnd_9x19_JHP",
                        "rhsusf_mag_17Rnd_9x19_JHP"
                    ];

     Mag_Shotgun =  [
                        "6Rnd_00_Buckshot_Magazine",
                        "6Rnd_Slug_Magazine",
                        "2Rnd_00_Buckshot_Magazine",
                        "2Rnd_Slug_Magazine",
                        "5Rnd_00_Buckshot_Magazine",
                        "5Rnd_Slug_Magazine"
                    ];

["Car", "init",
    {
         (_this select 0) addWeaponCargoGlobal [selectRandom ShotGunLoot, round(random 1)];
         (_this select 0) addMagazineCargoGlobal [selectRandom Mag_Shotgun, round(random 2)];

 

         (_this select 0) addWeaponCargoGlobal [selectRandom pistolLoot, round(random 2)];
         (_this select 0) addMagazineCargoGlobal [selectRandom Mag_Pistol, round(random 3)];

 

         (_this select 0) addWeaponCargoGlobal [selectRandom RifleLoot, round(random 1)];
         (_this select 0) addMagazineCargoGlobal [selectRandom Mag_Rifle, round(random 1)];

 

         (_this select 0) addWeaponCargoGlobal [selectRandom SniperLoot, 0 + (random 1)];
         (_this select 0) addMagazineCargoGlobal [selectRandom Mag_Sniper, 0 + (random 1)];

 

         (_this select 0) addMagazineCargoGlobal [selectRandom Mag_Rare, 0 + (random 1)];

 

         (_this select 0) addItemCargoGlobal [selectRandom foodLoot, ceil(random 3)];
         (_this select 0) addItemCargoGlobal [selectRandom foodLoot, round(random 3)];
         (_this select 0) addItemCargoGlobal [selectRandom itemsLoot, 1];
         (_this select 0) addItemCargoGlobal [selectRandom itemsLoot, 0 + (random 2)];
         (_this select 0) addItemCargoGlobal [selectRandom clothesLoot, round(random 1)];
         (_this select 0) addItemCargoGlobal [selectRandom clothesLoot, 1];
         (_this select 0) addItemCargoGlobal [selectRandom vestsLoot, 0 + (random 1)];
         (_this select 0) addItemCargoGlobal [selectRandom vestsLoot, 1];
         (_this select 0) addBackpackCargoGlobal [selectRandom backpacksLoot, round(random 2)];
    }, true, [], true] call CBA_fnc_addClassEventHandler;
};

 

 

Feel free to use these scripts as you see fit, just change the loot to what you want spawned. 

 

Thanks to everyone who gave me advise on this

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

You randomize too early:

private _ShotGun = selectRandom ShotGunLoot;
//later in the CBA EH init:
(_this select 0) addWeaponCargoGlobal [_ShotGun, 1];//will always be the same _ShotGun for every spawned car

//do this instead:
(_this select 0) addWeaponCargoGlobal [selectRandom ShotGunLoot, 1];

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

thanks ill give that ago. Was pretty tied last night. Seeing the "You randomize too early" i realized i was randomizing them before putting them in the car

Share this post


Link to post
Share on other sites

so awesome thank you @Grumpy Old Man that works a treat. But now my ammo isn't random. Changed it around heaps but still ammo is the same in all cars, some have different type i.e tracer versions. And none of the ammo fits in any of the spawned guns. My list isnt that long im sure eventually ill find a gun to fit the ammo i have. 

 

Spoiler

if (isServer) then {
    pistolLoot =
                    [
                         //Bnae Pistols
                        "bnae_r1_virtual",
                        "bnae_r1_e_virtual",
                        "bnae_r1_t_virtual",
                        "bnae_saa_virtual",
                        "rhsusf_weap_m9",
                        "bnae_l35_c_virtual",
                        "rhsusf_weap_m1911a1",
                        "CUP_hgun_Colt1911",
                        "rhsusf_weap_glock17g4",
                        "rhsusf_weap_m1911a1",
 //                       "KICKASS_Sawed_Off_Shotgun",
                        "CUP_hgun_TaurusTracker455"
 //                       "Hatchet",
 //                       "KA_knife",
 //                       "KA_dagger"
                    ];


    ShotGunLoot =
                    [
                          //Bnae shotguns
                        "bnae_m97_virtual",
                        "bnae_m97_camo1_virtual",
                        "bnae_m97_s_virtual",
                        "bnae_spr220_virtual",
                        "bnae_spr220_camo1_virtual",
                        "bnae_spr220_so_virtual",
                        "bnae_spr220_so_camo1_virtual",
                        "rhs_weap_M590_8RD",
                        "rhs_weap_M590_5RD",
                        "CUP_sgun_M1014"
//                        "KICKASS_Sawed_Off_Shotgun"
                    ];

    foodLoot =
                    [
                        //Ravage Items
                        "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"
                    ];


    itemsLoot =
                    [
                        "ryan_ruger77_optic_SOS",
                        "acc_flashlight",
                        //Dagger Items
                        "Dagger_10x_Round_Dot",
                        "Dagger_12x_Round_Dot_Gen2",
                        "Dagger_16x_Round_Dot",
                        //Bnae Items
                        "bnae_scope_blk_virtual",
                        "bnae_bipod_blk_virtual",
                        //Vanilla items
                        "Item_optic_LRPS",
                        "Item_bipod_01_F_khk",
                        //RHS Items
                        "rhsusf_acc_M8541",
                        "rhsusf_acc_premier",
                        "rhsusf_acc_LEUPOLDMK4",
                        "rhsusf_acc_LEUPOLDMK4_2",
                        "rhsusf_acc_harris_bipod",
                        //CUP Items
                        "CUP_optic_LeupoldMk4",
                        "CUP_optic_Leupold_VX3",
                        "CUP_bipod_Harris_1A2_L",
                        "CUP_bipod_VLTOR_Modpod",
                        //Ravage Items
                        "Binocular",
                        "FirstAidKit",
                        "Medikit",
                        "ItemMap",
                           "rvg_canisterFuel_Empty",
                        "rvg_toolkit",
                        "rvg_tire",
                        "rvg_money",
                        "rvg_docFolder",
                        "rvg_money",
                        "rvg_hose",
                        "rvg_guttingKnife",
                        "rvg_foldedTent",
                        "rvg_matches",
                        "rvg_foldedTent"
                    ];

    clothesLoot =
                    [
                           "U_C_Journalist",
                           "U_C_Poloshirt_blue",
                           "U_C_Poloshirt_burgundy",
                           "U_C_Poloshirt_salmon",
                           "U_C_Poloshirt_stripped",
                           "U_C_Poloshirt_tricolour",
                           "U_C_Poor_1",
                           "U_C_Poor_2",
                           "U_C_Poor_shorts_1",
                           "U_C_Scientist",
                           "U_OrestesBody",
                           "U_Rangemaster",
                           "U_NikosAgedBody",
                           "U_NikosBody",
                           "U_Competitor",
                           "U_I_G_resistanceLeader_F",
                           "U_C_man_sport_1_F",
                           "U_C_man_sport_2_F",
                           "U_C_man_sport_3_F",
                           "U_C_Man_casual_1_F",
                           "U_C_Man_casual_2_F",
                           "U_C_Man_casual_3_F",
                           "U_C_Man_casual_4_F",
                           "U_C_Man_casual_5_F",
                           "U_C_Man_casual_6_F",
                           "H_Helmet_Skate",
                           "H_Hat_brown",
                           "rhs_Booniehat_ocp",
                           "rhs_beanie_green",
                           "U_B_T_FullGhillie_tna_F",
                        "U_IG_Guerilla1_1",
                           "U_IG_Guerilla2_1",
                           "U_IG_Guerilla2_2",
                           "U_IG_Guerilla2_3",
                           "U_IG_Guerilla3_1",
                           "U_BG_Guerilla2_1",
                           "U_IG_Guerilla3_2",
                           "U_BG_Guerrilla_6_1",
                           "U_BG_Guerilla1_1",
                           "U_BG_Guerilla2_2",
                           "U_BG_Guerilla2_3",
                           "U_BG_Guerilla3_1"
 //                          "HITMAN_47_SUIT"
                    ];


    vestsLoot =
                    [
                        "V_Rangemaster_belt",
                        "rhs_vest_commander",
                        "rhs_vest_pistol_holster",
                        "Vest_V_Press_F",
                        "rhs_6sh46",
//                        "HITMAN_47_Hidden_Vest",
                        "dgr_coat5",
                        "dgr_coat6",
                        "dgr_coat7",
                        "dgr_coat8"
                    ];


    backpacksLoot =
                    [
                        "B_AssaultPack_rgr",
                        "B_Kitbag_rgr",
                        "B_TacticalPack_rgr",
                        "B_Respawn_Sleeping_bag_blue_F",
                        "B_Respawn_Sleeping_bag_brown_F",
                        "B_Respawn_TentDome_F",
                        "B_Respawn_Sleeping_bag_F",
                        "B_Respawn_TentA_F",
                        "rhs_sidor",
                        "B_Carryall_cbr",
                         "B_Carryall_khk",
                         "B_Carryall_mcamo",
                         "B_Carryall_ocamo",
                         "B_Carryall_oli",
                         "B_Carryall_oucamo"
                    ];

 

     RifleLoot =    [
                         //RHS Weapons
                         "rhs_weap_m14ebrri",
                         //Bnae Snipers
                         "bnae_mk1_virtual",
                         //CUP Rifles
                         "CUP_srifle_LeeEnfield",
                         "CUP_srifle_M14",
                         "CUP_srifle_LeeEnfield_rail",
                         "dgr_22",
                         "dgr_220",
                         "dgr_223",
                         "ryan_ruger77"
                     ];

 

     SniperLoot =   [
                        //CUP Weapons
                        "CUP_srifle_CZ550",
                        "CUP_smg_MP5A5",
                        "CUP_srifle_M24_des_LeupoldMk4LRT",
                        "CUP_srifle_M24_wdl_LeupoldMk4LRT",
                        "bnae_falkor_blk_virtual",
 //                       "KA_crossbow_black",
 //                       "KA_crossbow_wood",
                        "dgr_3006",
                        "dgr_257",
                        "dgr_270",
                        "dgr_300blk",
                        "dgr_308_m40_3",
                        "ryan_ruger77scope"
                    ];

 

//////////////// Shotguns //////////////////////////////
        private _ShotGun = selectRandom ShotGunLoot;
        private _config = [
            "cfgMagazines",
            "cfgWeapons"
            ] select (isClass (configFile >> "cfgWeapons" >> _ShotGun));

        private _ShotGun_magazines = [
            configFile >> _config >> _ShotGun >> "magazines",
            configFile >> _config >> _ShotGun
        ] select (_config isEqualTo "cfgMagazines");

 

////////////// Pistols /////////////////
        private _pistol = selectRandom pistolLoot;
        private _config = [
            "cfgMagazines",
            "cfgWeapons"
            ] select (isClass (configFile >> "cfgWeapons" >> _pistol));

        private _pistol_magazines = [
            configFile >> _config >> _pistol >> "magazines",
            configFile >> _config >> _pistol
        ] select (_config isEqualTo "cfgMagazines");

 

////////////////// Rifles ////////////////////////////
           private _Rifles = selectRandom RifleLoot;
        private _config = [
            "cfgMagazines",
            "cfgWeapons"
            ] select (isClass (configFile >> "cfgWeapons" >> _Rifles));

        private _Rifle_magazines = [
            configFile >> _config >> _Rifles >> "magazines",
            configFile >> _config >> _Rifles
        ] select (_config isEqualTo "cfgMagazines");

 

/////////////////// Snipers ////////////////////////////
        private _Snipers = selectRandom SniperLoot;
        private _config = [
            "cfgMagazines",
            "cfgWeapons"
            ] select (isClass (configFile >> "cfgWeapons" >> _Snipers));

        private _Sniper_magazines = [
            configFile >> _config >> _Snipers >> "magazines",
            configFile >> _config >> _Snipers
        ] select (_config isEqualTo "cfgMagazines");


["Car", "init",
    {
         (_this select 0) addWeaponCargoGlobal [selectRandom ShotGunLoot, 1];
          private _arr1 = getArray _ShotGun_magazines; // ShotGun Mags
         (_this select 0) addMagazineCargoGlobal [selectRandom _arr1, 1];

 

//          private _arr2 = getArray _ShotGun_magazines; // ShotGun Mags
//         (_this select 0) addMagazineCargoGlobal [selectRandom _arr2, 1]; // ShotGunLootround(random 1)

 

         (_this select 0) addWeaponCargoGlobal [selectRandom pistolLoot, 1];
          private _arr3 = getArray _pistol_magazines; // Pistol Mags round(random 2)
         (_this select 0) addMagazineCargoGlobal [selectRandom _arr3, 1];

 

//          private _arr4 = getArray _pistol_magazines; // Pistol Mags
//         (_this select 0) addMagazineCargoGlobal [selectRandom _arr4, 1];  // pistolLoot round(random 2)

 

         (_this select 0) addWeaponCargoGlobal [selectRandom RifleLoot, 1];
          private _arr5 = getArray _Rifle_magazines; // Rifle Mags
         (_this select 0) addMagazineCargoGlobal [[selectRandom _arr5, _Rifles] select (_arr5 isEqualTo []), 1];

 

//          private _arr6 = getArray _Rifle_magazines; // Rifle Mags
//         (_this select 0) addMagazineCargoGlobal [selectRandom _arr6, 1];  // RifleLootround(random 1)

 

         (_this select 0) addWeaponCargoGlobal [selectRandom SniperLoot, 1];
          private _arr7 = getArray _Sniper_magazines; // Sniper Mags
         (_this select 0) addMagazineCargoGlobal [[selectRandom _arr7, _Snipers] select (_arr7 isEqualTo []), 1];

 

//          private _arr8 = getArray _Sniper_magazines; // Sniper Mags
//         (_this select 0) addMagazineCargoGlobal [selectRandom _arr8, 1];  // SniperLoot round(random 1)


         (_this select 0) addItemCargoGlobal [selectRandom foodLoot, ceil(random 3)];
         (_this select 0) addItemCargoGlobal [selectRandom foodLoot, round(random 3)];
         (_this select 0) addItemCargoGlobal [selectRandom itemsLoot, 1];
         (_this select 0) addItemCargoGlobal [selectRandom itemsLoot, 1];
         (_this select 0) addItemCargoGlobal [selectRandom clothesLoot, round(random 1)];
         (_this select 0) addItemCargoGlobal [selectRandom clothesLoot, 1];
         (_this select 0) addItemCargoGlobal [selectRandom vestsLoot, 0 + (random 1)];
         (_this select 0) addItemCargoGlobal [selectRandom vestsLoot, 1];
         (_this select 0) addBackpackCargoGlobal [selectRandom backpacksLoot, round(random 2)];
    }, true, [], true] call CBA_fnc_addClassEventHandler;
};

/* You randomize too early:

private _ShotGun = selectRandom ShotGunLoot;
//later in the CBA EH init:
(_this select 0) addWeaponCargoGlobal [_ShotGun, 1];//will always be the same _ShotGun for every spawned car

//do this instead:
(_this select 0) addWeaponCargoGlobal [selectRandom ShotGunLoot, 1];
*/

 

So i got rid of the arrays i had in my op and made them like the rest. But now the ammo is the same type in all vehicles. The only other way i could think of it is make a loot list for the ammo types i want to spawn in but i was hoping i didnt have to do that.

 

I made them all give me one so i could test what i was getting. The mission is a wasteland that has been that way for years and every car you come across is either a wreck or a survivors car. Being a survivors car there should be gear in it and if there are guns its understandable that there would be ammo for at least one gun in the car.

Share this post


Link to post
Share on other sites

It's best practice to

Spoiler

wrap your long sections of code in spoiler tags.


 

Share this post


Link to post
Share on other sites

Okay ill give it ago. Sorry dont usually post something so long

 

  • Thanks 1

Share this post


Link to post
Share on other sites
1 hour ago, Chuc said:

so awesome thank you @Grumpy Old Man that works a treat. But now my ammo isn't random. Changed it around heaps but still ammo is the same in all cars, some have different type i.e tracer versions. And none of the ammo fits in any of the spawned guns. My list isnt that long im sure eventually ill find a gun to fit the ammo i have.

 

So i got rid of the arrays i had in my op and made them like the rest. But now the ammo is the same type in all vehicles. The only other way i could think of it is make a loot list for the ammo types i want to spawn in but i was hoping i didnt have to do that.

 

I made them all give me one so i could test what i was getting. The mission is a wasteland that has been that way for years and every car you come across is either a wreck or a survivors car. Being a survivors car there should be gear in it and if there are guns its understandable that there would be ammo for at least one gun in the car.

 

That's why you need to tie the magazines to their compatible weapons, like this:

_weapons = ["arifle_MXC_F","arifle_AK12_F","arifle_TRG20_F"];

//add random weapon to vehicle cargo
_vehicle = cursorobject;
_rndWeapon = selectRandom _weapons;
_mags = getArray (configfile >> "CfgWeapons" >> _rndWeapon >> "magazines");
_rndMag = selectRandom _mags;

_weapAmount = round (1 + random 3);
_magAmount = round ((4 + random 4) * _weapAmount);//so you'll get enough mags for each weapon added

_vehicle addWeaponCargo [_rndWeapon,_weapAmount];
_vehicle addMagazineCargo [_rndMag,_magAmount];

This will add at least one random weapon with at least 4-8 magazines into the cursor target.

Multiply the magazine amount with the amount of weapons added so you'll end up with plenty of useable magazines for each weapon added.

 

Cheers

Share this post


Link to post
Share on other sites
3 hours ago, Grumpy Old Man said:

 

That's why you need to tie the magazines to their compatible weapons, like this:


_weapons = ["arifle_MXC_F","arifle_AK12_F","arifle_TRG20_F"];

//add random weapon to vehicle cargo
_vehicle = cursorobject;
_rndWeapon = selectRandom _weapons;
_mags = getArray (configfile >> "CfgWeapons" >> _rndWeapon >> "magazines");
_rndMag = selectRandom _mags;

_weapAmount = round (1 + random 3);
_magAmount = round ((4 + random 4) * _weapAmount);//so you'll get enough mags for each weapon added

_vehicle addWeaponCargo [_rndWeapon,_weapAmount];
_vehicle addMagazineCargo [_rndMag,_magAmount];

This will add at least one random weapon with at least 4-8 magazines into the cursor target.

Multiply the magazine amount with the amount of weapons added so you'll end up with plenty of useable magazines for each weapon added.

 

Cheers

 

So i tried to implement your code into mine and i got it to spawn the ammo for the guns in car. Guns where random between the 2 editor placed cars i had and all guns had the right ammo. I couldnt seem to spawn in random ammo at all, ammo not for the guns spawned. That wasnt really a problem as a bit more tweaking could add that. The biggest problem was the code wasnt working for vehicles spawned by a script. Not sure what caused that to happen but its okay.

 

What i have done is added the magazines into there own loot list and just have them spawn in with the guns. Sometimes you will not get any ammo for the guns in car but sometimes you do. It works well and is random, random is what i was after.

 

VehicleLoot.sqf

 

Spoiler

//////////////// Created by Chuc ////////////////////

 

// execVM "VehicleLoot.sqf"


if (isServer) then {
    pistolLoot =
                    [
                         //Bnae Pistols
                        "bnae_r1_virtual",
                        "bnae_r1_e_virtual",
                        "bnae_r1_t_virtual",
                        "bnae_saa_virtual",
                        "rhsusf_weap_m9",
                        "bnae_l35_c_virtual",
                        "CUP_hgun_Colt1911",
                        "rhsusf_weap_glock17g4",
                        "CUP_hgun_TaurusTracker455"
                    ];


    ShotGunLoot =
                    [
                          //Bnae shotguns
                        "bnae_m97_virtual",
                        "bnae_m97_camo1_virtual",
                        "bnae_m97_s_virtual",
                        "bnae_spr220_virtual",
                        "bnae_spr220_camo1_virtual",
                        "bnae_spr220_so_virtual",
                        "bnae_spr220_so_camo1_virtual"
                    ];

    foodLoot =
                    [
                        //Ravage Items
                        "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"
                    ];


    itemsLoot =
                    [
                        "ryan_ruger77_optic_SOS",
                        "acc_flashlight",
                        //Dagger Items
                        "Dagger_10x_Round_Dot",
                        "Dagger_12x_Round_Dot_Gen2",
                        "Dagger_16x_Round_Dot",
                        //Bnae Items
                        "bnae_scope_blk_virtual",
                        "bnae_bipod_blk_virtual",
                        //Vanilla items
                        "Item_optic_LRPS",
                        "Item_bipod_01_F_khk",
                        //RHS Items
                        "rhsusf_acc_M8541",
                        "rhsusf_acc_premier",
                        "rhsusf_acc_LEUPOLDMK4",
                        "rhsusf_acc_LEUPOLDMK4_2",
                        "rhsusf_acc_harris_bipod",
                        //CUP Items
                        "CUP_optic_LeupoldMk4",
                        "CUP_optic_Leupold_VX3",
                        "CUP_bipod_Harris_1A2_L",
                        "CUP_bipod_VLTOR_Modpod",
                        //Ravage Items
                        "Binocular",
                        "FirstAidKit",
                        "Medikit",
                        "ItemMap",
                         "rvg_canisterFuel_Empty",
                        "rvg_toolkit",
                        "rvg_tire",
                        "rvg_money",
                        "rvg_docFolder",
                        "rvg_money",
                        "rvg_hose",
                        "rvg_guttingKnife",
                        "rvg_foldedTent",
                        "rvg_matches",
                        "rvg_foldedTent"
                    ];

    clothesLoot =
                    [
                           "U_C_Journalist",
                           "U_C_Poloshirt_blue",
                           "U_C_Poloshirt_burgundy",
                           "U_C_Poloshirt_salmon",
                           "U_C_Poloshirt_stripped",
                           "U_C_Poloshirt_tricolour",
                           "U_C_Poor_1",
                           "U_C_Poor_2",
                           "U_C_Poor_shorts_1",
                           "U_C_Scientist",
                           "U_OrestesBody",
                           "U_Rangemaster",
                           "U_NikosAgedBody",
                           "U_NikosBody",
                           "U_Competitor",
                           "U_I_G_resistanceLeader_F",
                           "U_C_man_sport_1_F",
                           "U_C_man_sport_2_F",
                           "U_C_man_sport_3_F",
                           "U_C_Man_casual_1_F",
                           "U_C_Man_casual_2_F",
                           "U_C_Man_casual_3_F",
                           "U_C_Man_casual_4_F",
                           "U_C_Man_casual_5_F",
                           "U_C_Man_casual_6_F",
                           "H_Helmet_Skate",
                           "H_Hat_brown",
                           "rhs_Booniehat_ocp",
                           "rhs_beanie_green",
                           "U_B_T_FullGhillie_tna_F",
                           "U_IG_Guerilla1_1",
                           "U_IG_Guerilla2_1",
                           "U_IG_Guerilla2_2",
                           "U_IG_Guerilla2_3",
                           "U_IG_Guerilla3_1",
                           "U_BG_Guerilla2_1",
                           "U_IG_Guerilla3_2",
                           "U_BG_Guerrilla_6_1",
                           "U_BG_Guerilla1_1",
                           "U_BG_Guerilla2_2",
                           "U_BG_Guerilla2_3",
                           "U_BG_Guerilla3_1"
                    ];


    vestsLoot =
                    [
                        "V_Rangemaster_belt",
                        "rhs_vest_commander",
                        "rhs_vest_pistol_holster",
                        "Vest_V_Press_F",
                        "rhs_6sh46",
                        "dgr_coat5",
                        "dgr_coat6",
                        "dgr_coat7",
                        "dgr_coat8"
                    ];


    backpacksLoot =
                    [
                        "B_AssaultPack_rgr",
                        "B_Kitbag_rgr",
                        "B_TacticalPack_rgr",
                        "B_Respawn_Sleeping_bag_blue_F",
                        "B_Respawn_Sleeping_bag_brown_F",
                        "B_Respawn_TentDome_F",
                        "B_Respawn_Sleeping_bag_F",
                        "B_Respawn_TentA_F",
                        "rhs_sidor",
                        "B_Carryall_cbr",
                        "B_Carryall_khk",
                        "B_Carryall_mcamo",
                        "B_Carryall_ocamo",
                        "B_Carryall_oli",
                        "B_Carryall_oucamo"
                    ];

 

     RifleLoot =    [
                         //RHS Weapons
                         "rhs_weap_m14ebrri",
                         //Bnae Snipers
                         "bnae_mk1_virtual",
                         //CUP Rifles
                         "CUP_srifle_M14",
                         "dgr_22",
                         "dgr_220",
                         "dgr_223",
                         "ryan_ruger77"
                     ];

 

     SniperLoot =   [
                        //CUP Weapons
                        "CUP_srifle_CZ550",
                        "CUP_smg_MP5A5",
                        "CUP_srifle_M24_des_LeupoldMk4LRT",
                        "CUP_srifle_M24_wdl_LeupoldMk4LRT",
                        "bnae_falkor_blk_virtual",
                        "dgr_3006",
                        "dgr_257",
                        "dgr_270",
                        "dgr_300blk",
                        "dgr_308_m40_3",
                        "ryan_ruger77scope"
                    ];

 

          ////////////// Magazines //////////////
     Mag_Rifle =    [
                        "rhsusf_20Rnd_762x51_m993_Mag",
                        "ryan_ruger77magazine",
                        "10Rnd_303_Magazine",
                        "CUP_20Rnd_762x51_DMR",
                        "20Rnd_762x51_Mag",

                        "DGR_22_Match_20Rnd",
                        "DGR_220_20Rnd",
                        "DGR_224_M193_10Rnd"
                    ];

 

     Mag_Sniper =   [
                        "ryan_ruger77magazine",
                        "10Rnd_300WM_Magazine",
                        "CUP_5x_22_LR_17_HMR_M",
                        "CUP_5Rnd_762x51_M24",
                        "CUP_30Rnd_9x19_MP5",
                        "DGR_257_10Rnd",
                        "DGR_270_10Rnd",
                        "DGR_300BLK_F_10Rnd",
                        "DGR_308_M80_10Rnd",
                        "DGR_3006M72_10Rnd"
                    ];

 

     Mag_Rare =    [
                        "rhsusf_mag_15Rnd_9x19_FMJ",
                        "8Rnd_45ACP_Magazine",
                        "8Rnd_45Super_Magazine",
                        "rhsusf_mag_17Rnd_9x19_FMJ",
                        "DGR_3006M22_10Rnd",
                        "DGR_3006M2_10Rnd",
                        "DGR_308_B416_10Rnd",
                        "DGR_308_M993_10Rnd",
                        "DGR_300BLK_S_10Rnd",
                        "DGR_300BLK_HP_10Rnd",
                        "DGR_224_SS109_10Rnd",
                        "DGR_224_MK318_10Rnd",
                        "DGR_224_MK262_10Rnd",
                        "DGR_224_M995_10Rnd",
                        "DGR_22_Subsonic_20Rnd",
                        "rhsusf_20Rnd_762x51_m118_special_Mag",
                        "rhsusf_20Rnd_762x51_m62_Mag",
                        "DGR_22_Stinger_20Rnd",
                        "DGR_224_VLD_10Rnd"
                    ];

 

     Mag_Pistol =   [
                        "8Rnd_45GAP_Magazine",
                        "6Rnd_357M_Magazine",
                        "8Rnd_9x19_Magazine",
                        "CUP_7Rnd_45ACP_1911",
                        "CUP_6Rnd_45ACP_M",
                        "rhsusf_mag_15Rnd_9x19_JHP",
                        "rhsusf_mag_17Rnd_9x19_JHP"
                    ];

 

     Mag_Shotgun =  [
                        "6Rnd_00_Buckshot_Magazine",
                        "6Rnd_Slug_Magazine",
                        "2Rnd_00_Buckshot_Magazine",
                        "2Rnd_Slug_Magazine",
                        "5Rnd_00_Buckshot_Magazine",
                        "5Rnd_Slug_Magazine"
                    ];

 

["Car", "init",
    {
         (_this select 0) addWeaponCargoGlobal [selectRandom ShotGunLoot, round(random 1)];
         (_this select 0) addMagazineCargoGlobal [selectRandom Mag_Shotgun, round(random 2)];

 

         (_this select 0) addWeaponCargoGlobal [selectRandom pistolLoot, round(random 2)];
         (_this select 0) addMagazineCargoGlobal [selectRandom Mag_Pistol, round(random 3)];

 

         (_this select 0) addWeaponCargoGlobal [selectRandom RifleLoot, round(random 1)];
         (_this select 0) addMagazineCargoGlobal [selectRandom Mag_Rifle, round(random 1)];

 

         (_this select 0) addWeaponCargoGlobal [selectRandom SniperLoot, 0 + (random 1)];
         (_this select 0) addMagazineCargoGlobal [selectRandom Mag_Sniper, 0 + (random 1)];

 

         (_this select 0) addMagazineCargoGlobal [selectRandom Mag_Rare, 0 + (random 1)];

 

         (_this select 0) addItemCargoGlobal [selectRandom foodLoot, ceil(random 3)];
         (_this select 0) addItemCargoGlobal [selectRandom foodLoot, round(random 3)];
         (_this select 0) addItemCargoGlobal [selectRandom itemsLoot, 1];
         (_this select 0) addItemCargoGlobal [selectRandom itemsLoot, 0 + (random 2)];
         (_this select 0) addItemCargoGlobal [selectRandom clothesLoot, round(random 1)];
         (_this select 0) addItemCargoGlobal [selectRandom clothesLoot, 1];
         (_this select 0) addItemCargoGlobal [selectRandom vestsLoot, 0 + (random 1)];
         (_this select 0) addItemCargoGlobal [selectRandom vestsLoot, 1];
         (_this select 0) addBackpackCargoGlobal [selectRandom backpacksLoot, round(random 2)];
    }, true, [], true] call CBA_fnc_addClassEventHandler;
};

 

 

There is the Code if anyone would like it. Thanks for your help guys.

  • Like 1

Share this post


Link to post
Share on other sites

edited the OP and title to give the scripts to people looking for them.

 

I still haven't found a random vehicle loot script outside of exile or epoch mods. 

 

 

Sorry for any spelling mistakes or grammar issues in this thread, Kids are making it difficult.

  • Like 2

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

×