ACE3/addons/rearm/functions/fnc_magazineInSupply.sqf
Githawk 9cfa2f11d9 Stuff
Arguments, Return Value, (optional)
2016-06-06 20:42:20 +02:00

43 lines
1.1 KiB
Plaintext

/*
* Author: GitHawk
* Returns true if the magazine is in the current supply
*
* Arguments:
* 0: Ammo Truck <OBJECT>
* 1: Magazine Classname <STRING>
*
* Return Value:
* Magazine in supply <BOOL>
*
* Example:
* [ammo_truck, "500Rnd_127x99_mag_Tracer_Red"] call ace_rearm_fnc_magazineInSupply
*
* Public: No
*/
#include "script_component.hpp"
params [
["_truck", objNull, [objNull]],
["_magazineClass", "", [""]]
];
if (isNull _truck ||
{_magazineClass isEqualTo ""}) exitWith {false};
// With limited supply, we need to check supply
if (GVAR(supply) == 1) exitWith {_this call FUNC(hasEnoughSupply)};
// With magazine specific supply, we need to check them
if (GVAR(supply) == 2) exitWith {
private _magazineSupply = _truck getVariable [QGVAR(magazineSupply), []];
private _magazinePresent = false;
{
_x params ["_magazine", "_rounds"];
if ((_magazine isEqualTo _magazineClass) && (_rounds > 0)) exitWith {_magazinePresent = true; };
false
} count _magazineSupply;
_magazinePresent
};
// With infinite supply, there is always one left
true