ACE3/addons/interaction/functions/fnc_canPassMagazine.sqf

31 lines
915 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-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
*/
#include "script_component.hpp"
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};
if (((vehicle _target) != _target) && {(vehicle _target) != (vehicle _player)}) exitWith {false};
2015-11-24 18:07:17 +00:00
private _compatibleMags = getArray (configfile >> "CfgWeapons" >> _weapon >> "magazines");
2015-09-11 21:52:00 +00:00
{
_x params ["_className", "", "_loaded"];
if ((_className in _compatibleMags) && {!_loaded} && {_target canAdd _className}) exitWith {true};
false
2015-10-06 15:56:32 +00:00
} foreach (magazinesAmmoFull _player);