Coladebote 46 Posted December 11, 2019 Hi guys: In a script for a vehicle to appear in a certain position, I have included a list of items that should appear in the vehicle inventory: morphine, bandages, ammunition ... I have also included tools and a backpack. The soldier must use the backpack to store the tools inside and be able to move with them to repair the vehicle. However, it is more interesting that the tools are already included inside the backpack. In this way, when taking the backpack, they already have the tools in the inventory. Can anyone help me in this regard? That is, the backpack appears in the inventory of the vehicle with the tools inside. Thanks. if (!isServer) exitWith {}; // VEHICLES // _markerstr = createMarker ["VEHICLE",[8849.8,23460.5]]; _markerstr setMarkerShape "ICON"; _height = 0.000335693; _vehicle = createVehicle ["CUP_B_RG31E_M2_OD_USMC", (getMarkerPos "VEHICLE"),[],0,"NONE"]; _dir = 210; _vehicle setDir _dir; _vehicle setFuel 0.5; clearMagazineCargoGlobal _vehicle; clearWeaponCargoGlobal _vehicle; clearItemCargoGlobal _vehicle; clearBackpackCargoGlobal _vehicle; /// WEAPONS /// _vehicle addweaponcargoGlobal ["launch_MRAWS_green_F",1]; _vehicle addweaponcargoGlobal ["launch_I_Titan_F",1]; _vehicle addweaponcargoGlobal ["rhs_weap_M320",2]; /// AMMUNITION /// _vehicle addmagazinecargoGlobal ["DemoCharge_Remote_Mag",4]; _vehicle addmagazinecargoGlobal ["200Rnd_556x45_Box_F",12]; _vehicle addmagazinecargoGlobal ["DGR_264_S_30Rnd",64]; _vehicle addmagazinecargoGlobal ["1Rnd_HE_Grenade_shell",32]; _vehicle addmagazinecargoGlobal ["HandGrenade",24]; _vehicle addmagazinecargoGlobal ["MiniGrenade",24]; _vehicle additemcargoGlobal ["Titan_AA",4]; _vehicle additemcargoGlobal ["MRAWS_HEAT_F",4]; /// EQUIPMENT /// _vehicle additemcargoGlobal ["ACE_Clacker",1]; _vehicle additemcargoGlobal ["B_UavTerminal",1]; _vehicle additemcargoGlobal ["ALIVE_Tablet",1]; _vehicle additemcargoGlobal ["tf_anprc152_1",2]; _vehicle additemcargoGlobal ["tf_rt1523g_big_bwmod",2]; _vehicle additemcargoGlobal ["SAS_Predator_W",8]; _vehicle additemcargoGlobal ["ToolKit",1]; _vehicle addbackpackcargoGlobal ["B_Carryall_khk",1]; _vehicle addbackpackcargoGlobal ["B_UAV_01_backpack_F",1]; /// MEDICINES /// _vehicle addItemCargoGlobal ["ACE_personalAidKit",8]; _vehicle addItemCargoGlobal ["ACE_bloodIV_500",32]; _vehicle addItemCargoGlobal ["ACE_epinephrine",16]; _vehicle addItemCargoGlobal ["ACE_tourniquet",32]; _vehicle addItemCargoGlobal ["ACE_morphine",40]; _vehicle addItemCargoGlobal ["ACE_packingBandage",100]; _vehicle addItemCargoGlobal ["ACE_elasticBandage",100]; _vehicle addItemCargoGlobal ["ACE_surgicalKit",2]; Share this post Link to post Share on other sites
pierremgi 4739 Posted December 11, 2019 It's easy because you clear all the stuff then place a backpack. Just: _vehicle addbackpackcargoGlobal ["B_Carryall_khk",1]; _bpk = (everyBackpack _vehicle) #0; _bpk additemcargoGlobal ["ToolKit",1]; 2 Share this post Link to post Share on other sites
Coladebote 46 Posted December 12, 2019 Thank you very much, Pierre, I will try it tonight. Very thankful. Share this post Link to post Share on other sites
Coladebote 46 Posted December 12, 2019 Hi: I've tried it on the server and it doesn't work. The backpack does appear in the vehicle inventory, but it is empty, without the tools inside. I am doing something wrong? This is the script I've tried: if (!isServer) exitWith {}; // VEHICLES // _markerstr = createMarker ["VEHICLE",[8849.8,23460.5]]; _markerstr setMarkerShape "ICON"; _height = 0.000335693; _vehicle = createVehicle ["CUP_B_RG31E_M2_OD_USMC", (getMarkerPos "VEHICLE"),[],0,"NONE"]; _dir = 210; _vehicle setDir _dir; _vehicle setFuel 0.5; clearMagazineCargoGlobal _vehicle; clearWeaponCargoGlobal _vehicle; clearItemCargoGlobal _vehicle; clearBackpackCargoGlobal _vehicle; /// WEAPONS /// _vehicle addweaponcargoGlobal ["launch_MRAWS_green_F",1]; _vehicle addweaponcargoGlobal ["launch_I_Titan_F",1]; _vehicle addweaponcargoGlobal ["rhs_weap_M320",2]; /// AMMUNITION /// _vehicle addmagazinecargoGlobal ["DemoCharge_Remote_Mag",4]; _vehicle addmagazinecargoGlobal ["200Rnd_556x45_Box_F",12]; _vehicle addmagazinecargoGlobal ["DGR_264_S_30Rnd",64]; _vehicle addmagazinecargoGlobal ["1Rnd_HE_Grenade_shell",32]; _vehicle addmagazinecargoGlobal ["HandGrenade",24]; _vehicle addmagazinecargoGlobal ["MiniGrenade",24]; _vehicle additemcargoGlobal ["Titan_AA",4]; _vehicle additemcargoGlobal ["MRAWS_HEAT_F",4]; /// EQUIPMENT /// _vehicle additemcargoGlobal ["ACE_Clacker",1]; _vehicle additemcargoGlobal ["B_UavTerminal",1]; _vehicle additemcargoGlobal ["ALIVE_Tablet",1]; _vehicle additemcargoGlobal ["tf_anprc152_1",2]; _vehicle additemcargoGlobal ["tf_rt1523g_big_bwmod",2]; _vehicle additemcargoGlobal ["SAS_Predator_W",8]; _vehicle additemcargoGlobal ["ToolKit",1]; _vehicle addbackpackcargoGlobal ["B_UAV_01_backpack_F",1]; _vehicle addbackpackcargoGlobal ["B_Carryall_khk",1]; _bpk = (everyBackpack _vehicle) #0; _bpk additemcargoGlobal ["ToolKit",1]; /// MEDICINES /// _vehicle addItemCargoGlobal ["ACE_personalAidKit",8]; _vehicle addItemCargoGlobal ["ACE_bloodIV_500",32]; _vehicle addItemCargoGlobal ["ACE_epinephrine",16]; _vehicle addItemCargoGlobal ["ACE_tourniquet",32]; _vehicle addItemCargoGlobal ["ACE_morphine",40]; _vehicle addItemCargoGlobal ["ACE_packingBandage",100]; _vehicle addItemCargoGlobal ["ACE_elasticBandage",100]; _vehicle addItemCargoGlobal ["ACE_surgicalKit",2]; Share this post Link to post Share on other sites
pierremgi 4739 Posted December 12, 2019 The code works. Perhaps, there is a problem on sync server/client, and you could wait for the broadcast of the backpack (global command is not instantaneous due to network), so spawn your code and wait a little bit before adding the tool kit: [] spawn { .... _vehicle addbackpackcargoGlobal ["B_Carryall_khk",1]; uiSleep 0.5; _bpk = (everyBackpack _vehicle) #0; _bpk additemcargoGlobal ["ToolKit",1]; .... }; Share this post Link to post Share on other sites
Larrow 2801 Posted December 13, 2019 You have re-ordered the backpacks as shown from your initial script, so backpack #0 is the UAV backpack of which adding the tools will not work. _vehicle addbackpackcargoGlobal ["B_UAV_01_backpack_F",1]; //First added backpack _vehicle addbackpackcargoGlobal ["B_Carryall_khk",1]; _bpk = (everyBackpack _vehicle) #0; //First backpack #0 _bpk additemcargoGlobal ["ToolKit",1]; Instead use... _vehicle addbackpackcargoGlobal ["B_UAV_01_backpack_F",1]; _vehicle addbackpackcargoGlobal ["B_Carryall_khk",1]; //Last backpack added before adding toolKit _bpks = everyBackpack _vehicle; _bpk = _bpks select ( count _bpks - 1 ); //Last backpack added _bpk additemcargoGlobal ["ToolKit",1]; 3 Share this post Link to post Share on other sites
pierremgi 4739 Posted December 13, 2019 Oups! yes. Sorry I missed that evidence. Do what you want, but stay consistent with the index of the backpack. Share this post Link to post Share on other sites
Coladebote 46 Posted December 14, 2019 Larrow's observation has been very timely. Indeed, it works perfectly, both locally and on the server. The backpack appears in the vehicle inventory with the tools inside. Perfect. Therefore, the script would look like this: if (!isServer) exitWith {}; // VEHICLES // _markerstr = createMarker ["VEHICLE",[8849.8,23460.5]]; _markerstr setMarkerShape "ICON"; _height = 0.000335693; _vehicle = createVehicle ["CUP_B_RG31E_M2_OD_USMC", (getMarkerPos "VEHICLE"),[],0,"NONE"]; _dir = 210; _vehicle setDir _dir; _vehicle setFuel 0.5; clearMagazineCargoGlobal _vehicle; clearWeaponCargoGlobal _vehicle; clearItemCargoGlobal _vehicle; clearBackpackCargoGlobal _vehicle; /// WEAPONS /// _vehicle addweaponcargoGlobal ["launch_MRAWS_green_F",1]; _vehicle addweaponcargoGlobal ["launch_I_Titan_F",1]; _vehicle addweaponcargoGlobal ["rhs_weap_M320",2]; /// AMMUNITION /// _vehicle addmagazinecargoGlobal ["DemoCharge_Remote_Mag",4]; _vehicle addmagazinecargoGlobal ["200Rnd_556x45_Box_F",12]; _vehicle addmagazinecargoGlobal ["DGR_264_S_30Rnd",64]; _vehicle addmagazinecargoGlobal ["1Rnd_HE_Grenade_shell",32]; _vehicle addmagazinecargoGlobal ["HandGrenade",24]; _vehicle addmagazinecargoGlobal ["MiniGrenade",24]; _vehicle additemcargoGlobal ["Titan_AA",4]; _vehicle additemcargoGlobal ["MRAWS_HEAT_F",4]; /// EQUIPMENT /// _vehicle additemcargoGlobal ["ACE_Clacker",1]; _vehicle additemcargoGlobal ["B_UavTerminal",1]; _vehicle additemcargoGlobal ["ALIVE_Tablet",1]; _vehicle additemcargoGlobal ["tf_anprc152_1",2]; _vehicle additemcargoGlobal ["tf_rt1523g_big_bwmod",2]; _vehicle additemcargoGlobal ["SAS_Predator_W",8]; _vehicle additemcargoGlobal ["ToolKit",1]; _vehicle addbackpackcargoGlobal ["B_UAV_01_backpack_F",1]; _vehicle addbackpackcargoGlobal ["B_Carryall_khk",1]; _bpks = everyBackpack _vehicle; _bpk = _bpks select ( count _bpks - 1 ); _bpk additemcargoGlobal ["ToolKit",1]; /// MEDICINES /// _vehicle addItemCargoGlobal ["ACE_personalAidKit",8]; _vehicle addItemCargoGlobal ["ACE_bloodIV_500",32]; _vehicle addItemCargoGlobal ["ACE_epinephrine",16]; _vehicle addItemCargoGlobal ["ACE_tourniquet",32]; _vehicle addItemCargoGlobal ["ACE_morphine",40]; _vehicle addItemCargoGlobal ["ACE_packingBandage",100]; _vehicle addItemCargoGlobal ["ACE_elasticBandage",100]; _vehicle addItemCargoGlobal ["ACE_surgicalKit",2]; Gentlemen, thank you very much for your help. Greetings from Spain. Share this post Link to post Share on other sites
Coladebote 46 Posted December 14, 2019 By the way, you can explain to me what the expressions "_bpks" and "_bpk" represent. Thank you. Share this post Link to post Share on other sites
pierremgi 4739 Posted December 14, 2019 That's just names of variables. _bpks for an array of backpacks returned by everyBackpack command. _bpk for the selected one. You can do (almost) what you want with variable names. change them if you want but stay consistent on script. For more info about commands used, see biki. 1 Share this post Link to post Share on other sites
Coladebote 46 Posted December 14, 2019 Thank you. 1 Share this post Link to post Share on other sites