a3_vemf_reloaded/exile_vemf_reloaded/fn/fn_giveAmmo.sqf

68 lines
1.6 KiB
Plaintext
Raw Normal View History

2016-06-02 21:18:09 +00:00
/*
Author: IT07
Description:
Adds magazines to given unit's vest/backpack if it flairTypes
Params:
_this: ARRAY
_this select 0: OBJECT - unit to give ammo to
_this select 1: STRING - primaryWeapon classname
_this select 2: STRING - secondaryWeapon classname
_this select 3: STRING - handGunWeapon classname
Returns:
BOOLEAN - true if successful
*/
2016-07-02 14:24:53 +00:00
private ["_r","_this0"];
params [
["_this0", objNull, [objNull]],
["_this1", "", [""]],
["_this2", "", [""]],
["_this3", "", [""]]
];
_r = [];
if not(_this1 isEqualTo "") then
2016-06-02 21:18:09 +00:00
{
2016-07-02 14:24:53 +00:00
private ["_m"];
_m = selectRandom (getArray (configFile >> "CfgWeapons" >> _this1 >> "magazines"));
for "_l" from 1 to 5 do
2016-06-02 21:18:09 +00:00
{
2016-07-02 14:24:53 +00:00
if not(_this0 canAdd _m) exitWith {};
_this0 addItem _m;
};
_r pushBack true;
};
if not(_this2 isEqualTo "") then
{
if not((backPack _this0) isEqualTo "") then
{
private ["_m"];
_m = selectRandom (getArray (configFile >> "CfgWeapons" >> _this2 >> "magazines"));
for "_l" from 1 to 3 do
2016-06-02 21:18:09 +00:00
{
2016-07-02 14:24:53 +00:00
if not(_this0 canAdd _m) exitWith {};
_this0 addItem _m;
2016-06-02 21:18:09 +00:00
};
2016-07-02 14:24:53 +00:00
_r pushBack true;
2016-06-02 21:18:09 +00:00
};
2016-07-02 14:24:53 +00:00
};
if not(_this3 isEqualTo "") then
2016-06-02 21:18:09 +00:00
{
2016-07-02 14:24:53 +00:00
private ["_m"];
_m = selectRandom (getArray (configFile >> "CfgWeapons" >> _this3 >> "magazines"));
for "_l" from 1 to 4 do
{
if not(_this0 canAdd _m) exitWith {};
_this0 addItem _m;
};
_r pushBack true;
2016-06-02 21:18:09 +00:00
};
2016-07-02 14:24:53 +00:00
if ((count _r) > 0) then { _r = true } else { _r = nil };
_r