#include "..\script_component.hpp" private _display = findDisplay IDD_LOCKERDIALOG; private _playerItems = _display displayCtrl IDC_PLAYEREQUIPMENTLIST; private _lockerItems = _display displayCtrl IDC_LOCKEREQUIPMENTLIST; private _selectedItem = lbCurSel _lockerItems; private _selectedItemData = _lockerItems lbData _selectedItem; private _data = call compile _selectedItemData; // private _locker = player getVariable ["FORGE_Locker", []]; private _locker = GETVAR(player,FORGE_Locker,[]); if ((isNil { _data })) exitWith { ctrlEnable [IDC_EQUIPBUTTON, true]; }; private _itemType = _data select 0; private _item = _data select 1; private _clear = true; switch (_itemType) do { case "backpack": { if (isNull (unitBackpack player)) then { player addBackpack _item; playSound "FD_Finish_F"; } else { _clear = false; // hintSilent "You already have a backpack equipped!"; ["You already have a backpack equiped!", "warning", 3, "right"] call EFUNC(misc,notify); playSound "FD_CP_Not_Clear_F"; }; }; case "facewear": { if (goggles player == "") then { player addGoggles _item; playSound "FD_Finish_F"; } else { _clear = false; // hintSilent "You already have facewear equipped!"; ["You already have facewear equiped!", "warning", 3, "right"] call EFUNC(misc,notify); playSound "FD_CP_Not_Clear_F"; }; }; case "headgear": { if (headgear player == "") then { player addHeadgear _item; playSound "FD_Finish_F"; } else { _clear = false; // hintSilent "You already have headgear equipped!"; ["You already have headgear equiped!", "warning", 3, "right"] call EFUNC(misc,notify); playSound "FD_CP_Not_Clear_F"; }; }; case "hmd": { if (hmd player == "") then { player linkItem _item; playSound "FD_Finish_F"; } else { _clear = false; // hintSilent "You already have a HMD equipped!"; ["You already have a HMD equiped!", "warning", 3, "right"] call EFUNC(misc,notify); playSound "FD_CP_Not_Clear_F"; }; }; case "item": { if (player canAdd _item) then { player addItem _item; playSound "FD_Finish_F"; } else { _clear = false; // hintSilent "You don't have enough space left!"; ["You don't have enough space left!", "warning", 3, "right"] call EFUNC(misc,notify); playSound "FD_CP_Not_Clear_F"; }; }; case "magazine": { if (player canAdd (_item select 0)) then { player addMagazine [(_item select 0), (_item select 1)]; playSound "FD_Finish_F"; } else { _clear = false; // hintSilent "You don't have enough space left!"; ["You don't have enough space left!", "warning", 3, "right"] call EFUNC(misc,notify); playSound "FD_CP_Not_Clear_F"; }; }; case "uniform": { if (uniform player == "") then { player forceAddUniform _item; playSound "FD_Finish_F"; } else { _clear = false; // hintSilent "You already have a uniform equipped!"; ["You already have a uniform equiped!", "warning", 3, "right"] call EFUNC(misc,notify); playSound "FD_CP_Not_Clear_F"; }; }; case "vest": { if (vest player == "") then { player addVest _item; playSound "FD_Finish_F"; } else { _clear = false; // hintSilent "You already have a vest equipped!"; ["You already have a vest equiped!", "warning", 3, "right"] call EFUNC(misc,notify); playSound "FD_CP_Not_Clear_F"; }; }; // case "weapon": { // if (!(getNumber (configFile >> "CfgWeapons" >> _item >> "type") == 131072) && // {!(getNumber (configFile >> "CfgWeapons" >> _item >> "type") == 1) || primaryWeapon player == ""} && // {!(getNumber (configFile >> "CfgWeapons" >> _item >> "type") == 2) || handgunWeapon player == ""} && // {!(getNumber (configFile >> "CfgWeapons" >> _item >> "type") == 4) || secondaryWeapon player == ""}) then { // private _compatibleMags = getArray (configFile >> "CfgWeapons" >> _item >> "magazines"); // private _baseType = (_compatibleMags select 0) select [0, (_compatibleMags select 0) find "_Tracer"]; // if (_baseType == "") then { _baseType = _compatibleMags select 0 }; // private _magIndices = []; // { // if ((_x select 0) == "magazine") then { // private _magClass = (_x select 1) select 0; // if ((_magClass in _compatibleMags || // {("ACE_" in _magClass) && {_baseType in _magClass}}) && // {player canAdd _magClass}) then { // player addMagazine [_magClass, (_x select 1) select 1]; // _magIndices pushBack _forEachIndex; // }; // }; // } forEach _locker; // reverse _magIndices; // { // _locker deleteAt _x; // } forEach _magIndices; // player addWeapon _item; // playSound "FD_Finish_F"; // } else { // _clear = false; // // hintSilent "You don't have enough space left!"; // ["You don't have enough space left!", "warning", 3, "right"] call EFUNC(misc,notify); // playSound "FD_CP_Not_Clear_F"; // }; // }; case "weapon": { private _weaponType = getNumber (configFile >> "CfgWeapons" >> _item >> "type"); private _hasSpace = switch (_weaponType) do { case 1: {primaryWeapon player == ""}; // Primary case 2: {handgunWeapon player == ""}; // Handgun case 4: {secondaryWeapon player == ""}; // Launcher case 131072: {false}; // Binoculars default {true}; }; if (_hasSpace) then { private _compatibleMags = getArray (configFile >> "CfgWeapons" >> _item >> "magazines"); private _baseType = (_compatibleMags select 0) select [0, (_compatibleMags select 0) find "_Tracer"]; if (_baseType == "") then {_baseType = _compatibleMags select 0}; private _magIndices = []; { if ((_x select 0) == "magazine") then { private _magClass = (_x select 1) select 0; if ((_magClass in _compatibleMags || {("ACE_" in _magClass) && {_baseType in _magClass}}) && {player canAdd _magClass}) then { player addMagazine [_magClass, (_x select 1) select 1]; _magIndices pushBack _forEachIndex; }; }; } forEach _locker; reverse _magIndices; {_locker deleteAt _x} forEach _magIndices; player addWeapon _item; playSound "FD_Finish_F"; } else { _clear = false; ["You don't have enough space left!", "warning", 3, "right"] call EFUNC(misc,notify); playSound "FD_CP_Not_Clear_F"; }; }; }; if (_clear) then { lbClear _lockerItems; lbClear _playerItems; _lockerItems lbSetCurSel -1; _playerItems lbSetCurSel -1; private _index = _locker findIf { _x isEqualTo _data }; _locker deleteAt _index; // player setVariable ["FORGE_Locker", _locker, true]; SETPVAR(player,FORGE_Locker,_locker); [] call FUNC(fetchLocker); [] call FUNC(fetchPlayer); ctrlEnable [IDC_EQUIPBUTTON, true]; };