Files
DayZ-Epoch/SQF/dayz_code/compile/dze_requiredItemsCheck.sqf
ebaydayz c2b16f0828 Consolidate DZE_ActionInProgress and r_action_count to one variable
There is no point in having two variables for the same purpose.

It is also pointless to keep an action count tally like r_action_count
was doing, since it is only ever checked for being 0 or 1. Any count
higher or lower than that is irrelevant.

I will make this change in vanilla too.
2016-08-25 15:38:27 -04:00

37 lines
1.3 KiB
Plaintext

private ["_missingText","_hasrequireditem","_hastoolweapon","_item","_require","_missing","_text","_classname","_hasbuilditem"];
_item = _this select 0;
_require = _this select 1;
_classname = _this select 2;
_missing = [];
_missingText = "";
_hasrequireditem = true;
_text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
{
_hastoolweapon = _x in weapons player;
if (!_hastoolweapon) then {
_missingText = getText (configFile >> "cfgWeapons" >> _x >> "displayName");
_missing set [count _missing, _missingText];
_hasrequireditem = false;
};
} forEach _require;
_missingText = "";
{
if (_forEachIndex == 0) then {
_missingText = _x;
} else {
if (_forEachIndex == ((count _missing) - 1)) then {
_missingText = _missingText + " and " + _x;
} else {
_missingText = _missingText + ", " + _x;
};
};
} forEach _missing;
_hasbuilditem = _item in magazines player;
if (!_hasbuilditem) exitWith {dayz_actionInProgress = false; format[localize "str_player_31",_text,"build"] call dayz_rollingMessages; false;};
if (!_hasrequireditem) exitWith {dayz_actionInProgress = false; format[localize "str_epoch_player_137",_missingText] call dayz_rollingMessages; false;};
//When calling this function in another script use a silent exitWith, unless you have something special to say. i.e. if (!_hasrequireditem) exitWith{};
_hasrequireditem;