mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 04:02:37 +03:00
Related to #1567, so I made this a function so it can be reused. People should call this whenever they are adding a toolbelt item which the player may already have. It has localized strings and handles spawning the weapon holder on water, land and rooftop. Tested both the sledgehammer and key copying. Confirmed all three conditions are working.
46 lines
1.3 KiB
Plaintext
46 lines
1.3 KiB
Plaintext
/*
|
|
Description:
|
|
Checks whether the player has the required items (magazines) or not
|
|
and displays a message if an item is missing.
|
|
|
|
Parameter(s):
|
|
_this: <array> list of item names the player is required to have (can also be an sub-array with item name and quantity)
|
|
|
|
Returns:
|
|
Boolean (true if the player has all required items)
|
|
|
|
How to use:
|
|
_hasItems = [["PartGeneric",4], "PartEngine", ["ItemGenerator"]] call player_checkItems;
|
|
*/
|
|
private ["_items","_inventory","_hasItems","_itemIn","_countIn","_qty","_missing","_missingQty","_textMissing"];
|
|
_items = _this;
|
|
_inventory = magazines player;
|
|
_hasItems = true;
|
|
{
|
|
_itemIn = "";
|
|
_countIn = 1;
|
|
if (typeName _x == "ARRAY") then {
|
|
if (count _x > 0) then {
|
|
_itemIn = _x select 0;
|
|
if (count _x > 1) then {
|
|
_countIn = _x select 1;
|
|
};
|
|
};
|
|
} else {
|
|
_itemIn = _x;
|
|
};
|
|
if (_itemIn != "") then {
|
|
_qty = { (_x == _itemIn) || (configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn) } count _inventory;
|
|
} else {
|
|
_qty = _countIn;
|
|
};
|
|
if (_qty < _countIn) exitWith {
|
|
_missing = _itemIn;
|
|
_missingQty = (_countIn - _qty);
|
|
_hasItems = false;
|
|
_textMissing = getText(configFile >> "CfgMagazines" >> _missing >> "displayName");
|
|
cutText [format[(localize "STR_EPOCH_ACTIONS_12"), _missingQty, _textMissing], "PLAIN DOWN"];
|
|
};
|
|
} forEach _items;
|
|
_hasItems
|