ACE3/addons/interaction/functions/fnc_canPassMagazine.sqf

33 lines
876 B
Plaintext
Raw Normal View History

2015-09-08 12:07:16 +00:00
/*
* Author: BaerMitUmlaut
* Checks if unit has a spare magazine for the specified weapon.
*
* Arguments:
* 0: Unit that passes the magazine <OBJECT>
* 1: Unit to pass the magazine to <OBJECT>
* 2: Weapon classname <STRING>
2015-09-08 12:07:16 +00:00
*
* Return Value:
* None
*
* Example:
* [_player, _target, "arifle_MX_F"] call ace_interaction_fnc_canPassMagazine
2015-09-08 12:07:16 +00:00
*
* Public: No
*/
#include "script_component.hpp"
params ["_player", "_target", "_weapon"];
private ["_compatibleMags", "_filteredMags"];
2015-09-08 12:07:16 +00:00
_compatibleMags = getArray (configfile >> "CfgWeapons" >> _weapon >> "magazines");
_filteredMags = [magazinesAmmoFull _player, {
params ["_className", "", "_loaded"];
_className in _compatibleMags && !_loaded
}] call EFUNC(common,filter);
2015-09-08 12:07:16 +00:00
2015-09-11 16:24:46 +00:00
if (!(_filteredMags isEqualTo []) && {{_target canAdd (_x select 0)} count _filteredMags > 0}) then {
true
} else {
false
};