ACE3/addons/interaction/functions/fnc_canPassMagazine.sqf

31 lines
929 B
Plaintext
Raw Normal View History

#include "script_component.hpp"
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-10-06 15:56:32 +00:00
*
2015-09-08 12:07:16 +00:00
* Return Value:
2015-10-06 15:56:32 +00:00
* Unit can pass magazine <BOOL>
2015-09-08 12:07:16 +00:00
*
* Example:
* [_player, _target, "arifle_MX_F"] call ace_interaction_fnc_canPassMagazine
2015-09-08 12:07:16 +00:00
*
* Public: No
*/
params ["_player", "_target", "_weapon"];
2015-09-08 12:07:16 +00:00
2015-11-24 18:07:17 +00:00
if (!GVAR(enableMagazinePassing)) exitWith {false};
2019-04-07 12:22:25 +00:00
if (_weapon isEqualTo "") exitWith {false};
if (((vehicle _target) != _target) && {(vehicle _target) != (vehicle _player)}) exitWith {false};
2015-11-24 18:07:17 +00:00
private _compatibleMags = [_weapon] call CBA_fnc_compatibleMagazines;
(magazinesAmmoFull _player) findIf {
2015-09-11 21:52:00 +00:00
_x params ["_className", "", "_loaded"];
(_className in _compatibleMags) && {!_loaded} && {[_target, _className] call CBA_fnc_canAddItem}
} > -1