Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
- disableSerialization;
- //declare
- _dialog = displayNull;
- //get
- _dialog = findDisplay 666;
- //validate
- if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
- if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
- };
- //declare
- _item = "";
- //get
- _item = lbData[669,(lbCurSel 669)];
- //validate
- if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
- if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
- if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
- //output
- diag_log(format["fn_craftAction:ItemData:%1", _item]);
- _allMaterial = true;
- //declare
- _itemFilter = "item";
- //get
- _itemFilter = lbData[673,(lbCurSel 673)];
- //validate
- if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
- if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
- if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
- //output
- diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
- _matsNeed = 0;
- _config = [_itemFilter] call life_fnc_craftCfg;
- //output
- diag_log(format["fn_craftAction:_config:%1", _config]);
- {
- //output
- diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
- if(_item == _x select 0) then {
- _matsNeed = _x select 1;
- _invSize = count _matsNeed;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _str = [_matsNeed select _i] call life_fnc_varToStr;
- _matsNum = _matsNeed select _i+1;
- if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
- };
- };
- } foreach (_config);
- if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
- //declare
- _newItem = "";
- _oldItem = _matsNeed;
- _newItem = _item;
- //Some checks
- if((count _matsNeed) == 0) exitWith {};
- _weight = nil;
- if(_itemFilter == "item") then {
- _weight = ([_item] call life_fnc_itemWeight);
- };
- if (isNil '_weight') then {
- _weight = 0;
- };
- if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom";};
- if(_itemFilter == "item") then {
- //output
- diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
- _itemName = [_newItem] call life_fnc_varToStr;
- //output
- diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
- } else {
- _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
- //output
- diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
- _itemName = _itemInfo select 1;
- };
- _upp = format["Crafting %1",_itemName];
- //output
- diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
- closeDialog 0;
- //Setup our progress bar.
- 5 cutRsc ["life_progress","PLAIN"];
- _ui = uiNameSpace getVariable "life_progress";
- _progress = _ui displayCtrl 38201;
- _pgText = _ui displayCtrl 38202;
- _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
- _progress progressSetPosition 0.01;
- _cP = 0.01;
- _removeItemSuccess = true;
- _invSize = count _oldItem;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
- };
- if(!_removeItemSuccess) exitWith {
- 5 cutText ["","PLAIN"];
- life_is_processing = false;
- };
- [] call life_fnc_p_updateMenu;
- life_is_processing = true;
- while{true} do{
- sleep 0.3;
- _cP = _cP + 0.01;
- _progress progressSetPosition _cP;
- _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
- if(_cP >= 1) exitWith {};
- };
- if(_itemFilter == "backpack") then{
- if(backpack player == "") then {
- player addBackpack _newItem;
- }else{
- hint localize "STR_CRAFT_AR_Backpack";
- life_is_processing = false;
- };
- };
- if(_itemFilter == "attachments") then {
- if(player canAdd _newItem) then {
- player addItem _newItem;
- } else {
- if(currentWeapon player == "") then {
- player addWeapon _newItem;
- } else {
- 5 cutText ["","PLAIN"];
- };
- };
- };
- //output
- diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
- if(_itemFilter == "item") then {
- _handledItem = [_newItem,1] call life_fnc_varHandle;
- //output
- diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
- [true,_handledItem,1] call life_fnc_handleInv;
- };
- if(_itemFilter == "pweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "pammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "hidden")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gang")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gangattach")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do { _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
- };
- life_is_processing = false;
- }; };
- };
- 5 cutText ["","PLAIN"];
- titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
- life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
- disableSerialization;
- //declare
- _dialog = displayNull;
- //get
- _dialog = findDisplay 666;
- //validate
- if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
- if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
- };
- //declare
- _item = "";
- //get
- _item = lbData[669,(lbCurSel 669)];
- //validate
- if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
- if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
- if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
- //output
- diag_log(format["fn_craftAction:ItemData:%1", _item]);
- _allMaterial = true;
- //declare
- _itemFilter = "item";
- //get
- _itemFilter = lbData[673,(lbCurSel 673)];
- //validate
- if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
- if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
- if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
- //output
- diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
- _matsNeed = 0;
- _config = [_itemFilter] call life_fnc_craftCfg;
- //output
- diag_log(format["fn_craftAction:_config:%1", _config]);
- {
- //output
- diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
- if(_item == _x select 0) then {
- _matsNeed = _x select 1;
- _invSize = count _matsNeed;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _str = [_matsNeed select _i] call life_fnc_varToStr;
- _matsNum = _matsNeed select _i+1;
- if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
- };
- };
- } foreach (_config);
- if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
- //declare
- _newItem = "";
- _oldItem = _matsNeed;
- _newItem = _item;
- //Some checks
- if((count _matsNeed) == 0) exitWith {};
- _weight = nil;
- if(_itemFilter == "item") then {
- _weight = ([_item] call life_fnc_itemWeight);
- };
- if (isNil '_weight') then {
- _weight = 0;
- };
- if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom";};
- if(_itemFilter == "item") then {
- //output
- diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
- _itemName = [_newItem] call life_fnc_varToStr;
- //output
- diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
- } else {
- _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
- //output
- diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
- _itemName = _itemInfo select 1;
- };
- _upp = format["Crafting %1",_itemName];
- //output
- diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
- closeDialog 0;
- //Setup our progress bar.
- 5 cutRsc ["life_progress","PLAIN"];
- _ui = uiNameSpace getVariable "life_progress";
- _progress = _ui displayCtrl 38201;
- _pgText = _ui displayCtrl 38202;
- _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
- _progress progressSetPosition 0.01;
- _cP = 0.01;
- _removeItemSuccess = true;
- _invSize = count _oldItem;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
- };
- if(!_removeItemSuccess) exitWith {
- 5 cutText ["","PLAIN"];
- life_is_processing = false;
- };
- [] call life_fnc_p_updateMenu;
- life_is_processing = true;
- while{true} do{
- sleep 0.3;
- _cP = _cP + 0.01;
- _progress progressSetPosition _cP;
- _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
- if(_cP >= 1) exitWith {};
- };
- if(_itemFilter == "backpack") then{
- if(backpack player == "") then {
- player addBackpack _newItem;
- }else{
- hint localize "STR_CRAFT_AR_Backpack";
- life_is_processing = false;
- };
- };
- if(_itemFilter == "attachments") then {
- if(player canAdd _newItem) then {
- player addItem _newItem;
- } else {
- if(currentWeapon player == "") then {
- player addWeapon _newItem;
- } else {
- 5 cutText ["","PLAIN"];
- };
- };
- };
- //output
- diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
- if(_itemFilter == "item") then {
- _handledItem = [_newItem,1] call life_fnc_varHandle;
- //output
- diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
- [true,_handledItem,1] call life_fnc_handleInv;
- };
- if(_itemFilter == "pweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "pammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "hidden")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gang")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gangattach")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do { _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
- };
- life_is_processing = false;
- }; };
- };
- 5 cutText ["","PLAIN"];
- titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
- life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
- disableSerialization;
- //declare
- _dialog = displayNull;
- //get
- _dialog = findDisplay 666;
- //validate
- if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
- if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
- };
- //declare
- _item = "";
- //get
- _item = lbData[669,(lbCurSel 669)];
- //validate
- if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
- if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
- if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
- //output
- diag_log(format["fn_craftAction:ItemData:%1", _item]);
- _allMaterial = true;
- //declare
- _itemFilter = "item";
- //get
- _itemFilter = lbData[673,(lbCurSel 673)];
- //validate
- if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
- if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
- if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
- //output
- diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
- _matsNeed = 0;
- _config = [_itemFilter] call life_fnc_craftCfg;
- //output
- diag_log(format["fn_craftAction:_config:%1", _config]);
- {
- //output
- diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
- if(_item == _x select 0) then {
- _matsNeed = _x select 1;
- _invSize = count _matsNeed;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _str = [_matsNeed select _i] call life_fnc_varToStr;
- _matsNum = _matsNeed select _i+1;
- if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
- };
- };
- } foreach (_config);
- if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
- //declare
- _newItem = "";
- _oldItem = _matsNeed;
- _newItem = _item;
- //Some checks
- if((count _matsNeed) == 0) exitWith {};
- _weight = nil;
- if(_itemFilter == "item") then {
- _weight = ([_item] call life_fnc_itemWeight);
- };
- if (isNil '_weight') then {
- _weight = 0;
- };
- if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom";};
- if(_itemFilter == "item") then {
- //output
- diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
- _itemName = [_newItem] call life_fnc_varToStr;
- //output
- diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
- } else {
- _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
- //output
- diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
- _itemName = _itemInfo select 1;
- };
- _upp = format["Crafting %1",_itemName];
- //output
- diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
- closeDialog 0;
- //Setup our progress bar.
- 5 cutRsc ["life_progress","PLAIN"];
- _ui = uiNameSpace getVariable "life_progress";
- _progress = _ui displayCtrl 38201;
- _pgText = _ui displayCtrl 38202;
- _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
- _progress progressSetPosition 0.01;
- _cP = 0.01;
- _removeItemSuccess = true;
- _invSize = count _oldItem;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
- };
- if(!_removeItemSuccess) exitWith {
- 5 cutText ["","PLAIN"];
- life_is_processing = false;
- };
- [] call life_fnc_p_updateMenu;
- life_is_processing = true;
- while{true} do{
- sleep 0.3;
- _cP = _cP + 0.01;
- _progress progressSetPosition _cP;
- _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
- if(_cP >= 1) exitWith {};
- };
- if(_itemFilter == "backpack") then{
- if(backpack player == "") then {
- player addBackpack _newItem;
- }else{
- hint localize "STR_CRAFT_AR_Backpack";
- life_is_processing = false;
- };
- };
- if(_itemFilter == "attachments") then {
- if(player canAdd _newItem) then {
- player addItem _newItem;
- } else {
- if(currentWeapon player == "") then {
- player addWeapon _newItem;
- } else {
- 5 cutText ["","PLAIN"];
- };
- };
- };
- //output
- diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
- if(_itemFilter == "item") then {
- _handledItem = [_newItem,1] call life_fnc_varHandle;
- //output
- diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
- [true,_handledItem,1] call life_fnc_handleInv;
- };
- if(_itemFilter == "pweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "pammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "hidden")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gang")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gangattach")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do { _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
- };
- life_is_processing = false;
- }; };
- };
- 5 cutText ["","PLAIN"];
- titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
- life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
- disableSerialization;
- //declare
- _dialog = displayNull;
- //get
- _dialog = findDisplay 666;
- //validate
- if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
- if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
- };
- //declare
- _item = "";
- //get
- _item = lbData[669,(lbCurSel 669)];
- //validate
- if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
- if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
- if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
- //output
- diag_log(format["fn_craftAction:ItemData:%1", _item]);
- _allMaterial = true;
- //declare
- _itemFilter = "item";
- //get
- _itemFilter = lbData[673,(lbCurSel 673)];
- //validate
- if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
- if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
- if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
- //output
- diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
- _matsNeed = 0;
- _config = [_itemFilter] call life_fnc_craftCfg;
- //output
- diag_log(format["fn_craftAction:_config:%1", _config]);
- {
- //output
- diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
- if(_item == _x select 0) then {
- _matsNeed = _x select 1;
- _invSize = count _matsNeed;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _str = [_matsNeed select _i] call life_fnc_varToStr;
- _matsNum = _matsNeed select _i+1;
- if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
- };
- };
- } foreach (_config);
- if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
- //declare
- _newItem = "";
- _oldItem = _matsNeed;
- _newItem = _item;
- //Some checks
- if((count _matsNeed) == 0) exitWith {};
- _weight = nil;
- if(_itemFilter == "item") then {
- _weight = ([_item] call life_fnc_itemWeight);
- };
- if (isNil '_weight') then {
- _weight = 0;
- };
- if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom";};
- if(_itemFilter == "item") then {
- //output
- diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
- _itemName = [_newItem] call life_fnc_varToStr;
- //output
- diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
- } else {
- _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
- //output
- diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
- _itemName = _itemInfo select 1;
- };
- _upp = format["Crafting %1",_itemName];
- //output
- diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
- closeDialog 0;
- //Setup our progress bar.
- 5 cutRsc ["life_progress","PLAIN"];
- _ui = uiNameSpace getVariable "life_progress";
- _progress = _ui displayCtrl 38201;
- _pgText = _ui displayCtrl 38202;
- _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
- _progress progressSetPosition 0.01;
- _cP = 0.01;
- _removeItemSuccess = true;
- _invSize = count _oldItem;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
- };
- if(!_removeItemSuccess) exitWith {
- 5 cutText ["","PLAIN"];
- life_is_processing = false;
- };
- [] call life_fnc_p_updateMenu;
- life_is_processing = true;
- while{true} do{
- sleep 0.3;
- _cP = _cP + 0.01;
- _progress progressSetPosition _cP;
- _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
- if(_cP >= 1) exitWith {};
- };
- if(_itemFilter == "backpack") then{
- if(backpack player == "") then {
- player addBackpack _newItem;
- }else{
- hint localize "STR_CRAFT_AR_Backpack";
- life_is_processing = false;
- };
- };
- if(_itemFilter == "attachments") then {
- if(player canAdd _newItem) then {
- player addItem _newItem;
- } else {
- if(currentWeapon player == "") then {
- player addWeapon _newItem;
- } else {
- 5 cutText ["","PLAIN"];
- };
- };
- };
- //output
- diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
- if(_itemFilter == "item") then {
- _handledItem = [_newItem,1] call life_fnc_varHandle;
- //output
- diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
- [true,_handledItem,1] call life_fnc_handleInv;
- };
- if(_itemFilter == "pweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "pammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "hidden")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gang")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gangattach")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do { _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
- };
- life_is_processing = false;
- }; };
- };
- 5 cutText ["","PLAIN"];
- titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
- life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
- disableSerialization;
- //declare
- _dialog = displayNull;
- //get
- _dialog = findDisplay 666;
- //validate
- if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
- if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
- };
- //declare
- _item = "";
- //get
- _item = lbData[669,(lbCurSel 669)];
- //validate
- if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
- if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
- if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
- //output
- diag_log(format["fn_craftAction:ItemData:%1", _item]);
- _allMaterial = true;
- //declare
- _itemFilter = "item";
- //get
- _itemFilter = lbData[673,(lbCurSel 673)];
- //validate
- if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
- if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
- if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
- //output
- diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
- _matsNeed = 0;
- _config = [_itemFilter] call life_fnc_craftCfg;
- //output
- diag_log(format["fn_craftAction:_config:%1", _config]);
- {
- //output
- diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
- if(_item == _x select 0) then {
- _matsNeed = _x select 1;
- _invSize = count _matsNeed;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _str = [_matsNeed select _i] call life_fnc_varToStr;
- _matsNum = _matsNeed select _i+1;
- if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
- };
- };
- } foreach (_config);
- if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
- //declare
- _newItem = "";
- _oldItem = _matsNeed;
- _newItem = _item;
- //Some checks
- if((count _matsNeed) == 0) exitWith {};
- _weight = nil;
- if(_itemFilter == "item") then {
- _weight = ([_item] call life_fnc_itemWeight);
- };
- if (isNil '_weight') then {
- _weight = 0;
- };
- if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom";};
- if(_itemFilter == "item") then {
- //output
- diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
- _itemName = [_newItem] call life_fnc_varToStr;
- //output
- diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
- } else {
- _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
- //output
- diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
- _itemName = _itemInfo select 1;
- };
- _upp = format["Crafting %1",_itemName];
- //output
- diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
- closeDialog 0;
- //Setup our progress bar.
- 5 cutRsc ["life_progress","PLAIN"];
- _ui = uiNameSpace getVariable "life_progress";
- _progress = _ui displayCtrl 38201;
- _pgText = _ui displayCtrl 38202;
- _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
- _progress progressSetPosition 0.01;
- _cP = 0.01;
- _removeItemSuccess = true;
- _invSize = count _oldItem;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
- };
- if(!_removeItemSuccess) exitWith {
- 5 cutText ["","PLAIN"];
- life_is_processing = false;
- };
- [] call life_fnc_p_updateMenu;
- life_is_processing = true;
- while{true} do{
- sleep 0.3;
- _cP = _cP + 0.01;
- _progress progressSetPosition _cP;
- _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
- if(_cP >= 1) exitWith {};
- };
- if(_itemFilter == "backpack") then{
- if(backpack player == "") then {
- player addBackpack _newItem;
- }else{
- hint localize "STR_CRAFT_AR_Backpack";
- life_is_processing = false;
- };
- };
- if(_itemFilter == "attachments") then {
- if(player canAdd _newItem) then {
- player addItem _newItem;
- } else {
- if(currentWeapon player == "") then {
- player addWeapon _newItem;
- } else {
- 5 cutText ["","PLAIN"];
- };
- };
- };
- //output
- diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
- if(_itemFilter == "item") then {
- _handledItem = [_newItem,1] call life_fnc_varHandle;
- //output
- diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
- [true,_handledItem,1] call life_fnc_handleInv;
- };
- if(_itemFilter == "pweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "pammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "hidden")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gang")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gangattach")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do { _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
- };
- life_is_processing = false;
- }; };
- };
- 5 cutText ["","PLAIN"];
- titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
- life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
- disableSerialization;
- //declare
- _dialog = displayNull;
- //get
- _dialog = findDisplay 666;
- //validate
- if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
- if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
- };
- //declare
- _item = "";
- //get
- _item = lbData[669,(lbCurSel 669)];
- //validate
- if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
- if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
- if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
- //output
- diag_log(format["fn_craftAction:ItemData:%1", _item]);
- _allMaterial = true;
- //declare
- _itemFilter = "item";
- //get
- _itemFilter = lbData[673,(lbCurSel 673)];
- //validate
- if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
- if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
- if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
- //output
- diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
- _matsNeed = 0;
- _config = [_itemFilter] call life_fnc_craftCfg;
- //output
- diag_log(format["fn_craftAction:_config:%1", _config]);
- {
- //output
- diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
- if(_item == _x select 0) then {
- _matsNeed = _x select 1;
- _invSize = count _matsNeed;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _str = [_matsNeed select _i] call life_fnc_varToStr;
- _matsNum = _matsNeed select _i+1;
- if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
- };
- };
- } foreach (_config);
- if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
- //declare
- _newItem = "";
- _oldItem = _matsNeed;
- _newItem = _item;
- //Some checks
- if((count _matsNeed) == 0) exitWith {};
- _weight = nil;
- if(_itemFilter == "item") then {
- _weight = ([_item] call life_fnc_itemWeight);
- };
- if (isNil '_weight') then {
- _weight = 0;
- };
- if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom";};
- if(_itemFilter == "item") then {
- //output
- diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
- _itemName = [_newItem] call life_fnc_varToStr;
- //output
- diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
- } else {
- _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
- //output
- diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
- _itemName = _itemInfo select 1;
- };
- _upp = format["Crafting %1",_itemName];
- //output
- diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
- closeDialog 0;
- //Setup our progress bar.
- 5 cutRsc ["life_progress","PLAIN"];
- _ui = uiNameSpace getVariable "life_progress";
- _progress = _ui displayCtrl 38201;
- _pgText = _ui displayCtrl 38202;
- _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
- _progress progressSetPosition 0.01;
- _cP = 0.01;
- _removeItemSuccess = true;
- _invSize = count _oldItem;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
- };
- if(!_removeItemSuccess) exitWith {
- 5 cutText ["","PLAIN"];
- life_is_processing = false;
- };
- [] call life_fnc_p_updateMenu;
- life_is_processing = true;
- while{true} do{
- sleep 0.3;
- _cP = _cP + 0.01;
- _progress progressSetPosition _cP;
- _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
- if(_cP >= 1) exitWith {};
- };
- if(_itemFilter == "backpack") then{
- if(backpack player == "") then {
- player addBackpack _newItem;
- }else{
- hint localize "STR_CRAFT_AR_Backpack";
- life_is_processing = false;
- };
- };
- if(_itemFilter == "attachments") then {
- if(player canAdd _newItem) then {
- player addItem _newItem;
- } else {
- if(currentWeapon player == "") then {
- player addWeapon _newItem;
- } else {
- 5 cutText ["","PLAIN"];
- };
- };
- };
- //output
- diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
- if(_itemFilter == "item") then {
- _handledItem = [_newItem,1] call life_fnc_varHandle;
- //output
- diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
- [true,_handledItem,1] call life_fnc_handleInv;
- };
- if(_itemFilter == "pweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "pammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "hidden")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gang")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gangattach")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do { _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
- };
- life_is_processing = false;
- }; };
- };
- 5 cutText ["","PLAIN"];
- titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
- life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
- disableSerialization;
- //declare
- _dialog = displayNull;
- //get
- _dialog = findDisplay 666;
- //validate
- if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
- if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
- };
- //declare
- _item = "";
- //get
- _item = lbData[669,(lbCurSel 669)];
- //validate
- if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
- if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
- if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
- //output
- diag_log(format["fn_craftAction:ItemData:%1", _item]);
- _allMaterial = true;
- //declare
- _itemFilter = "item";
- //get
- _itemFilter = lbData[673,(lbCurSel 673)];
- //validate
- if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
- if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
- if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
- //output
- diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
- _matsNeed = 0;
- _config = [_itemFilter] call life_fnc_craftCfg;
- //output
- diag_log(format["fn_craftAction:_config:%1", _config]);
- {
- //output
- diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
- if(_item == _x select 0) then {
- _matsNeed = _x select 1;
- _invSize = count _matsNeed;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _str = [_matsNeed select _i] call life_fnc_varToStr;
- _matsNum = _matsNeed select _i+1;
- if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
- };
- };
- } foreach (_config);
- if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
- //declare
- _newItem = "";
- _oldItem = _matsNeed;
- _newItem = _item;
- //Some checks
- if((count _matsNeed) == 0) exitWith {};
- _weight = nil;
- if(_itemFilter == "item") then {
- _weight = ([_item] call life_fnc_itemWeight);
- };
- if (isNil '_weight') then {
- _weight = 0;
- };
- if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom";};
- if(_itemFilter == "item") then {
- //output
- diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
- _itemName = [_newItem] call life_fnc_varToStr;
- //output
- diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
- } else {
- _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
- //output
- diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
- _itemName = _itemInfo select 1;
- };
- _upp = format["Crafting %1",_itemName];
- //output
- diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
- closeDialog 0;
- //Setup our progress bar.
- 5 cutRsc ["life_progress","PLAIN"];
- _ui = uiNameSpace getVariable "life_progress";
- _progress = _ui displayCtrl 38201;
- _pgText = _ui displayCtrl 38202;
- _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
- _progress progressSetPosition 0.01;
- _cP = 0.01;
- _removeItemSuccess = true;
- _invSize = count _oldItem;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
- };
- if(!_removeItemSuccess) exitWith {
- 5 cutText ["","PLAIN"];
- life_is_processing = false;
- };
- [] call life_fnc_p_updateMenu;
- life_is_processing = true;
- while{true} do{
- sleep 0.3;
- _cP = _cP + 0.01;
- _progress progressSetPosition _cP;
- _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
- if(_cP >= 1) exitWith {};
- };
- if(_itemFilter == "backpack") then{
- if(backpack player == "") then {
- player addBackpack _newItem;
- }else{
- hint localize "STR_CRAFT_AR_Backpack";
- life_is_processing = false;
- };
- };
- if(_itemFilter == "attachments") then {
- if(player canAdd _newItem) then {
- player addItem _newItem;
- } else {
- if(currentWeapon player == "") then {
- player addWeapon _newItem;
- } else {
- 5 cutText ["","PLAIN"];
- };
- };
- };
- //output
- diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
- if(_itemFilter == "item") then {
- _handledItem = [_newItem,1] call life_fnc_varHandle;
- //output
- diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
- [true,_handledItem,1] call life_fnc_handleInv;
- };
- if(_itemFilter == "pweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "pammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "hidden")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gang")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gangattach")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do { _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
- };
- life_is_processing = false;
- }; };
- };
- 5 cutText ["","PLAIN"];
- titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
- life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
- disableSerialization;
- //declare
- _dialog = displayNull;
- //get
- _dialog = findDisplay 666;
- //validate
- if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
- if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
- };
- //declare
- _item = "";
- //get
- _item = lbData[669,(lbCurSel 669)];
- //validate
- if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
- if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
- if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
- //output
- diag_log(format["fn_craftAction:ItemData:%1", _item]);
- _allMaterial = true;
- //declare
- _itemFilter = "item";
- //get
- _itemFilter = lbData[673,(lbCurSel 673)];
- //validate
- if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
- if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
- if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
- //output
- diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
- _matsNeed = 0;
- _config = [_itemFilter] call life_fnc_craftCfg;
- //output
- diag_log(format["fn_craftAction:_config:%1", _config]);
- {
- //output
- diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
- if(_item == _x select 0) then {
- _matsNeed = _x select 1;
- _invSize = count _matsNeed;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _str = [_matsNeed select _i] call life_fnc_varToStr;
- _matsNum = _matsNeed select _i+1;
- if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
- };
- };
- } foreach (_config);
- if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
- //declare
- _newItem = "";
- _oldItem = _matsNeed;
- _newItem = _item;
- //Some checks
- if((count _matsNeed) == 0) exitWith {};
- _weight = nil;
- if(_itemFilter == "item") then {
- _weight = ([_item] call life_fnc_itemWeight);
- };
- if (isNil '_weight') then {
- _weight = 0;
- };
- if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom";};
- if(_itemFilter == "item") then {
- //output
- diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
- _itemName = [_newItem] call life_fnc_varToStr;
- //output
- diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
- } else {
- _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
- //output
- diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
- _itemName = _itemInfo select 1;
- };
- _upp = format["Crafting %1",_itemName];
- //output
- diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
- closeDialog 0;
- //Setup our progress bar.
- 5 cutRsc ["life_progress","PLAIN"];
- _ui = uiNameSpace getVariable "life_progress";
- _progress = _ui displayCtrl 38201;
- _pgText = _ui displayCtrl 38202;
- _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
- _progress progressSetPosition 0.01;
- _cP = 0.01;
- _removeItemSuccess = true;
- _invSize = count _oldItem;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
- };
- if(!_removeItemSuccess) exitWith {
- 5 cutText ["","PLAIN"];
- life_is_processing = false;
- };
- [] call life_fnc_p_updateMenu;
- life_is_processing = true;
- while{true} do{
- sleep 0.3;
- _cP = _cP + 0.01;
- _progress progressSetPosition _cP;
- _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
- if(_cP >= 1) exitWith {};
- };
- if(_itemFilter == "backpack") then{
- if(backpack player == "") then {
- player addBackpack _newItem;
- }else{
- hint localize "STR_CRAFT_AR_Backpack";
- life_is_processing = false;
- };
- };
- if(_itemFilter == "attachments") then {
- if(player canAdd _newItem) then {
- player addItem _newItem;
- } else {
- if(currentWeapon player == "") then {
- player addWeapon _newItem;
- } else {
- 5 cutText ["","PLAIN"];
- };
- };
- };
- //output
- diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
- if(_itemFilter == "item") then {
- _handledItem = [_newItem,1] call life_fnc_varHandle;
- //output
- diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
- [true,_handledItem,1] call life_fnc_handleInv;
- };
- if(_itemFilter == "pweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "pammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "hidden")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gang")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gangattach")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do { _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
- };
- life_is_processing = false;
- }; };
- };
- 5 cutText ["","PLAIN"];
- titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
- life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
- disableSerialization;
- //declare
- _dialog = displayNull;
- //get
- _dialog = findDisplay 666;
- //validate
- if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
- if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
- };
- //declare
- _item = "";
- //get
- _item = lbData[669,(lbCurSel 669)];
- //validate
- if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
- if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
- if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
- //output
- diag_log(format["fn_craftAction:ItemData:%1", _item]);
- _allMaterial = true;
- //declare
- _itemFilter = "item";
- //get
- _itemFilter = lbData[673,(lbCurSel 673)];
- //validate
- if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
- if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
- if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
- //output
- diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
- _matsNeed = 0;
- _config = [_itemFilter] call life_fnc_craftCfg;
- //output
- diag_log(format["fn_craftAction:_config:%1", _config]);
- {
- //output
- diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
- if(_item == _x select 0) then {
- _matsNeed = _x select 1;
- _invSize = count _matsNeed;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _str = [_matsNeed select _i] call life_fnc_varToStr;
- _matsNum = _matsNeed select _i+1;
- if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
- };
- };
- } foreach (_config);
- if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
- //declare
- _newItem = "";
- _oldItem = _matsNeed;
- _newItem = _item;
- //Some checks
- if((count _matsNeed) == 0) exitWith {};
- _weight = nil;
- if(_itemFilter == "item") then {
- _weight = ([_item] call life_fnc_itemWeight);
- };
- if (isNil '_weight') then {
- _weight = 0;
- };
- if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom";};
- if(_itemFilter == "item") then {
- //output
- diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
- _itemName = [_newItem] call life_fnc_varToStr;
- //output
- diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
- } else {
- _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
- //output
- diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
- _itemName = _itemInfo select 1;
- };
- _upp = format["Crafting %1",_itemName];
- //output
- diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
- closeDialog 0;
- //Setup our progress bar.
- 5 cutRsc ["life_progress","PLAIN"];
- _ui = uiNameSpace getVariable "life_progress";
- _progress = _ui displayCtrl 38201;
- _pgText = _ui displayCtrl 38202;
- _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
- _progress progressSetPosition 0.01;
- _cP = 0.01;
- _removeItemSuccess = true;
- _invSize = count _oldItem;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
- };
- if(!_removeItemSuccess) exitWith {
- 5 cutText ["","PLAIN"];
- life_is_processing = false;
- };
- [] call life_fnc_p_updateMenu;
- life_is_processing = true;
- while{true} do{
- sleep 0.3;
- _cP = _cP + 0.01;
- _progress progressSetPosition _cP;
- _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
- if(_cP >= 1) exitWith {};
- };
- if(_itemFilter == "backpack") then{
- if(backpack player == "") then {
- player addBackpack _newItem;
- }else{
- hint localize "STR_CRAFT_AR_Backpack";
- life_is_processing = false;
- };
- };
- if(_itemFilter == "attachments") then {
- if(player canAdd _newItem) then {
- player addItem _newItem;
- } else {
- if(currentWeapon player == "") then {
- player addWeapon _newItem;
- } else {
- 5 cutText ["","PLAIN"];
- };
- };
- };
- //output
- diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
- if(_itemFilter == "item") then {
- _handledItem = [_newItem,1] call life_fnc_varHandle;
- //output
- diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
- [true,_handledItem,1] call life_fnc_handleInv;
- };
- if(_itemFilter == "pweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "pammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "hidden")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gang")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gangattach")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do { _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
- };
- life_is_processing = false;
- }; };
- };
- 5 cutText ["","PLAIN"];
- titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
- life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
- disableSerialization;
- //declare
- _dialog = displayNull;
- //get
- _dialog = findDisplay 666;
- //validate
- if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
- if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
- };
- //declare
- _item = "";
- //get
- _item = lbData[669,(lbCurSel 669)];
- //validate
- if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
- if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
- if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
- //output
- diag_log(format["fn_craftAction:ItemData:%1", _item]);
- _allMaterial = true;
- //declare
- _itemFilter = "item";
- //get
- _itemFilter = lbData[673,(lbCurSel 673)];
- //validate
- if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
- if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
- if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
- //output
- diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
- _matsNeed = 0;
- _config = [_itemFilter] call life_fnc_craftCfg;
- //output
- diag_log(format["fn_craftAction:_config:%1", _config]);
- {
- //output
- diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
- if(_item == _x select 0) then {
- _matsNeed = _x select 1;
- _invSize = count _matsNeed;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _str = [_matsNeed select _i] call life_fnc_varToStr;
- _matsNum = _matsNeed select _i+1;
- if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
- };
- };
- } foreach (_config);
- if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
- //declare
- _newItem = "";
- _oldItem = _matsNeed;
- _newItem = _item;
- //Some checks
- if((count _matsNeed) == 0) exitWith {};
- _weight = nil;
- if(_itemFilter == "item") then {
- _weight = ([_item] call life_fnc_itemWeight);
- };
- if (isNil '_weight') then {
- _weight = 0;
- };
- if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom";};
- if(_itemFilter == "item") then {
- //output
- diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
- _itemName = [_newItem] call life_fnc_varToStr;
- //output
- diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
- } else {
- _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
- //output
- diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
- _itemName = _itemInfo select 1;
- };
- _upp = format["Crafting %1",_itemName];
- //output
- diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
- closeDialog 0;
- //Setup our progress bar.
- 5 cutRsc ["life_progress","PLAIN"];
- _ui = uiNameSpace getVariable "life_progress";
- _progress = _ui displayCtrl 38201;
- _pgText = _ui displayCtrl 38202;
- _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
- _progress progressSetPosition 0.01;
- _cP = 0.01;
- _removeItemSuccess = true;
- _invSize = count _oldItem;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
- };
- if(!_removeItemSuccess) exitWith {
- 5 cutText ["","PLAIN"];
- life_is_processing = false;
- };
- [] call life_fnc_p_updateMenu;
- life_is_processing = true;
- while{true} do{
- sleep 0.3;
- _cP = _cP + 0.01;
- _progress progressSetPosition _cP;
- _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
- if(_cP >= 1) exitWith {};
- };
- if(_itemFilter == "backpack") then{
- if(backpack player == "") then {
- player addBackpack _newItem;
- }else{
- hint localize "STR_CRAFT_AR_Backpack";
- life_is_processing = false;
- };
- };
- if(_itemFilter == "attachments") then {
- if(player canAdd _newItem) then {
- player addItem _newItem;
- } else {
- if(currentWeapon player == "") then {
- player addWeapon _newItem;
- } else {
- 5 cutText ["","PLAIN"];
- };
- };
- };
- //output
- diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
- if(_itemFilter == "item") then {
- _handledItem = [_newItem,1] call life_fnc_varHandle;
- //output
- diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
- [true,_handledItem,1] call life_fnc_handleInv;
- };
- if(_itemFilter == "pweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "pammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "hidden")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gang")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gangattach")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do { _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
- };
- life_is_processing = false;
- }; };
- };
- 5 cutText ["","PLAIN"];
- titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
- life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
- disableSerialization;
- //declare
- _dialog = displayNull;
- //get
- _dialog = findDisplay 666;
- //validate
- if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
- if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
- };
- //declare
- _item = "";
- //get
- _item = lbData[669,(lbCurSel 669)];
- //validate
- if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
- if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
- if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
- //output
- diag_log(format["fn_craftAction:ItemData:%1", _item]);
- _allMaterial = true;
- //declare
- _itemFilter = "item";
- //get
- _itemFilter = lbData[673,(lbCurSel 673)];
- //validate
- if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
- if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
- if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
- //output
- diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
- _matsNeed = 0;
- _config = [_itemFilter] call life_fnc_craftCfg;
- //output
- diag_log(format["fn_craftAction:_config:%1", _config]);
- {
- //output
- diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
- if(_item == _x select 0) then {
- _matsNeed = _x select 1;
- _invSize = count _matsNeed;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _str = [_matsNeed select _i] call life_fnc_varToStr;
- _matsNum = _matsNeed select _i+1;
- if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
- };
- };
- } foreach (_config);
- if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
- //declare
- _newItem = "";
- _oldItem = _matsNeed;
- _newItem = _item;
- //Some checks
- if((count _matsNeed) == 0) exitWith {};
- _weight = nil;
- if(_itemFilter == "item") then {
- _weight = ([_item] call life_fnc_itemWeight);
- };
- if (isNil '_weight') then {
- _weight = 0;
- };
- if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom";};
- if(_itemFilter == "item") then {
- //output
- diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
- _itemName = [_newItem] call life_fnc_varToStr;
- //output
- diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
- } else {
- _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
- //output
- diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
- _itemName = _itemInfo select 1;
- };
- _upp = format["Crafting %1",_itemName];
- //output
- diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
- closeDialog 0;
- //Setup our progress bar.
- 5 cutRsc ["life_progress","PLAIN"];
- _ui = uiNameSpace getVariable "life_progress";
- _progress = _ui displayCtrl 38201;
- _pgText = _ui displayCtrl 38202;
- _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
- _progress progressSetPosition 0.01;
- _cP = 0.01;
- _removeItemSuccess = true;
- _invSize = count _oldItem;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
- };
- if(!_removeItemSuccess) exitWith {
- 5 cutText ["","PLAIN"];
- life_is_processing = false;
- };
- [] call life_fnc_p_updateMenu;
- life_is_processing = true;
- while{true} do{
- sleep 0.3;
- _cP = _cP + 0.01;
- _progress progressSetPosition _cP;
- _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
- if(_cP >= 1) exitWith {};
- };
- if(_itemFilter == "backpack") then{
- if(backpack player == "") then {
- player addBackpack _newItem;
- }else{
- hint localize "STR_CRAFT_AR_Backpack";
- life_is_processing = false;
- };
- };
- if(_itemFilter == "attachments") then {
- if(player canAdd _newItem) then {
- player addItem _newItem;
- } else {
- if(currentWeapon player == "") then {
- player addWeapon _newItem;
- } else {
- 5 cutText ["","PLAIN"];
- };
- };
- };
- //output
- diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
- if(_itemFilter == "item") then {
- _handledItem = [_newItem,1] call life_fnc_varHandle;
- //output
- diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
- [true,_handledItem,1] call life_fnc_handleInv;
- };
- if(_itemFilter == "pweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "pammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "hidden")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gang")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gangattach")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do { _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
- };
- life_is_processing = false;
- }; };
- };
- 5 cutText ["","PLAIN"];
- titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
- life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
- disableSerialization;
- //declare
- _dialog = displayNull;
- //get
- _dialog = findDisplay 666;
- //validate
- if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
- if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
- };
- //declare
- _item = "";
- //get
- _item = lbData[669,(lbCurSel 669)];
- //validate
- if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
- if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
- if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
- //output
- diag_log(format["fn_craftAction:ItemData:%1", _item]);
- _allMaterial = true;
- //declare
- _itemFilter = "item";
- //get
- _itemFilter = lbData[673,(lbCurSel 673)];
- //validate
- if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
- if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
- if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
- //output
- diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
- _matsNeed = 0;
- _config = [_itemFilter] call life_fnc_craftCfg;
- //output
- diag_log(format["fn_craftAction:_config:%1", _config]);
- {
- //output
- diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
- if(_item == _x select 0) then {
- _matsNeed = _x select 1;
- _invSize = count _matsNeed;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _str = [_matsNeed select _i] call life_fnc_varToStr;
- _matsNum = _matsNeed select _i+1;
- if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
- };
- };
- } foreach (_config);
- if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
- //declare
- _newItem = "";
- _oldItem = _matsNeed;
- _newItem = _item;
- //Some checks
- if((count _matsNeed) == 0) exitWith {};
- _weight = nil;
- if(_itemFilter == "item") then {
- _weight = ([_item] call life_fnc_itemWeight);
- };
- if (isNil '_weight') then {
- _weight = 0;
- };
- if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom";};
- if(_itemFilter == "item") then {
- //output
- diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
- _itemName = [_newItem] call life_fnc_varToStr;
- //output
- diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
- } else {
- _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
- //output
- diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
- _itemName = _itemInfo select 1;
- };
- _upp = format["Crafting %1",_itemName];
- //output
- diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
- closeDialog 0;
- //Setup our progress bar.
- 5 cutRsc ["life_progress","PLAIN"];
- _ui = uiNameSpace getVariable "life_progress";
- _progress = _ui displayCtrl 38201;
- _pgText = _ui displayCtrl 38202;
- _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
- _progress progressSetPosition 0.01;
- _cP = 0.01;
- _removeItemSuccess = true;
- _invSize = count _oldItem;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
- };
- if(!_removeItemSuccess) exitWith {
- 5 cutText ["","PLAIN"];
- life_is_processing = false;
- };
- [] call life_fnc_p_updateMenu;
- life_is_processing = true;
- while{true} do{
- sleep 0.3;
- _cP = _cP + 0.01;
- _progress progressSetPosition _cP;
- _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
- if(_cP >= 1) exitWith {};
- };
- if(_itemFilter == "backpack") then{
- if(backpack player == "") then {
- player addBackpack _newItem;
- }else{
- hint localize "STR_CRAFT_AR_Backpack";
- life_is_processing = false;
- };
- };
- if(_itemFilter == "attachments") then {
- if(player canAdd _newItem) then {
- player addItem _newItem;
- } else {
- if(currentWeapon player == "") then {
- player addWeapon _newItem;
- } else {
- 5 cutText ["","PLAIN"];
- };
- };
- };
- //output
- diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
- if(_itemFilter == "item") then {
- _handledItem = [_newItem,1] call life_fnc_varHandle;
- //output
- diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
- [true,_handledItem,1] call life_fnc_handleInv;
- };
- if(_itemFilter == "pweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "pammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "hidden")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gang")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gangattach")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do { _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
- };
- life_is_processing = false;
- }; };
- };
- 5 cutText ["","PLAIN"];
- titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
- life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
- disableSerialization;
- //declare
- _dialog = displayNull;
- //get
- _dialog = findDisplay 666;
- //validate
- if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
- if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
- };
- //declare
- _item = "";
- //get
- _item = lbData[669,(lbCurSel 669)];
- //validate
- if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
- if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
- if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
- //output
- diag_log(format["fn_craftAction:ItemData:%1", _item]);
- _allMaterial = true;
- //declare
- _itemFilter = "item";
- //get
- _itemFilter = lbData[673,(lbCurSel 673)];
- //validate
- if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
- if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
- if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
- //output
- diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
- _matsNeed = 0;
- _config = [_itemFilter] call life_fnc_craftCfg;
- //output
- diag_log(format["fn_craftAction:_config:%1", _config]);
- {
- //output
- diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
- if(_item == _x select 0) then {
- _matsNeed = _x select 1;
- _invSize = count _matsNeed;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _str = [_matsNeed select _i] call life_fnc_varToStr;
- _matsNum = _matsNeed select _i+1;
- if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
- };
- };
- } foreach (_config);
- if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
- //declare
- _newItem = "";
- _oldItem = _matsNeed;
- _newItem = _item;
- //Some checks
- if((count _matsNeed) == 0) exitWith {};
- _weight = nil;
- if(_itemFilter == "item") then {
- _weight = ([_item] call life_fnc_itemWeight);
- };
- if (isNil '_weight') then {
- _weight = 0;
- };
- if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom";};
- if(_itemFilter == "item") then {
- //output
- diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
- _itemName = [_newItem] call life_fnc_varToStr;
- //output
- diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
- } else {
- _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
- //output
- diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
- _itemName = _itemInfo select 1;
- };
- _upp = format["Crafting %1",_itemName];
- //output
- diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
- closeDialog 0;
- //Setup our progress bar.
- 5 cutRsc ["life_progress","PLAIN"];
- _ui = uiNameSpace getVariable "life_progress";
- _progress = _ui displayCtrl 38201;
- _pgText = _ui displayCtrl 38202;
- _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
- _progress progressSetPosition 0.01;
- _cP = 0.01;
- _removeItemSuccess = true;
- _invSize = count _oldItem;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
- };
- if(!_removeItemSuccess) exitWith {
- 5 cutText ["","PLAIN"];
- life_is_processing = false;
- };
- [] call life_fnc_p_updateMenu;
- life_is_processing = true;
- while{true} do{
- sleep 0.3;
- _cP = _cP + 0.01;
- _progress progressSetPosition _cP;
- _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
- if(_cP >= 1) exitWith {};
- };
- if(_itemFilter == "backpack") then{
- if(backpack player == "") then {
- player addBackpack _newItem;
- }else{
- hint localize "STR_CRAFT_AR_Backpack";
- life_is_processing = false;
- };
- };
- if(_itemFilter == "attachments") then {
- if(player canAdd _newItem) then {
- player addItem _newItem;
- } else {
- if(currentWeapon player == "") then {
- player addWeapon _newItem;
- } else {
- 5 cutText ["","PLAIN"];
- };
- };
- };
- //output
- diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
- if(_itemFilter == "item") then {
- _handledItem = [_newItem,1] call life_fnc_varHandle;
- //output
- diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
- [true,_handledItem,1] call life_fnc_handleInv;
- };
- if(_itemFilter == "pweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "pammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "hidden")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gang")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gangattach")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do { _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
- };
- life_is_processing = false;
- }; };
- };
- 5 cutText ["","PLAIN"];
- titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
- life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
- disableSerialization;
- //declare
- _dialog = displayNull;
- //get
- _dialog = findDisplay 666;
- //validate
- if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
- if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
- };
- //declare
- _item = "";
- //get
- _item = lbData[669,(lbCurSel 669)];
- //validate
- if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
- if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
- if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
- //output
- diag_log(format["fn_craftAction:ItemData:%1", _item]);
- _allMaterial = true;
- //declare
- _itemFilter = "item";
- //get
- _itemFilter = lbData[673,(lbCurSel 673)];
- //validate
- if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
- if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
- if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
- //output
- diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
- _matsNeed = 0;
- _config = [_itemFilter] call life_fnc_craftCfg;
- //output
- diag_log(format["fn_craftAction:_config:%1", _config]);
- {
- //output
- diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
- if(_item == _x select 0) then {
- _matsNeed = _x select 1;
- _invSize = count _matsNeed;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _str = [_matsNeed select _i] call life_fnc_varToStr;
- _matsNum = _matsNeed select _i+1;
- if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
- };
- };
- } foreach (_config);
- if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
- //declare
- _newItem = "";
- _oldItem = _matsNeed;
- _newItem = _item;
- //Some checks
- if((count _matsNeed) == 0) exitWith {};
- _weight = nil;
- if(_itemFilter == "item") then {
- _weight = ([_item] call life_fnc_itemWeight);
- };
- if (isNil '_weight') then {
- _weight = 0;
- };
- if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom";};
- if(_itemFilter == "item") then {
- //output
- diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
- _itemName = [_newItem] call life_fnc_varToStr;
- //output
- diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
- } else {
- _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
- //output
- diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
- _itemName = _itemInfo select 1;
- };
- _upp = format["Crafting %1",_itemName];
- //output
- diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
- closeDialog 0;
- //Setup our progress bar.
- 5 cutRsc ["life_progress","PLAIN"];
- _ui = uiNameSpace getVariable "life_progress";
- _progress = _ui displayCtrl 38201;
- _pgText = _ui displayCtrl 38202;
- _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
- _progress progressSetPosition 0.01;
- _cP = 0.01;
- _removeItemSuccess = true;
- _invSize = count _oldItem;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
- };
- if(!_removeItemSuccess) exitWith {
- 5 cutText ["","PLAIN"];
- life_is_processing = false;
- };
- [] call life_fnc_p_updateMenu;
- life_is_processing = true;
- while{true} do{
- sleep 0.3;
- _cP = _cP + 0.01;
- _progress progressSetPosition _cP;
- _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
- if(_cP >= 1) exitWith {};
- };
- if(_itemFilter == "backpack") then{
- if(backpack player == "") then {
- player addBackpack _newItem;
- }else{
- hint localize "STR_CRAFT_AR_Backpack";
- life_is_processing = false;
- };
- };
- if(_itemFilter == "attachments") then {
- if(player canAdd _newItem) then {
- player addItem _newItem;
- } else {
- if(currentWeapon player == "") then {
- player addWeapon _newItem;
- } else {
- 5 cutText ["","PLAIN"];
- };
- };
- };
- //output
- diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
- if(_itemFilter == "item") then {
- _handledItem = [_newItem,1] call life_fnc_varHandle;
- //output
- diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
- [true,_handledItem,1] call life_fnc_handleInv;
- };
- if(_itemFilter == "pweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rweapon")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "rammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "pammunition")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "hidden")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gang")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- if(_itemFilter == "gangattach")
- then{
- if(player canAdd _newItem)
- then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")
- then{ player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do { _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
- };
- life_is_processing = false;
- }; };
- };
- 5 cutText ["","PLAIN"];
- titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
- life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
- disableSerialization;
- //declare
- _dialog = displayNull;
- //get
- _dialog = findDisplay 666;
- //validate
- if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
- if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
- };
- //declare
- _item = "";
- //get
- _item = lbData[669,(lbCurSel 669)];
- //validate
- if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
- if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
- if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
- //output
- diag_log(format["fn_craftAction:ItemData:%1", _item]);
- _allMaterial = true;
- //declare
- _itemFilter = "item";
- //get
- _itemFilter = lbData[673,(lbCurSel 673)];
- //validate
- if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
- if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
- if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
- //output
- diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
- _matsNeed = 0;
- _config = [_itemFilter] call life_fnc_craftCfg;
- //output
- diag_log(format["fn_craftAction:_config:%1", _config]);
- {
- //output
- diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
- if(_item == _x select 0) then {
- _matsNeed = _x select 1;
- _invSize = count _matsNeed;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _str = [_matsNeed select _i] call life_fnc_varToStr;
- _matsNum = _matsNeed select _i+1;
- if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
- };
- };
- } foreach (_config);
- if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
- //declare
- _newItem = "";
- _oldItem = _matsNeed;
- _newItem = _item;
- //Some checks
- if((count _matsNeed) == 0) exitWith {};
- _weight = nil;
- if(_itemFilter == "item") then {
- _weight = ([_item] call life_fnc_itemWeight);
- };
- if (isNil '_weight') then {
- _weight = 0;
- };
- if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; };
- if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom";};
- if(_itemFilter == "item") then {
- //output
- diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
- _itemName = [_newItem] call life_fnc_varToStr;
- //output
- diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
- } else {
- _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
- //output
- diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
- _itemName = _itemInfo select 1;
- };
- _upp = format["Crafting %1",_itemName];
- //output
- diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
- closeDialog 0;
- //Setup our progress bar.
- 5 cutRsc ["life_progress","PLAIN"];
- _ui = uiNameSpace getVariable "life_progress";
- _progress = _ui displayCtrl 38201;
- _pgText = _ui displayCtrl 38202;
- _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
- _progress progressSetPosition 0.01;
- _cP = 0.01;
- _removeItemSuccess = true;
- _invSize = count _oldItem;
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
- };
- if(!_removeItemSuccess) exitWith {
- 5 cutText ["","PLAIN"];
- life_is_processing = false;
- };
- [] call life_fnc_p_updateMenu;
- life_is_processing = true;
- while{true} do{
- sleep 0.3;
- _cP = _cP + 0.01;
- _progress progressSetPosition _cP;
- _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
- if(_cP >= 1) exitWith {};
- };
- if(_itemFilter == "backpack") then{
- if(backpack player == "") then {
- player addBackpack _newItem;
- }else{
- hint localize "STR_CRAFT_AR_Backpack";
- life_is_processing = false;
- };
- };
- if(_itemFilter == "attachments") then {
- if(player canAdd _newItem) then {
- player addItem _newItem;
- } else {
- if(currentWeapon player == "") then {
- player addWeapon _newItem;
- } else {
- 5 cutText ["","PLAIN"];
- };
- };
- };
- //output
- diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
- if(_itemFilter == "item") then {
- _handledItem = [_newItem,1] call life_fnc_varHandle;
- //output
- diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
- [true,_handledItem,1] call life_fnc_handleInv;
- };
- if(_itemFilter == "pweapon") then {
- if(player canAdd _newItem) then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "") then {
- player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- };
- };
- };
- if(_itemFilter == "rweapon")then{
- if(player canAdd _newItem)then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")then{
- player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- };
- };
- };
- if(_itemFilter == "rammunition")then{
- if(player canAdd _newItem)then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")then{
- player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- };
- };
- };
- if(_itemFilter == "pammunition")then{
- if(player canAdd _newItem)then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")then{
- player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- };
- };
- };
- if(_itemFilter == "hidden")then{
- if(player canAdd _newItem)then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")then{
- player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- };
- };
- };
- if(_itemFilter == "gang")then{
- if(player canAdd _newItem)then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")then{
- player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- };
- };
- };
- if(_itemFilter == "gangattach")then{
- if(player canAdd _newItem)then{
- player addItem _newItem;
- } else {
- if(currentWeapon player == "")then{
- player addWeapon _newItem;
- }else{
- 5 cutText ["","PLAIN"];
- };
- };
- };
- for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
- _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
- [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
- };
- life_is_processing = false;
- 5 cutText ["","PLAIN"];
- titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
- life_is_processing = false;
Advertisement
Add Comment
Please, Sign In to add comment