Forum Jump :

Author Message


Posts: 4
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2015-03-16 18:58        
     
Im building a script that allows a player to pull a vehicle up to a point and select from a pre-defined set of backpacks to load the vehicle up with. For example, a medical assault pack loaded with FAKs and a medkit.

Im trying to find a way to either:

1. add items to a backpack after they are spawned into the vehicle

or (and preferably)

2. create the backpack as a variable (complete with its contents) and then spawn the backpack in the vehicle

What is the best way to achieve this?


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 61
In-game name: Kobayashi Maru

 
#2 Posted at 2015-03-17 00:06        
     
You could try something like:

clearMagazineCargoGlobal my_vehicle; //(optional to make room)
my_vehicle addBackpackCargo ["B_AssaultPack_blk",2]; // or any other type
{_x addItemCargo ["FirstAidKit",5]} forEach everyBackpack my_vehicle; // example

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Advertisement


Author Message


Posts: 4
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2015-03-17 03:27        
     
That would be fine if I were putting the same thing in every bag, but I need distinct contents for each bag.

Edit: Hmm but perhaps I could put a conditional statement in the loop that checks the type of bag. Then adds proper contents for each distinct bag type. That might do it!

This post was edited by kirklogan (2015-03-17 13:15, ago)


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 61
In-game name: Kobayashi Maru

 
#4 Posted at 2015-03-17 16:50        
     
Sure you can! As far as a types are concerned, it's easy:
my_vehicle addBackpackCargo ["B_AssaultPack_blk",3];
my_vehicle addBackpackCargo ["B_AssaultPack_cbr",2];

{
if (typeof _x == "B_AssaultPack_cbr") then {_x addItemCargo ["FirstAidKit",10];
_x addItemCargo ["Medikit",1]};

if (typeof _x == "B_AssaultPack_blk") then {_x addItemCargo ["Toolkit",1]};
} forEach (everyBackpack my_vehicle);

you can also setVariable, then getvariable to point at each backpack and make them different from each others.

_i=0;
my_vehicle addBackpackCargo ["B_AssaultPack_blk",3];
my_vehicle addBackpackCargo ["B_AssaultPack_cbr",2];
{_x setvariable ["pack_nbr",_i];_i=_i+1} forEach (everyBackpack my_vehicle);
{
if (_x getVariable "pack_nbr" == 2) then {_x addItemCargo ["FirstAidKit",10];
_x addItemCargo ["Medikit",1]};

if (_x getVariable "pack_nbr" == 4) then {_x addItemCargo ["Toolkit",1]};
} forEach (everyBackpack my_vehicle);

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 5
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#5 Posted at 2015-04-14 04:02        
     
This is What I got so far, but it is only one backpack with gear you would need a new file and new add action for each backpack if you do it my way...

File Backpack.sqf
//PV2 Derienzo [2nd ABCT] Items in Backpack in Cargo Script 
player addbackpack "b_kitbag_base";
(unitBackpack player) addItemCargoGlobal ["",1];
(unitBackpack player) addMagazineCargo ["",1];

What that does is it adds the backpack to the player, and then adds the items to the backpack

Vehicle/Box Init:
this addAction["<t color='#ff1111'>Backpacks</t>", "backpack.sqf"];  

Like I said before, you need a new addAction script for each backpack if you do it this way.

If you have any questions, let me know!






Tags: Backpack