Home   Help Search Login Register  

Author Topic: (SOLVED) How can I add a weapon and magazine array to a vehicle  (Read 2717 times)

0 Members and 1 Guest are viewing this topic.

Offline Undeceived

  • Members
  • *
    • My missions and campaigns
Hello guys!

I know that I can add arrays to persons like this:

Code: [Select]
_weaponsarray = weapons player
_magsarray = magazines player


_i = 0;

if(isServer) then
{
while{_i < count _magsarray} do
{

person2 addmagazine (_magsarray select _i);
sleep 0.2;
_i = _i + 1;
};
};



_i = 0;

if(isServer) then
{
while{_i < count _weaponsarray} do
{

person2 addweapon (_weaponsarray select _i);
sleep 0.2;
_i = _i + 1;
};
};



But how can I add the player's weapons and magazines to an vehicle (e.g. "box")?

How do you have to use the addmagazinecargo and addweaponcargo commands? I tried several possibilities but none of them worked...


Thank you very much for your help and time!
« Last Edit: 01 Sep 2011, 16:56:45 by Undeceived »
Current project: Black Lands (Arma 3)

Offline mr_book.PXS.Pvt

  • Members
  • *
Re: How can I add a weapon and magazine array to a vehicle
« Reply #1 on: 01 Sep 2011, 16:01:47 »
Hi Undeceived,
this might work:
Code: [Select]
_magsarray = magazines player;
_weaponsarray = weapons player;

_i = 0;
if (isServer) then
{
while {_i<count _magsarray} do
{
box1 addmagazinecargo [format ["%1", _magsarray select _i], 1];
sleep 0.1;
_i = _i + 1;
};
};

_i = 0;
if (isServer) then
{
while {_i<count _weaponsarray} do
{
box1 addweaponcargo [format ["%1", _weaponsarray select _i], 1];
sleep 0.1;
_i = _i + 1;
};
};
Adds one magazine or weapon out of the array to the ammobox/vehicle/whatever. In the end, the box should contain pretty much the same stuff that the player has in his inventory.
Hm, I'm not sure whether the "count _weaponsarray" should be "(count _weaponsarray)-1" instead. Because when _i is zero and count is five, then the while-loop will be executed six instead of five times. You may want to try that out.
Good day,
mr_book

Offline Undeceived

  • Members
  • *
    • My missions and campaigns
Re: How can I add a weapon and magazine array to a vehicle
« Reply #2 on: 01 Sep 2011, 16:56:26 »
This works perfectly, thanks a lot, mr_book! :)

I didn't have to change anything from your code, the amount of magazines in the box is the same as the player's.


Thanks again for this quick answer! :good:
Current project: Black Lands (Arma 3)