item overflow support for spawning count of items or weapons

This commit is contained in:
vbawol 2016-04-24 17:44:11 -05:00
parent 5744be50d3
commit 14ea6a44dc

View File

@ -23,31 +23,28 @@
BOOL
*/
private ["_wHPos","_wH","_nearByHolder"];
params [["_item","",[""]],["_count",0]];
if (player canAdd _item) then {
if (_count >= 1) then {
player addMagazine [_item, _count];
} else {
params [["_item","",[""]],["_count",1]];
for "_i" from 1 to _count do
{
if (player canAdd _item) then {
player addItem _item;
};
} else {
_wH = objNull;
_nearByHolder = nearestObjects [position player,["groundWeaponHolder"],3];
if (_nearByHolder isEqualTo []) then {
_wHPos = player modelToWorld [0,1,0];
if (surfaceIsWater _wHPos) then {
_wHPos = ASLToATL _wHPos;
} else {
_wH = objNull;
if (isNil "_nearByHolder") then {
_nearByHolder = nearestObjects [position player,["groundWeaponHolder"],3];
};
if (_nearByHolder isEqualTo []) then {
_wHPos = player modelToWorld [0,1,0];
if (surfaceIsWater _wHPos) then {
_wHPos = ASLToATL _wHPos;
};
_wH = createVehicle ["groundWeaponHolder",_wHPos, [], 0, "CAN_COLLIDE"];
} else {
_wH = _nearByHolder select 0;
};
if !(isNull _wh) then {
_wh addItemCargoGlobal [_item,1];
};
_wH = createVehicle ["groundWeaponHolder",_wHPos, [], 0, "CAN_COLLIDE"];
} else {
_wH = _nearByHolder select 0;
};
if (_count >= 1) then {
_wh addMagazineAmmoCargo[_item, 1, _count];
} else {
_wh addItemCargoGlobal [_item,1];
};
};
true