OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: Undeceived on 01 Sep 2011, 13:36:15
-
Hello guys!
I know that I can add arrays to persons like this:
_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!
-
Hi Undeceived,
this might work:
_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
-
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: