player2_dz

Untitled

May 16th, 2016
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 125.63 KB | None | 0 0
  1. private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
  2. disableSerialization;
  3.  
  4. //declare
  5. _dialog = displayNull;
  6.  
  7. //get
  8. _dialog = findDisplay 666;
  9.  
  10. //validate
  11. if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
  12. if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
  13. };
  14.  
  15. //declare
  16. _item = "";
  17.  
  18. //get
  19. _item = lbData[669,(lbCurSel 669)];
  20.  
  21. //validate
  22. if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
  23. if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
  24. if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
  25.  
  26. //output
  27. diag_log(format["fn_craftAction:ItemData:%1", _item]);
  28.  
  29. _allMaterial = true;
  30.  
  31. //declare
  32. _itemFilter = "item";
  33.  
  34. //get
  35. _itemFilter = lbData[673,(lbCurSel 673)];
  36.  
  37. //validate
  38. if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
  39. if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
  40. if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
  41.  
  42.  
  43. //output
  44. diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
  45.  
  46.  
  47. _matsNeed = 0;
  48. _config = [_itemFilter] call life_fnc_craftCfg;
  49.  
  50. //output
  51. diag_log(format["fn_craftAction:_config:%1", _config]);
  52.  
  53. {
  54.     //output
  55.     diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
  56.  
  57.  
  58.     if(_item == _x select 0) then {
  59.          _matsNeed = _x select 1;
  60.         _invSize = count _matsNeed;
  61.         for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
  62.                 _str = [_matsNeed select _i] call life_fnc_varToStr;
  63.                 _matsNum = _matsNeed select _i+1;  
  64.                 if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
  65.         };
  66.     };
  67. } foreach (_config);
  68.  
  69. if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
  70.  
  71. //declare
  72. _newItem = "";
  73.  
  74. _oldItem = _matsNeed;
  75. _newItem = _item;
  76.  
  77. //Some checks
  78. if((count _matsNeed) == 0) exitWith {};
  79.  
  80. _weight = nil;
  81. if(_itemFilter == "item") then {
  82.     _weight = ([_item] call life_fnc_itemWeight);
  83. };
  84. if (isNil '_weight') then {
  85.     _weight = 0;
  86. };
  87.  
  88. if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith  {   hint localize "STR_NOTF_NoRoom"; };
  89. if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith    {  hint localize "STR_NOTF_NoRoom"; };
  90. if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";  };
  91. if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  92. if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  93. if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  94. if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  95. if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  96. if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";};
  97.  
  98. if(_itemFilter == "item") then    {
  99.  
  100.     //output
  101.     diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
  102.  
  103.    _itemName = [_newItem] call life_fnc_varToStr;
  104.  
  105.    //output
  106.     diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
  107.  
  108. } else        {  
  109.     _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
  110.  
  111.    //output
  112.     diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
  113.  
  114.     _itemName = _itemInfo select 1;
  115. };
  116.  
  117.  
  118. _upp = format["Crafting %1",_itemName];
  119.  
  120. //output
  121. diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
  122.  
  123. closeDialog 0;
  124.  
  125. //Setup our progress bar.
  126.  
  127. 5 cutRsc ["life_progress","PLAIN"];
  128. _ui = uiNameSpace getVariable "life_progress";
  129. _progress = _ui displayCtrl 38201;
  130. _pgText = _ui displayCtrl 38202;
  131. _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
  132. _progress progressSetPosition 0.01;
  133. _cP = 0.01;
  134. _removeItemSuccess = true;
  135. _invSize = count _oldItem;
  136.  
  137. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do  {
  138.    _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  139.     if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
  140. };
  141.  
  142. if(!_removeItemSuccess) exitWith {
  143.     5 cutText ["","PLAIN"];
  144.     life_is_processing = false;
  145. };
  146.  
  147. [] call life_fnc_p_updateMenu;
  148.  
  149. life_is_processing = true;
  150.  
  151.  while{true} do{
  152.     sleep  0.3;
  153.     _cP = _cP + 0.01;
  154.     _progress progressSetPosition _cP;
  155.     _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
  156.     if(_cP >= 1) exitWith {};
  157. };
  158.  
  159. if(_itemFilter == "backpack") then{
  160.     if(backpack player == "") then {    
  161.         player addBackpack _newItem;
  162.     }else{
  163.           hint localize "STR_CRAFT_AR_Backpack";
  164.         life_is_processing = false;
  165.     };
  166. };
  167.  
  168. if(_itemFilter == "attachments") then {
  169.     if(player canAdd _newItem) then {  
  170.         player addItem _newItem;
  171.     } else {      
  172.         if(currentWeapon player == "") then {
  173.             player addWeapon _newItem;
  174.         } else {
  175.             5 cutText ["","PLAIN"];
  176.         };
  177.     };
  178. };
  179.  
  180.  
  181. //output
  182. diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
  183.  
  184. if(_itemFilter == "item") then {
  185.     _handledItem = [_newItem,1]  call life_fnc_varHandle;
  186.  
  187.     //output
  188.     diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
  189.  
  190.     [true,_handledItem,1] call life_fnc_handleInv;
  191. };
  192.  
  193.  
  194. if(_itemFilter == "pweapon")
  195. then{  
  196. if(player canAdd _newItem)
  197. then{  
  198. player addItem _newItem;
  199. } else {      
  200. if(currentWeapon player == "")
  201. then{   player addWeapon _newItem;
  202. }else{    
  203. 5 cutText ["","PLAIN"];      
  204.  
  205. if(_itemFilter == "rweapon")
  206. then{  
  207. if(player canAdd _newItem)
  208. then{  
  209. player addItem _newItem;
  210. } else {      
  211. if(currentWeapon player == "")
  212. then{   player addWeapon _newItem;
  213. }else{    
  214. 5 cutText ["","PLAIN"];
  215.  
  216. if(_itemFilter == "rammunition")
  217. then{  
  218. if(player canAdd _newItem)
  219. then{  
  220. player addItem _newItem;
  221. } else {      
  222. if(currentWeapon player == "")
  223. then{   player addWeapon _newItem;
  224. }else{    
  225. 5 cutText ["","PLAIN"];
  226.  
  227. if(_itemFilter == "pammunition")
  228. then{  
  229. if(player canAdd _newItem)
  230. then{  
  231. player addItem _newItem;
  232. } else {      
  233. if(currentWeapon player == "")
  234. then{   player addWeapon _newItem;
  235. }else{    
  236. 5 cutText ["","PLAIN"];      
  237.  
  238. if(_itemFilter == "hidden")
  239. then{  
  240. if(player canAdd _newItem)
  241. then{  
  242. player addItem _newItem;
  243. } else {      
  244. if(currentWeapon player == "")
  245. then{   player addWeapon _newItem;
  246. }else{    
  247. 5 cutText ["","PLAIN"];
  248.  
  249. if(_itemFilter == "gang")
  250. then{  
  251. if(player canAdd _newItem)
  252. then{  
  253. player addItem _newItem;
  254. } else {      
  255. if(currentWeapon player == "")
  256. then{   player addWeapon _newItem;
  257. }else{    
  258. 5 cutText ["","PLAIN"];
  259.  
  260. if(_itemFilter == "gangattach")
  261. then{  
  262. if(player canAdd _newItem)
  263. then{  
  264. player addItem _newItem;
  265. } else {      
  266. if(currentWeapon player == "")
  267. then{   player addWeapon _newItem;
  268. }else{    
  269. 5 cutText ["","PLAIN"];
  270.  
  271.  
  272.  
  273.  
  274. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {             _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  275. [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
  276. };        
  277. life_is_processing = false;    
  278. };  };
  279. };
  280. 5 cutText ["","PLAIN"];
  281. titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
  282. life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
  283. disableSerialization;
  284.  
  285. //declare
  286. _dialog = displayNull;
  287.  
  288. //get
  289. _dialog = findDisplay 666;
  290.  
  291. //validate
  292. if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
  293. if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
  294. };
  295.  
  296. //declare
  297. _item = "";
  298.  
  299. //get
  300. _item = lbData[669,(lbCurSel 669)];
  301.  
  302. //validate
  303. if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
  304. if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
  305. if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
  306.  
  307. //output
  308. diag_log(format["fn_craftAction:ItemData:%1", _item]);
  309.  
  310. _allMaterial = true;
  311.  
  312. //declare
  313. _itemFilter = "item";
  314.  
  315. //get
  316. _itemFilter = lbData[673,(lbCurSel 673)];
  317.  
  318. //validate
  319. if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
  320. if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
  321. if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
  322.  
  323.  
  324. //output
  325. diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
  326.  
  327.  
  328. _matsNeed = 0;
  329. _config = [_itemFilter] call life_fnc_craftCfg;
  330.  
  331. //output
  332. diag_log(format["fn_craftAction:_config:%1", _config]);
  333.  
  334. {
  335.     //output
  336.     diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
  337.  
  338.  
  339.     if(_item == _x select 0) then {
  340.          _matsNeed = _x select 1;
  341.         _invSize = count _matsNeed;
  342.         for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
  343.                 _str = [_matsNeed select _i] call life_fnc_varToStr;
  344.                 _matsNum = _matsNeed select _i+1;  
  345.                 if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
  346.         };
  347.     };
  348. } foreach (_config);
  349.  
  350. if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
  351.  
  352. //declare
  353. _newItem = "";
  354.  
  355. _oldItem = _matsNeed;
  356. _newItem = _item;
  357.  
  358. //Some checks
  359. if((count _matsNeed) == 0) exitWith {};
  360.  
  361. _weight = nil;
  362. if(_itemFilter == "item") then {
  363.     _weight = ([_item] call life_fnc_itemWeight);
  364. };
  365. if (isNil '_weight') then {
  366.     _weight = 0;
  367. };
  368.  
  369. if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith  {   hint localize "STR_NOTF_NoRoom"; };
  370. if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith    {  hint localize "STR_NOTF_NoRoom"; };
  371. if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";  };
  372. if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  373. if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  374. if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  375. if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  376. if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  377. if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";};
  378.  
  379. if(_itemFilter == "item") then    {
  380.  
  381.     //output
  382.     diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
  383.  
  384.    _itemName = [_newItem] call life_fnc_varToStr;
  385.  
  386.    //output
  387.     diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
  388.  
  389. } else        {  
  390.     _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
  391.  
  392.    //output
  393.     diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
  394.  
  395.     _itemName = _itemInfo select 1;
  396. };
  397.  
  398.  
  399. _upp = format["Crafting %1",_itemName];
  400.  
  401. //output
  402. diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
  403.  
  404. closeDialog 0;
  405.  
  406. //Setup our progress bar.
  407.  
  408. 5 cutRsc ["life_progress","PLAIN"];
  409. _ui = uiNameSpace getVariable "life_progress";
  410. _progress = _ui displayCtrl 38201;
  411. _pgText = _ui displayCtrl 38202;
  412. _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
  413. _progress progressSetPosition 0.01;
  414. _cP = 0.01;
  415. _removeItemSuccess = true;
  416. _invSize = count _oldItem;
  417.  
  418. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do  {
  419.    _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  420.     if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
  421. };
  422.  
  423. if(!_removeItemSuccess) exitWith {
  424.     5 cutText ["","PLAIN"];
  425.     life_is_processing = false;
  426. };
  427.  
  428. [] call life_fnc_p_updateMenu;
  429.  
  430. life_is_processing = true;
  431.  
  432.  while{true} do{
  433.     sleep  0.3;
  434.     _cP = _cP + 0.01;
  435.     _progress progressSetPosition _cP;
  436.     _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
  437.     if(_cP >= 1) exitWith {};
  438. };
  439.  
  440. if(_itemFilter == "backpack") then{
  441.     if(backpack player == "") then {    
  442.         player addBackpack _newItem;
  443.     }else{
  444.           hint localize "STR_CRAFT_AR_Backpack";
  445.         life_is_processing = false;
  446.     };
  447. };
  448.  
  449. if(_itemFilter == "attachments") then {
  450.     if(player canAdd _newItem) then {  
  451.         player addItem _newItem;
  452.     } else {      
  453.         if(currentWeapon player == "") then {
  454.             player addWeapon _newItem;
  455.         } else {
  456.             5 cutText ["","PLAIN"];
  457.         };
  458.     };
  459. };
  460.  
  461.  
  462. //output
  463. diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
  464.  
  465. if(_itemFilter == "item") then {
  466.     _handledItem = [_newItem,1]  call life_fnc_varHandle;
  467.  
  468.     //output
  469.     diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
  470.  
  471.     [true,_handledItem,1] call life_fnc_handleInv;
  472. };
  473.  
  474.  
  475. if(_itemFilter == "pweapon")
  476. then{  
  477. if(player canAdd _newItem)
  478. then{  
  479. player addItem _newItem;
  480. } else {      
  481. if(currentWeapon player == "")
  482. then{   player addWeapon _newItem;
  483. }else{    
  484. 5 cutText ["","PLAIN"];      
  485.  
  486. if(_itemFilter == "rweapon")
  487. then{  
  488. if(player canAdd _newItem)
  489. then{  
  490. player addItem _newItem;
  491. } else {      
  492. if(currentWeapon player == "")
  493. then{   player addWeapon _newItem;
  494. }else{    
  495. 5 cutText ["","PLAIN"];
  496.  
  497. if(_itemFilter == "rammunition")
  498. then{  
  499. if(player canAdd _newItem)
  500. then{  
  501. player addItem _newItem;
  502. } else {      
  503. if(currentWeapon player == "")
  504. then{   player addWeapon _newItem;
  505. }else{    
  506. 5 cutText ["","PLAIN"];
  507.  
  508. if(_itemFilter == "pammunition")
  509. then{  
  510. if(player canAdd _newItem)
  511. then{  
  512. player addItem _newItem;
  513. } else {      
  514. if(currentWeapon player == "")
  515. then{   player addWeapon _newItem;
  516. }else{    
  517. 5 cutText ["","PLAIN"];      
  518.  
  519. if(_itemFilter == "hidden")
  520. then{  
  521. if(player canAdd _newItem)
  522. then{  
  523. player addItem _newItem;
  524. } else {      
  525. if(currentWeapon player == "")
  526. then{   player addWeapon _newItem;
  527. }else{    
  528. 5 cutText ["","PLAIN"];
  529.  
  530. if(_itemFilter == "gang")
  531. then{  
  532. if(player canAdd _newItem)
  533. then{  
  534. player addItem _newItem;
  535. } else {      
  536. if(currentWeapon player == "")
  537. then{   player addWeapon _newItem;
  538. }else{    
  539. 5 cutText ["","PLAIN"];
  540.  
  541. if(_itemFilter == "gangattach")
  542. then{  
  543. if(player canAdd _newItem)
  544. then{  
  545. player addItem _newItem;
  546. } else {      
  547. if(currentWeapon player == "")
  548. then{   player addWeapon _newItem;
  549. }else{    
  550. 5 cutText ["","PLAIN"];
  551.  
  552.  
  553.  
  554.  
  555. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {             _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  556. [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
  557. };        
  558. life_is_processing = false;    
  559. };  };
  560. };
  561. 5 cutText ["","PLAIN"];
  562. titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
  563. life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
  564. disableSerialization;
  565.  
  566. //declare
  567. _dialog = displayNull;
  568.  
  569. //get
  570. _dialog = findDisplay 666;
  571.  
  572. //validate
  573. if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
  574. if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
  575. };
  576.  
  577. //declare
  578. _item = "";
  579.  
  580. //get
  581. _item = lbData[669,(lbCurSel 669)];
  582.  
  583. //validate
  584. if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
  585. if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
  586. if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
  587.  
  588. //output
  589. diag_log(format["fn_craftAction:ItemData:%1", _item]);
  590.  
  591. _allMaterial = true;
  592.  
  593. //declare
  594. _itemFilter = "item";
  595.  
  596. //get
  597. _itemFilter = lbData[673,(lbCurSel 673)];
  598.  
  599. //validate
  600. if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
  601. if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
  602. if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
  603.  
  604.  
  605. //output
  606. diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
  607.  
  608.  
  609. _matsNeed = 0;
  610. _config = [_itemFilter] call life_fnc_craftCfg;
  611.  
  612. //output
  613. diag_log(format["fn_craftAction:_config:%1", _config]);
  614.  
  615. {
  616.     //output
  617.     diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
  618.  
  619.  
  620.     if(_item == _x select 0) then {
  621.          _matsNeed = _x select 1;
  622.         _invSize = count _matsNeed;
  623.         for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
  624.                 _str = [_matsNeed select _i] call life_fnc_varToStr;
  625.                 _matsNum = _matsNeed select _i+1;  
  626.                 if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
  627.         };
  628.     };
  629. } foreach (_config);
  630.  
  631. if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
  632.  
  633. //declare
  634. _newItem = "";
  635.  
  636. _oldItem = _matsNeed;
  637. _newItem = _item;
  638.  
  639. //Some checks
  640. if((count _matsNeed) == 0) exitWith {};
  641.  
  642. _weight = nil;
  643. if(_itemFilter == "item") then {
  644.     _weight = ([_item] call life_fnc_itemWeight);
  645. };
  646. if (isNil '_weight') then {
  647.     _weight = 0;
  648. };
  649.  
  650. if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith  {   hint localize "STR_NOTF_NoRoom"; };
  651. if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith    {  hint localize "STR_NOTF_NoRoom"; };
  652. if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";  };
  653. if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  654. if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  655. if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  656. if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  657. if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  658. if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";};
  659.  
  660. if(_itemFilter == "item") then    {
  661.  
  662.     //output
  663.     diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
  664.  
  665.    _itemName = [_newItem] call life_fnc_varToStr;
  666.  
  667.    //output
  668.     diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
  669.  
  670. } else        {  
  671.     _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
  672.  
  673.    //output
  674.     diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
  675.  
  676.     _itemName = _itemInfo select 1;
  677. };
  678.  
  679.  
  680. _upp = format["Crafting %1",_itemName];
  681.  
  682. //output
  683. diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
  684.  
  685. closeDialog 0;
  686.  
  687. //Setup our progress bar.
  688.  
  689. 5 cutRsc ["life_progress","PLAIN"];
  690. _ui = uiNameSpace getVariable "life_progress";
  691. _progress = _ui displayCtrl 38201;
  692. _pgText = _ui displayCtrl 38202;
  693. _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
  694. _progress progressSetPosition 0.01;
  695. _cP = 0.01;
  696. _removeItemSuccess = true;
  697. _invSize = count _oldItem;
  698.  
  699. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do  {
  700.    _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  701.     if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
  702. };
  703.  
  704. if(!_removeItemSuccess) exitWith {
  705.     5 cutText ["","PLAIN"];
  706.     life_is_processing = false;
  707. };
  708.  
  709. [] call life_fnc_p_updateMenu;
  710.  
  711. life_is_processing = true;
  712.  
  713.  while{true} do{
  714.     sleep  0.3;
  715.     _cP = _cP + 0.01;
  716.     _progress progressSetPosition _cP;
  717.     _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
  718.     if(_cP >= 1) exitWith {};
  719. };
  720.  
  721. if(_itemFilter == "backpack") then{
  722.     if(backpack player == "") then {    
  723.         player addBackpack _newItem;
  724.     }else{
  725.           hint localize "STR_CRAFT_AR_Backpack";
  726.         life_is_processing = false;
  727.     };
  728. };
  729.  
  730. if(_itemFilter == "attachments") then {
  731.     if(player canAdd _newItem) then {  
  732.         player addItem _newItem;
  733.     } else {      
  734.         if(currentWeapon player == "") then {
  735.             player addWeapon _newItem;
  736.         } else {
  737.             5 cutText ["","PLAIN"];
  738.         };
  739.     };
  740. };
  741.  
  742.  
  743. //output
  744. diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
  745.  
  746. if(_itemFilter == "item") then {
  747.     _handledItem = [_newItem,1]  call life_fnc_varHandle;
  748.  
  749.     //output
  750.     diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
  751.  
  752.     [true,_handledItem,1] call life_fnc_handleInv;
  753. };
  754.  
  755.  
  756. if(_itemFilter == "pweapon")
  757. then{  
  758. if(player canAdd _newItem)
  759. then{  
  760. player addItem _newItem;
  761. } else {      
  762. if(currentWeapon player == "")
  763. then{   player addWeapon _newItem;
  764. }else{    
  765. 5 cutText ["","PLAIN"];      
  766.  
  767. if(_itemFilter == "rweapon")
  768. then{  
  769. if(player canAdd _newItem)
  770. then{  
  771. player addItem _newItem;
  772. } else {      
  773. if(currentWeapon player == "")
  774. then{   player addWeapon _newItem;
  775. }else{    
  776. 5 cutText ["","PLAIN"];
  777.  
  778. if(_itemFilter == "rammunition")
  779. then{  
  780. if(player canAdd _newItem)
  781. then{  
  782. player addItem _newItem;
  783. } else {      
  784. if(currentWeapon player == "")
  785. then{   player addWeapon _newItem;
  786. }else{    
  787. 5 cutText ["","PLAIN"];
  788.  
  789. if(_itemFilter == "pammunition")
  790. then{  
  791. if(player canAdd _newItem)
  792. then{  
  793. player addItem _newItem;
  794. } else {      
  795. if(currentWeapon player == "")
  796. then{   player addWeapon _newItem;
  797. }else{    
  798. 5 cutText ["","PLAIN"];      
  799.  
  800. if(_itemFilter == "hidden")
  801. then{  
  802. if(player canAdd _newItem)
  803. then{  
  804. player addItem _newItem;
  805. } else {      
  806. if(currentWeapon player == "")
  807. then{   player addWeapon _newItem;
  808. }else{    
  809. 5 cutText ["","PLAIN"];
  810.  
  811. if(_itemFilter == "gang")
  812. then{  
  813. if(player canAdd _newItem)
  814. then{  
  815. player addItem _newItem;
  816. } else {      
  817. if(currentWeapon player == "")
  818. then{   player addWeapon _newItem;
  819. }else{    
  820. 5 cutText ["","PLAIN"];
  821.  
  822. if(_itemFilter == "gangattach")
  823. then{  
  824. if(player canAdd _newItem)
  825. then{  
  826. player addItem _newItem;
  827. } else {      
  828. if(currentWeapon player == "")
  829. then{   player addWeapon _newItem;
  830. }else{    
  831. 5 cutText ["","PLAIN"];
  832.  
  833.  
  834.  
  835.  
  836. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {             _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  837. [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
  838. };        
  839. life_is_processing = false;    
  840. };  };
  841. };
  842. 5 cutText ["","PLAIN"];
  843. titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
  844. life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
  845. disableSerialization;
  846.  
  847. //declare
  848. _dialog = displayNull;
  849.  
  850. //get
  851. _dialog = findDisplay 666;
  852.  
  853. //validate
  854. if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
  855. if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
  856. };
  857.  
  858. //declare
  859. _item = "";
  860.  
  861. //get
  862. _item = lbData[669,(lbCurSel 669)];
  863.  
  864. //validate
  865. if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
  866. if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
  867. if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
  868.  
  869. //output
  870. diag_log(format["fn_craftAction:ItemData:%1", _item]);
  871.  
  872. _allMaterial = true;
  873.  
  874. //declare
  875. _itemFilter = "item";
  876.  
  877. //get
  878. _itemFilter = lbData[673,(lbCurSel 673)];
  879.  
  880. //validate
  881. if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
  882. if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
  883. if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
  884.  
  885.  
  886. //output
  887. diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
  888.  
  889.  
  890. _matsNeed = 0;
  891. _config = [_itemFilter] call life_fnc_craftCfg;
  892.  
  893. //output
  894. diag_log(format["fn_craftAction:_config:%1", _config]);
  895.  
  896. {
  897.     //output
  898.     diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
  899.  
  900.  
  901.     if(_item == _x select 0) then {
  902.          _matsNeed = _x select 1;
  903.         _invSize = count _matsNeed;
  904.         for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
  905.                 _str = [_matsNeed select _i] call life_fnc_varToStr;
  906.                 _matsNum = _matsNeed select _i+1;  
  907.                 if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
  908.         };
  909.     };
  910. } foreach (_config);
  911.  
  912. if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
  913.  
  914. //declare
  915. _newItem = "";
  916.  
  917. _oldItem = _matsNeed;
  918. _newItem = _item;
  919.  
  920. //Some checks
  921. if((count _matsNeed) == 0) exitWith {};
  922.  
  923. _weight = nil;
  924. if(_itemFilter == "item") then {
  925.     _weight = ([_item] call life_fnc_itemWeight);
  926. };
  927. if (isNil '_weight') then {
  928.     _weight = 0;
  929. };
  930.  
  931. if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith  {   hint localize "STR_NOTF_NoRoom"; };
  932. if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith    {  hint localize "STR_NOTF_NoRoom"; };
  933. if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";  };
  934. if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  935. if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  936. if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  937. if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  938. if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  939. if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";};
  940.  
  941. if(_itemFilter == "item") then    {
  942.  
  943.     //output
  944.     diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
  945.  
  946.    _itemName = [_newItem] call life_fnc_varToStr;
  947.  
  948.    //output
  949.     diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
  950.  
  951. } else        {  
  952.     _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
  953.  
  954.    //output
  955.     diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
  956.  
  957.     _itemName = _itemInfo select 1;
  958. };
  959.  
  960.  
  961. _upp = format["Crafting %1",_itemName];
  962.  
  963. //output
  964. diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
  965.  
  966. closeDialog 0;
  967.  
  968. //Setup our progress bar.
  969.  
  970. 5 cutRsc ["life_progress","PLAIN"];
  971. _ui = uiNameSpace getVariable "life_progress";
  972. _progress = _ui displayCtrl 38201;
  973. _pgText = _ui displayCtrl 38202;
  974. _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
  975. _progress progressSetPosition 0.01;
  976. _cP = 0.01;
  977. _removeItemSuccess = true;
  978. _invSize = count _oldItem;
  979.  
  980. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do  {
  981.    _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  982.     if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
  983. };
  984.  
  985. if(!_removeItemSuccess) exitWith {
  986.     5 cutText ["","PLAIN"];
  987.     life_is_processing = false;
  988. };
  989.  
  990. [] call life_fnc_p_updateMenu;
  991.  
  992. life_is_processing = true;
  993.  
  994.  while{true} do{
  995.     sleep  0.3;
  996.     _cP = _cP + 0.01;
  997.     _progress progressSetPosition _cP;
  998.     _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
  999.     if(_cP >= 1) exitWith {};
  1000. };
  1001.  
  1002. if(_itemFilter == "backpack") then{
  1003.     if(backpack player == "") then {    
  1004.         player addBackpack _newItem;
  1005.     }else{
  1006.           hint localize "STR_CRAFT_AR_Backpack";
  1007.         life_is_processing = false;
  1008.     };
  1009. };
  1010.  
  1011. if(_itemFilter == "attachments") then {
  1012.     if(player canAdd _newItem) then {  
  1013.         player addItem _newItem;
  1014.     } else {      
  1015.         if(currentWeapon player == "") then {
  1016.             player addWeapon _newItem;
  1017.         } else {
  1018.             5 cutText ["","PLAIN"];
  1019.         };
  1020.     };
  1021. };
  1022.  
  1023.  
  1024. //output
  1025. diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
  1026.  
  1027. if(_itemFilter == "item") then {
  1028.     _handledItem = [_newItem,1]  call life_fnc_varHandle;
  1029.  
  1030.     //output
  1031.     diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
  1032.  
  1033.     [true,_handledItem,1] call life_fnc_handleInv;
  1034. };
  1035.  
  1036.  
  1037. if(_itemFilter == "pweapon")
  1038. then{  
  1039. if(player canAdd _newItem)
  1040. then{  
  1041. player addItem _newItem;
  1042. } else {      
  1043. if(currentWeapon player == "")
  1044. then{   player addWeapon _newItem;
  1045. }else{    
  1046. 5 cutText ["","PLAIN"];      
  1047.  
  1048. if(_itemFilter == "rweapon")
  1049. then{  
  1050. if(player canAdd _newItem)
  1051. then{  
  1052. player addItem _newItem;
  1053. } else {      
  1054. if(currentWeapon player == "")
  1055. then{   player addWeapon _newItem;
  1056. }else{    
  1057. 5 cutText ["","PLAIN"];
  1058.  
  1059. if(_itemFilter == "rammunition")
  1060. then{  
  1061. if(player canAdd _newItem)
  1062. then{  
  1063. player addItem _newItem;
  1064. } else {      
  1065. if(currentWeapon player == "")
  1066. then{   player addWeapon _newItem;
  1067. }else{    
  1068. 5 cutText ["","PLAIN"];
  1069.  
  1070. if(_itemFilter == "pammunition")
  1071. then{  
  1072. if(player canAdd _newItem)
  1073. then{  
  1074. player addItem _newItem;
  1075. } else {      
  1076. if(currentWeapon player == "")
  1077. then{   player addWeapon _newItem;
  1078. }else{    
  1079. 5 cutText ["","PLAIN"];      
  1080.  
  1081. if(_itemFilter == "hidden")
  1082. then{  
  1083. if(player canAdd _newItem)
  1084. then{  
  1085. player addItem _newItem;
  1086. } else {      
  1087. if(currentWeapon player == "")
  1088. then{   player addWeapon _newItem;
  1089. }else{    
  1090. 5 cutText ["","PLAIN"];
  1091.  
  1092. if(_itemFilter == "gang")
  1093. then{  
  1094. if(player canAdd _newItem)
  1095. then{  
  1096. player addItem _newItem;
  1097. } else {      
  1098. if(currentWeapon player == "")
  1099. then{   player addWeapon _newItem;
  1100. }else{    
  1101. 5 cutText ["","PLAIN"];
  1102.  
  1103. if(_itemFilter == "gangattach")
  1104. then{  
  1105. if(player canAdd _newItem)
  1106. then{  
  1107. player addItem _newItem;
  1108. } else {      
  1109. if(currentWeapon player == "")
  1110. then{   player addWeapon _newItem;
  1111. }else{    
  1112. 5 cutText ["","PLAIN"];
  1113.  
  1114.  
  1115.  
  1116.  
  1117. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {             _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  1118. [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
  1119. };        
  1120. life_is_processing = false;    
  1121. };  };
  1122. };
  1123. 5 cutText ["","PLAIN"];
  1124. titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
  1125. life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
  1126. disableSerialization;
  1127.  
  1128. //declare
  1129. _dialog = displayNull;
  1130.  
  1131. //get
  1132. _dialog = findDisplay 666;
  1133.  
  1134. //validate
  1135. if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
  1136. if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
  1137. };
  1138.  
  1139. //declare
  1140. _item = "";
  1141.  
  1142. //get
  1143. _item = lbData[669,(lbCurSel 669)];
  1144.  
  1145. //validate
  1146. if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
  1147. if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
  1148. if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
  1149.  
  1150. //output
  1151. diag_log(format["fn_craftAction:ItemData:%1", _item]);
  1152.  
  1153. _allMaterial = true;
  1154.  
  1155. //declare
  1156. _itemFilter = "item";
  1157.  
  1158. //get
  1159. _itemFilter = lbData[673,(lbCurSel 673)];
  1160.  
  1161. //validate
  1162. if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
  1163. if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
  1164. if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
  1165.  
  1166.  
  1167. //output
  1168. diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
  1169.  
  1170.  
  1171. _matsNeed = 0;
  1172. _config = [_itemFilter] call life_fnc_craftCfg;
  1173.  
  1174. //output
  1175. diag_log(format["fn_craftAction:_config:%1", _config]);
  1176.  
  1177. {
  1178.     //output
  1179.     diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
  1180.  
  1181.  
  1182.     if(_item == _x select 0) then {
  1183.          _matsNeed = _x select 1;
  1184.         _invSize = count _matsNeed;
  1185.         for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
  1186.                 _str = [_matsNeed select _i] call life_fnc_varToStr;
  1187.                 _matsNum = _matsNeed select _i+1;  
  1188.                 if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
  1189.         };
  1190.     };
  1191. } foreach (_config);
  1192.  
  1193. if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
  1194.  
  1195. //declare
  1196. _newItem = "";
  1197.  
  1198. _oldItem = _matsNeed;
  1199. _newItem = _item;
  1200.  
  1201. //Some checks
  1202. if((count _matsNeed) == 0) exitWith {};
  1203.  
  1204. _weight = nil;
  1205. if(_itemFilter == "item") then {
  1206.     _weight = ([_item] call life_fnc_itemWeight);
  1207. };
  1208. if (isNil '_weight') then {
  1209.     _weight = 0;
  1210. };
  1211.  
  1212. if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith  {   hint localize "STR_NOTF_NoRoom"; };
  1213. if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith    {  hint localize "STR_NOTF_NoRoom"; };
  1214. if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";  };
  1215. if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  1216. if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  1217. if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  1218. if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  1219. if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  1220. if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";};
  1221.  
  1222. if(_itemFilter == "item") then    {
  1223.  
  1224.     //output
  1225.     diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
  1226.  
  1227.    _itemName = [_newItem] call life_fnc_varToStr;
  1228.  
  1229.    //output
  1230.     diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
  1231.  
  1232. } else        {  
  1233.     _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
  1234.  
  1235.    //output
  1236.     diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
  1237.  
  1238.     _itemName = _itemInfo select 1;
  1239. };
  1240.  
  1241.  
  1242. _upp = format["Crafting %1",_itemName];
  1243.  
  1244. //output
  1245. diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
  1246.  
  1247. closeDialog 0;
  1248.  
  1249. //Setup our progress bar.
  1250.  
  1251. 5 cutRsc ["life_progress","PLAIN"];
  1252. _ui = uiNameSpace getVariable "life_progress";
  1253. _progress = _ui displayCtrl 38201;
  1254. _pgText = _ui displayCtrl 38202;
  1255. _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
  1256. _progress progressSetPosition 0.01;
  1257. _cP = 0.01;
  1258. _removeItemSuccess = true;
  1259. _invSize = count _oldItem;
  1260.  
  1261. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do  {
  1262.    _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  1263.     if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
  1264. };
  1265.  
  1266. if(!_removeItemSuccess) exitWith {
  1267.     5 cutText ["","PLAIN"];
  1268.     life_is_processing = false;
  1269. };
  1270.  
  1271. [] call life_fnc_p_updateMenu;
  1272.  
  1273. life_is_processing = true;
  1274.  
  1275.  while{true} do{
  1276.     sleep  0.3;
  1277.     _cP = _cP + 0.01;
  1278.     _progress progressSetPosition _cP;
  1279.     _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
  1280.     if(_cP >= 1) exitWith {};
  1281. };
  1282.  
  1283. if(_itemFilter == "backpack") then{
  1284.     if(backpack player == "") then {    
  1285.         player addBackpack _newItem;
  1286.     }else{
  1287.           hint localize "STR_CRAFT_AR_Backpack";
  1288.         life_is_processing = false;
  1289.     };
  1290. };
  1291.  
  1292. if(_itemFilter == "attachments") then {
  1293.     if(player canAdd _newItem) then {  
  1294.         player addItem _newItem;
  1295.     } else {      
  1296.         if(currentWeapon player == "") then {
  1297.             player addWeapon _newItem;
  1298.         } else {
  1299.             5 cutText ["","PLAIN"];
  1300.         };
  1301.     };
  1302. };
  1303.  
  1304.  
  1305. //output
  1306. diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
  1307.  
  1308. if(_itemFilter == "item") then {
  1309.     _handledItem = [_newItem,1]  call life_fnc_varHandle;
  1310.  
  1311.     //output
  1312.     diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
  1313.  
  1314.     [true,_handledItem,1] call life_fnc_handleInv;
  1315. };
  1316.  
  1317.  
  1318. if(_itemFilter == "pweapon")
  1319. then{  
  1320. if(player canAdd _newItem)
  1321. then{  
  1322. player addItem _newItem;
  1323. } else {      
  1324. if(currentWeapon player == "")
  1325. then{   player addWeapon _newItem;
  1326. }else{    
  1327. 5 cutText ["","PLAIN"];      
  1328.  
  1329. if(_itemFilter == "rweapon")
  1330. then{  
  1331. if(player canAdd _newItem)
  1332. then{  
  1333. player addItem _newItem;
  1334. } else {      
  1335. if(currentWeapon player == "")
  1336. then{   player addWeapon _newItem;
  1337. }else{    
  1338. 5 cutText ["","PLAIN"];
  1339.  
  1340. if(_itemFilter == "rammunition")
  1341. then{  
  1342. if(player canAdd _newItem)
  1343. then{  
  1344. player addItem _newItem;
  1345. } else {      
  1346. if(currentWeapon player == "")
  1347. then{   player addWeapon _newItem;
  1348. }else{    
  1349. 5 cutText ["","PLAIN"];
  1350.  
  1351. if(_itemFilter == "pammunition")
  1352. then{  
  1353. if(player canAdd _newItem)
  1354. then{  
  1355. player addItem _newItem;
  1356. } else {      
  1357. if(currentWeapon player == "")
  1358. then{   player addWeapon _newItem;
  1359. }else{    
  1360. 5 cutText ["","PLAIN"];      
  1361.  
  1362. if(_itemFilter == "hidden")
  1363. then{  
  1364. if(player canAdd _newItem)
  1365. then{  
  1366. player addItem _newItem;
  1367. } else {      
  1368. if(currentWeapon player == "")
  1369. then{   player addWeapon _newItem;
  1370. }else{    
  1371. 5 cutText ["","PLAIN"];
  1372.  
  1373. if(_itemFilter == "gang")
  1374. then{  
  1375. if(player canAdd _newItem)
  1376. then{  
  1377. player addItem _newItem;
  1378. } else {      
  1379. if(currentWeapon player == "")
  1380. then{   player addWeapon _newItem;
  1381. }else{    
  1382. 5 cutText ["","PLAIN"];
  1383.  
  1384. if(_itemFilter == "gangattach")
  1385. then{  
  1386. if(player canAdd _newItem)
  1387. then{  
  1388. player addItem _newItem;
  1389. } else {      
  1390. if(currentWeapon player == "")
  1391. then{   player addWeapon _newItem;
  1392. }else{    
  1393. 5 cutText ["","PLAIN"];
  1394.  
  1395.  
  1396.  
  1397.  
  1398. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {             _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  1399. [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
  1400. };        
  1401. life_is_processing = false;    
  1402. };  };
  1403. };
  1404. 5 cutText ["","PLAIN"];
  1405. titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
  1406. life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
  1407. disableSerialization;
  1408.  
  1409. //declare
  1410. _dialog = displayNull;
  1411.  
  1412. //get
  1413. _dialog = findDisplay 666;
  1414.  
  1415. //validate
  1416. if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
  1417. if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
  1418. };
  1419.  
  1420. //declare
  1421. _item = "";
  1422.  
  1423. //get
  1424. _item = lbData[669,(lbCurSel 669)];
  1425.  
  1426. //validate
  1427. if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
  1428. if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
  1429. if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
  1430.  
  1431. //output
  1432. diag_log(format["fn_craftAction:ItemData:%1", _item]);
  1433.  
  1434. _allMaterial = true;
  1435.  
  1436. //declare
  1437. _itemFilter = "item";
  1438.  
  1439. //get
  1440. _itemFilter = lbData[673,(lbCurSel 673)];
  1441.  
  1442. //validate
  1443. if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
  1444. if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
  1445. if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
  1446.  
  1447.  
  1448. //output
  1449. diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
  1450.  
  1451.  
  1452. _matsNeed = 0;
  1453. _config = [_itemFilter] call life_fnc_craftCfg;
  1454.  
  1455. //output
  1456. diag_log(format["fn_craftAction:_config:%1", _config]);
  1457.  
  1458. {
  1459.     //output
  1460.     diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
  1461.  
  1462.  
  1463.     if(_item == _x select 0) then {
  1464.          _matsNeed = _x select 1;
  1465.         _invSize = count _matsNeed;
  1466.         for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
  1467.                 _str = [_matsNeed select _i] call life_fnc_varToStr;
  1468.                 _matsNum = _matsNeed select _i+1;  
  1469.                 if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
  1470.         };
  1471.     };
  1472. } foreach (_config);
  1473.  
  1474. if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
  1475.  
  1476. //declare
  1477. _newItem = "";
  1478.  
  1479. _oldItem = _matsNeed;
  1480. _newItem = _item;
  1481.  
  1482. //Some checks
  1483. if((count _matsNeed) == 0) exitWith {};
  1484.  
  1485. _weight = nil;
  1486. if(_itemFilter == "item") then {
  1487.     _weight = ([_item] call life_fnc_itemWeight);
  1488. };
  1489. if (isNil '_weight') then {
  1490.     _weight = 0;
  1491. };
  1492.  
  1493. if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith  {   hint localize "STR_NOTF_NoRoom"; };
  1494. if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith    {  hint localize "STR_NOTF_NoRoom"; };
  1495. if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";  };
  1496. if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  1497. if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  1498. if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  1499. if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  1500. if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  1501. if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";};
  1502.  
  1503. if(_itemFilter == "item") then    {
  1504.  
  1505.     //output
  1506.     diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
  1507.  
  1508.    _itemName = [_newItem] call life_fnc_varToStr;
  1509.  
  1510.    //output
  1511.     diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
  1512.  
  1513. } else        {  
  1514.     _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
  1515.  
  1516.    //output
  1517.     diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
  1518.  
  1519.     _itemName = _itemInfo select 1;
  1520. };
  1521.  
  1522.  
  1523. _upp = format["Crafting %1",_itemName];
  1524.  
  1525. //output
  1526. diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
  1527.  
  1528. closeDialog 0;
  1529.  
  1530. //Setup our progress bar.
  1531.  
  1532. 5 cutRsc ["life_progress","PLAIN"];
  1533. _ui = uiNameSpace getVariable "life_progress";
  1534. _progress = _ui displayCtrl 38201;
  1535. _pgText = _ui displayCtrl 38202;
  1536. _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
  1537. _progress progressSetPosition 0.01;
  1538. _cP = 0.01;
  1539. _removeItemSuccess = true;
  1540. _invSize = count _oldItem;
  1541.  
  1542. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do  {
  1543.    _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  1544.     if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
  1545. };
  1546.  
  1547. if(!_removeItemSuccess) exitWith {
  1548.     5 cutText ["","PLAIN"];
  1549.     life_is_processing = false;
  1550. };
  1551.  
  1552. [] call life_fnc_p_updateMenu;
  1553.  
  1554. life_is_processing = true;
  1555.  
  1556.  while{true} do{
  1557.     sleep  0.3;
  1558.     _cP = _cP + 0.01;
  1559.     _progress progressSetPosition _cP;
  1560.     _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
  1561.     if(_cP >= 1) exitWith {};
  1562. };
  1563.  
  1564. if(_itemFilter == "backpack") then{
  1565.     if(backpack player == "") then {    
  1566.         player addBackpack _newItem;
  1567.     }else{
  1568.           hint localize "STR_CRAFT_AR_Backpack";
  1569.         life_is_processing = false;
  1570.     };
  1571. };
  1572.  
  1573. if(_itemFilter == "attachments") then {
  1574.     if(player canAdd _newItem) then {  
  1575.         player addItem _newItem;
  1576.     } else {      
  1577.         if(currentWeapon player == "") then {
  1578.             player addWeapon _newItem;
  1579.         } else {
  1580.             5 cutText ["","PLAIN"];
  1581.         };
  1582.     };
  1583. };
  1584.  
  1585.  
  1586. //output
  1587. diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
  1588.  
  1589. if(_itemFilter == "item") then {
  1590.     _handledItem = [_newItem,1]  call life_fnc_varHandle;
  1591.  
  1592.     //output
  1593.     diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
  1594.  
  1595.     [true,_handledItem,1] call life_fnc_handleInv;
  1596. };
  1597.  
  1598.  
  1599. if(_itemFilter == "pweapon")
  1600. then{  
  1601. if(player canAdd _newItem)
  1602. then{  
  1603. player addItem _newItem;
  1604. } else {      
  1605. if(currentWeapon player == "")
  1606. then{   player addWeapon _newItem;
  1607. }else{    
  1608. 5 cutText ["","PLAIN"];      
  1609.  
  1610. if(_itemFilter == "rweapon")
  1611. then{  
  1612. if(player canAdd _newItem)
  1613. then{  
  1614. player addItem _newItem;
  1615. } else {      
  1616. if(currentWeapon player == "")
  1617. then{   player addWeapon _newItem;
  1618. }else{    
  1619. 5 cutText ["","PLAIN"];
  1620.  
  1621. if(_itemFilter == "rammunition")
  1622. then{  
  1623. if(player canAdd _newItem)
  1624. then{  
  1625. player addItem _newItem;
  1626. } else {      
  1627. if(currentWeapon player == "")
  1628. then{   player addWeapon _newItem;
  1629. }else{    
  1630. 5 cutText ["","PLAIN"];
  1631.  
  1632. if(_itemFilter == "pammunition")
  1633. then{  
  1634. if(player canAdd _newItem)
  1635. then{  
  1636. player addItem _newItem;
  1637. } else {      
  1638. if(currentWeapon player == "")
  1639. then{   player addWeapon _newItem;
  1640. }else{    
  1641. 5 cutText ["","PLAIN"];      
  1642.  
  1643. if(_itemFilter == "hidden")
  1644. then{  
  1645. if(player canAdd _newItem)
  1646. then{  
  1647. player addItem _newItem;
  1648. } else {      
  1649. if(currentWeapon player == "")
  1650. then{   player addWeapon _newItem;
  1651. }else{    
  1652. 5 cutText ["","PLAIN"];
  1653.  
  1654. if(_itemFilter == "gang")
  1655. then{  
  1656. if(player canAdd _newItem)
  1657. then{  
  1658. player addItem _newItem;
  1659. } else {      
  1660. if(currentWeapon player == "")
  1661. then{   player addWeapon _newItem;
  1662. }else{    
  1663. 5 cutText ["","PLAIN"];
  1664.  
  1665. if(_itemFilter == "gangattach")
  1666. then{  
  1667. if(player canAdd _newItem)
  1668. then{  
  1669. player addItem _newItem;
  1670. } else {      
  1671. if(currentWeapon player == "")
  1672. then{   player addWeapon _newItem;
  1673. }else{    
  1674. 5 cutText ["","PLAIN"];
  1675.  
  1676.  
  1677.  
  1678.  
  1679. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {             _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  1680. [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
  1681. };        
  1682. life_is_processing = false;    
  1683. };  };
  1684. };
  1685. 5 cutText ["","PLAIN"];
  1686. titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
  1687. life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
  1688. disableSerialization;
  1689.  
  1690. //declare
  1691. _dialog = displayNull;
  1692.  
  1693. //get
  1694. _dialog = findDisplay 666;
  1695.  
  1696. //validate
  1697. if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
  1698. if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
  1699. };
  1700.  
  1701. //declare
  1702. _item = "";
  1703.  
  1704. //get
  1705. _item = lbData[669,(lbCurSel 669)];
  1706.  
  1707. //validate
  1708. if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
  1709. if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
  1710. if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
  1711.  
  1712. //output
  1713. diag_log(format["fn_craftAction:ItemData:%1", _item]);
  1714.  
  1715. _allMaterial = true;
  1716.  
  1717. //declare
  1718. _itemFilter = "item";
  1719.  
  1720. //get
  1721. _itemFilter = lbData[673,(lbCurSel 673)];
  1722.  
  1723. //validate
  1724. if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
  1725. if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
  1726. if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
  1727.  
  1728.  
  1729. //output
  1730. diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
  1731.  
  1732.  
  1733. _matsNeed = 0;
  1734. _config = [_itemFilter] call life_fnc_craftCfg;
  1735.  
  1736. //output
  1737. diag_log(format["fn_craftAction:_config:%1", _config]);
  1738.  
  1739. {
  1740.     //output
  1741.     diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
  1742.  
  1743.  
  1744.     if(_item == _x select 0) then {
  1745.          _matsNeed = _x select 1;
  1746.         _invSize = count _matsNeed;
  1747.         for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
  1748.                 _str = [_matsNeed select _i] call life_fnc_varToStr;
  1749.                 _matsNum = _matsNeed select _i+1;  
  1750.                 if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
  1751.         };
  1752.     };
  1753. } foreach (_config);
  1754.  
  1755. if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
  1756.  
  1757. //declare
  1758. _newItem = "";
  1759.  
  1760. _oldItem = _matsNeed;
  1761. _newItem = _item;
  1762.  
  1763. //Some checks
  1764. if((count _matsNeed) == 0) exitWith {};
  1765.  
  1766. _weight = nil;
  1767. if(_itemFilter == "item") then {
  1768.     _weight = ([_item] call life_fnc_itemWeight);
  1769. };
  1770. if (isNil '_weight') then {
  1771.     _weight = 0;
  1772. };
  1773.  
  1774. if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith  {   hint localize "STR_NOTF_NoRoom"; };
  1775. if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith    {  hint localize "STR_NOTF_NoRoom"; };
  1776. if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";  };
  1777. if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  1778. if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  1779. if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  1780. if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  1781. if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  1782. if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";};
  1783.  
  1784. if(_itemFilter == "item") then    {
  1785.  
  1786.     //output
  1787.     diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
  1788.  
  1789.    _itemName = [_newItem] call life_fnc_varToStr;
  1790.  
  1791.    //output
  1792.     diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
  1793.  
  1794. } else        {  
  1795.     _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
  1796.  
  1797.    //output
  1798.     diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
  1799.  
  1800.     _itemName = _itemInfo select 1;
  1801. };
  1802.  
  1803.  
  1804. _upp = format["Crafting %1",_itemName];
  1805.  
  1806. //output
  1807. diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
  1808.  
  1809. closeDialog 0;
  1810.  
  1811. //Setup our progress bar.
  1812.  
  1813. 5 cutRsc ["life_progress","PLAIN"];
  1814. _ui = uiNameSpace getVariable "life_progress";
  1815. _progress = _ui displayCtrl 38201;
  1816. _pgText = _ui displayCtrl 38202;
  1817. _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
  1818. _progress progressSetPosition 0.01;
  1819. _cP = 0.01;
  1820. _removeItemSuccess = true;
  1821. _invSize = count _oldItem;
  1822.  
  1823. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do  {
  1824.    _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  1825.     if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
  1826. };
  1827.  
  1828. if(!_removeItemSuccess) exitWith {
  1829.     5 cutText ["","PLAIN"];
  1830.     life_is_processing = false;
  1831. };
  1832.  
  1833. [] call life_fnc_p_updateMenu;
  1834.  
  1835. life_is_processing = true;
  1836.  
  1837.  while{true} do{
  1838.     sleep  0.3;
  1839.     _cP = _cP + 0.01;
  1840.     _progress progressSetPosition _cP;
  1841.     _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
  1842.     if(_cP >= 1) exitWith {};
  1843. };
  1844.  
  1845. if(_itemFilter == "backpack") then{
  1846.     if(backpack player == "") then {    
  1847.         player addBackpack _newItem;
  1848.     }else{
  1849.           hint localize "STR_CRAFT_AR_Backpack";
  1850.         life_is_processing = false;
  1851.     };
  1852. };
  1853.  
  1854. if(_itemFilter == "attachments") then {
  1855.     if(player canAdd _newItem) then {  
  1856.         player addItem _newItem;
  1857.     } else {      
  1858.         if(currentWeapon player == "") then {
  1859.             player addWeapon _newItem;
  1860.         } else {
  1861.             5 cutText ["","PLAIN"];
  1862.         };
  1863.     };
  1864. };
  1865.  
  1866.  
  1867. //output
  1868. diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
  1869.  
  1870. if(_itemFilter == "item") then {
  1871.     _handledItem = [_newItem,1]  call life_fnc_varHandle;
  1872.  
  1873.     //output
  1874.     diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
  1875.  
  1876.     [true,_handledItem,1] call life_fnc_handleInv;
  1877. };
  1878.  
  1879.  
  1880. if(_itemFilter == "pweapon")
  1881. then{  
  1882. if(player canAdd _newItem)
  1883. then{  
  1884. player addItem _newItem;
  1885. } else {      
  1886. if(currentWeapon player == "")
  1887. then{   player addWeapon _newItem;
  1888. }else{    
  1889. 5 cutText ["","PLAIN"];      
  1890.  
  1891. if(_itemFilter == "rweapon")
  1892. then{  
  1893. if(player canAdd _newItem)
  1894. then{  
  1895. player addItem _newItem;
  1896. } else {      
  1897. if(currentWeapon player == "")
  1898. then{   player addWeapon _newItem;
  1899. }else{    
  1900. 5 cutText ["","PLAIN"];
  1901.  
  1902. if(_itemFilter == "rammunition")
  1903. then{  
  1904. if(player canAdd _newItem)
  1905. then{  
  1906. player addItem _newItem;
  1907. } else {      
  1908. if(currentWeapon player == "")
  1909. then{   player addWeapon _newItem;
  1910. }else{    
  1911. 5 cutText ["","PLAIN"];
  1912.  
  1913. if(_itemFilter == "pammunition")
  1914. then{  
  1915. if(player canAdd _newItem)
  1916. then{  
  1917. player addItem _newItem;
  1918. } else {      
  1919. if(currentWeapon player == "")
  1920. then{   player addWeapon _newItem;
  1921. }else{    
  1922. 5 cutText ["","PLAIN"];      
  1923.  
  1924. if(_itemFilter == "hidden")
  1925. then{  
  1926. if(player canAdd _newItem)
  1927. then{  
  1928. player addItem _newItem;
  1929. } else {      
  1930. if(currentWeapon player == "")
  1931. then{   player addWeapon _newItem;
  1932. }else{    
  1933. 5 cutText ["","PLAIN"];
  1934.  
  1935. if(_itemFilter == "gang")
  1936. then{  
  1937. if(player canAdd _newItem)
  1938. then{  
  1939. player addItem _newItem;
  1940. } else {      
  1941. if(currentWeapon player == "")
  1942. then{   player addWeapon _newItem;
  1943. }else{    
  1944. 5 cutText ["","PLAIN"];
  1945.  
  1946. if(_itemFilter == "gangattach")
  1947. then{  
  1948. if(player canAdd _newItem)
  1949. then{  
  1950. player addItem _newItem;
  1951. } else {      
  1952. if(currentWeapon player == "")
  1953. then{   player addWeapon _newItem;
  1954. }else{    
  1955. 5 cutText ["","PLAIN"];
  1956.  
  1957.  
  1958.  
  1959.  
  1960. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {             _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  1961. [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
  1962. };        
  1963. life_is_processing = false;    
  1964. };  };
  1965. };
  1966. 5 cutText ["","PLAIN"];
  1967. titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
  1968. life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
  1969. disableSerialization;
  1970.  
  1971. //declare
  1972. _dialog = displayNull;
  1973.  
  1974. //get
  1975. _dialog = findDisplay 666;
  1976.  
  1977. //validate
  1978. if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
  1979. if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
  1980. };
  1981.  
  1982. //declare
  1983. _item = "";
  1984.  
  1985. //get
  1986. _item = lbData[669,(lbCurSel 669)];
  1987.  
  1988. //validate
  1989. if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
  1990. if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
  1991. if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
  1992.  
  1993. //output
  1994. diag_log(format["fn_craftAction:ItemData:%1", _item]);
  1995.  
  1996. _allMaterial = true;
  1997.  
  1998. //declare
  1999. _itemFilter = "item";
  2000.  
  2001. //get
  2002. _itemFilter = lbData[673,(lbCurSel 673)];
  2003.  
  2004. //validate
  2005. if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
  2006. if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
  2007. if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
  2008.  
  2009.  
  2010. //output
  2011. diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
  2012.  
  2013.  
  2014. _matsNeed = 0;
  2015. _config = [_itemFilter] call life_fnc_craftCfg;
  2016.  
  2017. //output
  2018. diag_log(format["fn_craftAction:_config:%1", _config]);
  2019.  
  2020. {
  2021.     //output
  2022.     diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
  2023.  
  2024.  
  2025.     if(_item == _x select 0) then {
  2026.          _matsNeed = _x select 1;
  2027.         _invSize = count _matsNeed;
  2028.         for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
  2029.                 _str = [_matsNeed select _i] call life_fnc_varToStr;
  2030.                 _matsNum = _matsNeed select _i+1;  
  2031.                 if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
  2032.         };
  2033.     };
  2034. } foreach (_config);
  2035.  
  2036. if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
  2037.  
  2038. //declare
  2039. _newItem = "";
  2040.  
  2041. _oldItem = _matsNeed;
  2042. _newItem = _item;
  2043.  
  2044. //Some checks
  2045. if((count _matsNeed) == 0) exitWith {};
  2046.  
  2047. _weight = nil;
  2048. if(_itemFilter == "item") then {
  2049.     _weight = ([_item] call life_fnc_itemWeight);
  2050. };
  2051. if (isNil '_weight') then {
  2052.     _weight = 0;
  2053. };
  2054.  
  2055. if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith  {   hint localize "STR_NOTF_NoRoom"; };
  2056. if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith    {  hint localize "STR_NOTF_NoRoom"; };
  2057. if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";  };
  2058. if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  2059. if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  2060. if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  2061. if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  2062. if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  2063. if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";};
  2064.  
  2065. if(_itemFilter == "item") then    {
  2066.  
  2067.     //output
  2068.     diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
  2069.  
  2070.    _itemName = [_newItem] call life_fnc_varToStr;
  2071.  
  2072.    //output
  2073.     diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
  2074.  
  2075. } else        {  
  2076.     _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
  2077.  
  2078.    //output
  2079.     diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
  2080.  
  2081.     _itemName = _itemInfo select 1;
  2082. };
  2083.  
  2084.  
  2085. _upp = format["Crafting %1",_itemName];
  2086.  
  2087. //output
  2088. diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
  2089.  
  2090. closeDialog 0;
  2091.  
  2092. //Setup our progress bar.
  2093.  
  2094. 5 cutRsc ["life_progress","PLAIN"];
  2095. _ui = uiNameSpace getVariable "life_progress";
  2096. _progress = _ui displayCtrl 38201;
  2097. _pgText = _ui displayCtrl 38202;
  2098. _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
  2099. _progress progressSetPosition 0.01;
  2100. _cP = 0.01;
  2101. _removeItemSuccess = true;
  2102. _invSize = count _oldItem;
  2103.  
  2104. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do  {
  2105.    _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  2106.     if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
  2107. };
  2108.  
  2109. if(!_removeItemSuccess) exitWith {
  2110.     5 cutText ["","PLAIN"];
  2111.     life_is_processing = false;
  2112. };
  2113.  
  2114. [] call life_fnc_p_updateMenu;
  2115.  
  2116. life_is_processing = true;
  2117.  
  2118.  while{true} do{
  2119.     sleep  0.3;
  2120.     _cP = _cP + 0.01;
  2121.     _progress progressSetPosition _cP;
  2122.     _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
  2123.     if(_cP >= 1) exitWith {};
  2124. };
  2125.  
  2126. if(_itemFilter == "backpack") then{
  2127.     if(backpack player == "") then {    
  2128.         player addBackpack _newItem;
  2129.     }else{
  2130.           hint localize "STR_CRAFT_AR_Backpack";
  2131.         life_is_processing = false;
  2132.     };
  2133. };
  2134.  
  2135. if(_itemFilter == "attachments") then {
  2136.     if(player canAdd _newItem) then {  
  2137.         player addItem _newItem;
  2138.     } else {      
  2139.         if(currentWeapon player == "") then {
  2140.             player addWeapon _newItem;
  2141.         } else {
  2142.             5 cutText ["","PLAIN"];
  2143.         };
  2144.     };
  2145. };
  2146.  
  2147.  
  2148. //output
  2149. diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
  2150.  
  2151. if(_itemFilter == "item") then {
  2152.     _handledItem = [_newItem,1]  call life_fnc_varHandle;
  2153.  
  2154.     //output
  2155.     diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
  2156.  
  2157.     [true,_handledItem,1] call life_fnc_handleInv;
  2158. };
  2159.  
  2160.  
  2161. if(_itemFilter == "pweapon")
  2162. then{  
  2163. if(player canAdd _newItem)
  2164. then{  
  2165. player addItem _newItem;
  2166. } else {      
  2167. if(currentWeapon player == "")
  2168. then{   player addWeapon _newItem;
  2169. }else{    
  2170. 5 cutText ["","PLAIN"];      
  2171.  
  2172. if(_itemFilter == "rweapon")
  2173. then{  
  2174. if(player canAdd _newItem)
  2175. then{  
  2176. player addItem _newItem;
  2177. } else {      
  2178. if(currentWeapon player == "")
  2179. then{   player addWeapon _newItem;
  2180. }else{    
  2181. 5 cutText ["","PLAIN"];
  2182.  
  2183. if(_itemFilter == "rammunition")
  2184. then{  
  2185. if(player canAdd _newItem)
  2186. then{  
  2187. player addItem _newItem;
  2188. } else {      
  2189. if(currentWeapon player == "")
  2190. then{   player addWeapon _newItem;
  2191. }else{    
  2192. 5 cutText ["","PLAIN"];
  2193.  
  2194. if(_itemFilter == "pammunition")
  2195. then{  
  2196. if(player canAdd _newItem)
  2197. then{  
  2198. player addItem _newItem;
  2199. } else {      
  2200. if(currentWeapon player == "")
  2201. then{   player addWeapon _newItem;
  2202. }else{    
  2203. 5 cutText ["","PLAIN"];      
  2204.  
  2205. if(_itemFilter == "hidden")
  2206. then{  
  2207. if(player canAdd _newItem)
  2208. then{  
  2209. player addItem _newItem;
  2210. } else {      
  2211. if(currentWeapon player == "")
  2212. then{   player addWeapon _newItem;
  2213. }else{    
  2214. 5 cutText ["","PLAIN"];
  2215.  
  2216. if(_itemFilter == "gang")
  2217. then{  
  2218. if(player canAdd _newItem)
  2219. then{  
  2220. player addItem _newItem;
  2221. } else {      
  2222. if(currentWeapon player == "")
  2223. then{   player addWeapon _newItem;
  2224. }else{    
  2225. 5 cutText ["","PLAIN"];
  2226.  
  2227. if(_itemFilter == "gangattach")
  2228. then{  
  2229. if(player canAdd _newItem)
  2230. then{  
  2231. player addItem _newItem;
  2232. } else {      
  2233. if(currentWeapon player == "")
  2234. then{   player addWeapon _newItem;
  2235. }else{    
  2236. 5 cutText ["","PLAIN"];
  2237.  
  2238.  
  2239.  
  2240.  
  2241. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {             _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  2242. [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
  2243. };        
  2244. life_is_processing = false;    
  2245. };  };
  2246. };
  2247. 5 cutText ["","PLAIN"];
  2248. titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
  2249. life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
  2250. disableSerialization;
  2251.  
  2252. //declare
  2253. _dialog = displayNull;
  2254.  
  2255. //get
  2256. _dialog = findDisplay 666;
  2257.  
  2258. //validate
  2259. if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
  2260. if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
  2261. };
  2262.  
  2263. //declare
  2264. _item = "";
  2265.  
  2266. //get
  2267. _item = lbData[669,(lbCurSel 669)];
  2268.  
  2269. //validate
  2270. if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
  2271. if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
  2272. if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
  2273.  
  2274. //output
  2275. diag_log(format["fn_craftAction:ItemData:%1", _item]);
  2276.  
  2277. _allMaterial = true;
  2278.  
  2279. //declare
  2280. _itemFilter = "item";
  2281.  
  2282. //get
  2283. _itemFilter = lbData[673,(lbCurSel 673)];
  2284.  
  2285. //validate
  2286. if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
  2287. if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
  2288. if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
  2289.  
  2290.  
  2291. //output
  2292. diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
  2293.  
  2294.  
  2295. _matsNeed = 0;
  2296. _config = [_itemFilter] call life_fnc_craftCfg;
  2297.  
  2298. //output
  2299. diag_log(format["fn_craftAction:_config:%1", _config]);
  2300.  
  2301. {
  2302.     //output
  2303.     diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
  2304.  
  2305.  
  2306.     if(_item == _x select 0) then {
  2307.          _matsNeed = _x select 1;
  2308.         _invSize = count _matsNeed;
  2309.         for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
  2310.                 _str = [_matsNeed select _i] call life_fnc_varToStr;
  2311.                 _matsNum = _matsNeed select _i+1;  
  2312.                 if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
  2313.         };
  2314.     };
  2315. } foreach (_config);
  2316.  
  2317. if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
  2318.  
  2319. //declare
  2320. _newItem = "";
  2321.  
  2322. _oldItem = _matsNeed;
  2323. _newItem = _item;
  2324.  
  2325. //Some checks
  2326. if((count _matsNeed) == 0) exitWith {};
  2327.  
  2328. _weight = nil;
  2329. if(_itemFilter == "item") then {
  2330.     _weight = ([_item] call life_fnc_itemWeight);
  2331. };
  2332. if (isNil '_weight') then {
  2333.     _weight = 0;
  2334. };
  2335.  
  2336. if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith  {   hint localize "STR_NOTF_NoRoom"; };
  2337. if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith    {  hint localize "STR_NOTF_NoRoom"; };
  2338. if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";  };
  2339. if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  2340. if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  2341. if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  2342. if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  2343. if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  2344. if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";};
  2345.  
  2346. if(_itemFilter == "item") then    {
  2347.  
  2348.     //output
  2349.     diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
  2350.  
  2351.    _itemName = [_newItem] call life_fnc_varToStr;
  2352.  
  2353.    //output
  2354.     diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
  2355.  
  2356. } else        {  
  2357.     _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
  2358.  
  2359.    //output
  2360.     diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
  2361.  
  2362.     _itemName = _itemInfo select 1;
  2363. };
  2364.  
  2365.  
  2366. _upp = format["Crafting %1",_itemName];
  2367.  
  2368. //output
  2369. diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
  2370.  
  2371. closeDialog 0;
  2372.  
  2373. //Setup our progress bar.
  2374.  
  2375. 5 cutRsc ["life_progress","PLAIN"];
  2376. _ui = uiNameSpace getVariable "life_progress";
  2377. _progress = _ui displayCtrl 38201;
  2378. _pgText = _ui displayCtrl 38202;
  2379. _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
  2380. _progress progressSetPosition 0.01;
  2381. _cP = 0.01;
  2382. _removeItemSuccess = true;
  2383. _invSize = count _oldItem;
  2384.  
  2385. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do  {
  2386.    _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  2387.     if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
  2388. };
  2389.  
  2390. if(!_removeItemSuccess) exitWith {
  2391.     5 cutText ["","PLAIN"];
  2392.     life_is_processing = false;
  2393. };
  2394.  
  2395. [] call life_fnc_p_updateMenu;
  2396.  
  2397. life_is_processing = true;
  2398.  
  2399.  while{true} do{
  2400.     sleep  0.3;
  2401.     _cP = _cP + 0.01;
  2402.     _progress progressSetPosition _cP;
  2403.     _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
  2404.     if(_cP >= 1) exitWith {};
  2405. };
  2406.  
  2407. if(_itemFilter == "backpack") then{
  2408.     if(backpack player == "") then {    
  2409.         player addBackpack _newItem;
  2410.     }else{
  2411.           hint localize "STR_CRAFT_AR_Backpack";
  2412.         life_is_processing = false;
  2413.     };
  2414. };
  2415.  
  2416. if(_itemFilter == "attachments") then {
  2417.     if(player canAdd _newItem) then {  
  2418.         player addItem _newItem;
  2419.     } else {      
  2420.         if(currentWeapon player == "") then {
  2421.             player addWeapon _newItem;
  2422.         } else {
  2423.             5 cutText ["","PLAIN"];
  2424.         };
  2425.     };
  2426. };
  2427.  
  2428.  
  2429. //output
  2430. diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
  2431.  
  2432. if(_itemFilter == "item") then {
  2433.     _handledItem = [_newItem,1]  call life_fnc_varHandle;
  2434.  
  2435.     //output
  2436.     diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
  2437.  
  2438.     [true,_handledItem,1] call life_fnc_handleInv;
  2439. };
  2440.  
  2441.  
  2442. if(_itemFilter == "pweapon")
  2443. then{  
  2444. if(player canAdd _newItem)
  2445. then{  
  2446. player addItem _newItem;
  2447. } else {      
  2448. if(currentWeapon player == "")
  2449. then{   player addWeapon _newItem;
  2450. }else{    
  2451. 5 cutText ["","PLAIN"];      
  2452.  
  2453. if(_itemFilter == "rweapon")
  2454. then{  
  2455. if(player canAdd _newItem)
  2456. then{  
  2457. player addItem _newItem;
  2458. } else {      
  2459. if(currentWeapon player == "")
  2460. then{   player addWeapon _newItem;
  2461. }else{    
  2462. 5 cutText ["","PLAIN"];
  2463.  
  2464. if(_itemFilter == "rammunition")
  2465. then{  
  2466. if(player canAdd _newItem)
  2467. then{  
  2468. player addItem _newItem;
  2469. } else {      
  2470. if(currentWeapon player == "")
  2471. then{   player addWeapon _newItem;
  2472. }else{    
  2473. 5 cutText ["","PLAIN"];
  2474.  
  2475. if(_itemFilter == "pammunition")
  2476. then{  
  2477. if(player canAdd _newItem)
  2478. then{  
  2479. player addItem _newItem;
  2480. } else {      
  2481. if(currentWeapon player == "")
  2482. then{   player addWeapon _newItem;
  2483. }else{    
  2484. 5 cutText ["","PLAIN"];      
  2485.  
  2486. if(_itemFilter == "hidden")
  2487. then{  
  2488. if(player canAdd _newItem)
  2489. then{  
  2490. player addItem _newItem;
  2491. } else {      
  2492. if(currentWeapon player == "")
  2493. then{   player addWeapon _newItem;
  2494. }else{    
  2495. 5 cutText ["","PLAIN"];
  2496.  
  2497. if(_itemFilter == "gang")
  2498. then{  
  2499. if(player canAdd _newItem)
  2500. then{  
  2501. player addItem _newItem;
  2502. } else {      
  2503. if(currentWeapon player == "")
  2504. then{   player addWeapon _newItem;
  2505. }else{    
  2506. 5 cutText ["","PLAIN"];
  2507.  
  2508. if(_itemFilter == "gangattach")
  2509. then{  
  2510. if(player canAdd _newItem)
  2511. then{  
  2512. player addItem _newItem;
  2513. } else {      
  2514. if(currentWeapon player == "")
  2515. then{   player addWeapon _newItem;
  2516. }else{    
  2517. 5 cutText ["","PLAIN"];
  2518.  
  2519.  
  2520.  
  2521.  
  2522. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {             _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  2523. [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
  2524. };        
  2525. life_is_processing = false;    
  2526. };  };
  2527. };
  2528. 5 cutText ["","PLAIN"];
  2529. titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
  2530. life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
  2531. disableSerialization;
  2532.  
  2533. //declare
  2534. _dialog = displayNull;
  2535.  
  2536. //get
  2537. _dialog = findDisplay 666;
  2538.  
  2539. //validate
  2540. if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
  2541. if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
  2542. };
  2543.  
  2544. //declare
  2545. _item = "";
  2546.  
  2547. //get
  2548. _item = lbData[669,(lbCurSel 669)];
  2549.  
  2550. //validate
  2551. if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
  2552. if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
  2553. if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
  2554.  
  2555. //output
  2556. diag_log(format["fn_craftAction:ItemData:%1", _item]);
  2557.  
  2558. _allMaterial = true;
  2559.  
  2560. //declare
  2561. _itemFilter = "item";
  2562.  
  2563. //get
  2564. _itemFilter = lbData[673,(lbCurSel 673)];
  2565.  
  2566. //validate
  2567. if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
  2568. if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
  2569. if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
  2570.  
  2571.  
  2572. //output
  2573. diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
  2574.  
  2575.  
  2576. _matsNeed = 0;
  2577. _config = [_itemFilter] call life_fnc_craftCfg;
  2578.  
  2579. //output
  2580. diag_log(format["fn_craftAction:_config:%1", _config]);
  2581.  
  2582. {
  2583.     //output
  2584.     diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
  2585.  
  2586.  
  2587.     if(_item == _x select 0) then {
  2588.          _matsNeed = _x select 1;
  2589.         _invSize = count _matsNeed;
  2590.         for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
  2591.                 _str = [_matsNeed select _i] call life_fnc_varToStr;
  2592.                 _matsNum = _matsNeed select _i+1;  
  2593.                 if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
  2594.         };
  2595.     };
  2596. } foreach (_config);
  2597.  
  2598. if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
  2599.  
  2600. //declare
  2601. _newItem = "";
  2602.  
  2603. _oldItem = _matsNeed;
  2604. _newItem = _item;
  2605.  
  2606. //Some checks
  2607. if((count _matsNeed) == 0) exitWith {};
  2608.  
  2609. _weight = nil;
  2610. if(_itemFilter == "item") then {
  2611.     _weight = ([_item] call life_fnc_itemWeight);
  2612. };
  2613. if (isNil '_weight') then {
  2614.     _weight = 0;
  2615. };
  2616.  
  2617. if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith  {   hint localize "STR_NOTF_NoRoom"; };
  2618. if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith    {  hint localize "STR_NOTF_NoRoom"; };
  2619. if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";  };
  2620. if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  2621. if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  2622. if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  2623. if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  2624. if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  2625. if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";};
  2626.  
  2627. if(_itemFilter == "item") then    {
  2628.  
  2629.     //output
  2630.     diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
  2631.  
  2632.    _itemName = [_newItem] call life_fnc_varToStr;
  2633.  
  2634.    //output
  2635.     diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
  2636.  
  2637. } else        {  
  2638.     _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
  2639.  
  2640.    //output
  2641.     diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
  2642.  
  2643.     _itemName = _itemInfo select 1;
  2644. };
  2645.  
  2646.  
  2647. _upp = format["Crafting %1",_itemName];
  2648.  
  2649. //output
  2650. diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
  2651.  
  2652. closeDialog 0;
  2653.  
  2654. //Setup our progress bar.
  2655.  
  2656. 5 cutRsc ["life_progress","PLAIN"];
  2657. _ui = uiNameSpace getVariable "life_progress";
  2658. _progress = _ui displayCtrl 38201;
  2659. _pgText = _ui displayCtrl 38202;
  2660. _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
  2661. _progress progressSetPosition 0.01;
  2662. _cP = 0.01;
  2663. _removeItemSuccess = true;
  2664. _invSize = count _oldItem;
  2665.  
  2666. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do  {
  2667.    _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  2668.     if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
  2669. };
  2670.  
  2671. if(!_removeItemSuccess) exitWith {
  2672.     5 cutText ["","PLAIN"];
  2673.     life_is_processing = false;
  2674. };
  2675.  
  2676. [] call life_fnc_p_updateMenu;
  2677.  
  2678. life_is_processing = true;
  2679.  
  2680.  while{true} do{
  2681.     sleep  0.3;
  2682.     _cP = _cP + 0.01;
  2683.     _progress progressSetPosition _cP;
  2684.     _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
  2685.     if(_cP >= 1) exitWith {};
  2686. };
  2687.  
  2688. if(_itemFilter == "backpack") then{
  2689.     if(backpack player == "") then {    
  2690.         player addBackpack _newItem;
  2691.     }else{
  2692.           hint localize "STR_CRAFT_AR_Backpack";
  2693.         life_is_processing = false;
  2694.     };
  2695. };
  2696.  
  2697. if(_itemFilter == "attachments") then {
  2698.     if(player canAdd _newItem) then {  
  2699.         player addItem _newItem;
  2700.     } else {      
  2701.         if(currentWeapon player == "") then {
  2702.             player addWeapon _newItem;
  2703.         } else {
  2704.             5 cutText ["","PLAIN"];
  2705.         };
  2706.     };
  2707. };
  2708.  
  2709.  
  2710. //output
  2711. diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
  2712.  
  2713. if(_itemFilter == "item") then {
  2714.     _handledItem = [_newItem,1]  call life_fnc_varHandle;
  2715.  
  2716.     //output
  2717.     diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
  2718.  
  2719.     [true,_handledItem,1] call life_fnc_handleInv;
  2720. };
  2721.  
  2722.  
  2723. if(_itemFilter == "pweapon")
  2724. then{  
  2725. if(player canAdd _newItem)
  2726. then{  
  2727. player addItem _newItem;
  2728. } else {      
  2729. if(currentWeapon player == "")
  2730. then{   player addWeapon _newItem;
  2731. }else{    
  2732. 5 cutText ["","PLAIN"];      
  2733.  
  2734. if(_itemFilter == "rweapon")
  2735. then{  
  2736. if(player canAdd _newItem)
  2737. then{  
  2738. player addItem _newItem;
  2739. } else {      
  2740. if(currentWeapon player == "")
  2741. then{   player addWeapon _newItem;
  2742. }else{    
  2743. 5 cutText ["","PLAIN"];
  2744.  
  2745. if(_itemFilter == "rammunition")
  2746. then{  
  2747. if(player canAdd _newItem)
  2748. then{  
  2749. player addItem _newItem;
  2750. } else {      
  2751. if(currentWeapon player == "")
  2752. then{   player addWeapon _newItem;
  2753. }else{    
  2754. 5 cutText ["","PLAIN"];
  2755.  
  2756. if(_itemFilter == "pammunition")
  2757. then{  
  2758. if(player canAdd _newItem)
  2759. then{  
  2760. player addItem _newItem;
  2761. } else {      
  2762. if(currentWeapon player == "")
  2763. then{   player addWeapon _newItem;
  2764. }else{    
  2765. 5 cutText ["","PLAIN"];      
  2766.  
  2767. if(_itemFilter == "hidden")
  2768. then{  
  2769. if(player canAdd _newItem)
  2770. then{  
  2771. player addItem _newItem;
  2772. } else {      
  2773. if(currentWeapon player == "")
  2774. then{   player addWeapon _newItem;
  2775. }else{    
  2776. 5 cutText ["","PLAIN"];
  2777.  
  2778. if(_itemFilter == "gang")
  2779. then{  
  2780. if(player canAdd _newItem)
  2781. then{  
  2782. player addItem _newItem;
  2783. } else {      
  2784. if(currentWeapon player == "")
  2785. then{   player addWeapon _newItem;
  2786. }else{    
  2787. 5 cutText ["","PLAIN"];
  2788.  
  2789. if(_itemFilter == "gangattach")
  2790. then{  
  2791. if(player canAdd _newItem)
  2792. then{  
  2793. player addItem _newItem;
  2794. } else {      
  2795. if(currentWeapon player == "")
  2796. then{   player addWeapon _newItem;
  2797. }else{    
  2798. 5 cutText ["","PLAIN"];
  2799.  
  2800.  
  2801.  
  2802.  
  2803. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {             _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  2804. [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
  2805. };        
  2806. life_is_processing = false;    
  2807. };  };
  2808. };
  2809. 5 cutText ["","PLAIN"];
  2810. titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
  2811. life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
  2812. disableSerialization;
  2813.  
  2814. //declare
  2815. _dialog = displayNull;
  2816.  
  2817. //get
  2818. _dialog = findDisplay 666;
  2819.  
  2820. //validate
  2821. if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
  2822. if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
  2823. };
  2824.  
  2825. //declare
  2826. _item = "";
  2827.  
  2828. //get
  2829. _item = lbData[669,(lbCurSel 669)];
  2830.  
  2831. //validate
  2832. if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
  2833. if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
  2834. if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
  2835.  
  2836. //output
  2837. diag_log(format["fn_craftAction:ItemData:%1", _item]);
  2838.  
  2839. _allMaterial = true;
  2840.  
  2841. //declare
  2842. _itemFilter = "item";
  2843.  
  2844. //get
  2845. _itemFilter = lbData[673,(lbCurSel 673)];
  2846.  
  2847. //validate
  2848. if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
  2849. if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
  2850. if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
  2851.  
  2852.  
  2853. //output
  2854. diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
  2855.  
  2856.  
  2857. _matsNeed = 0;
  2858. _config = [_itemFilter] call life_fnc_craftCfg;
  2859.  
  2860. //output
  2861. diag_log(format["fn_craftAction:_config:%1", _config]);
  2862.  
  2863. {
  2864.     //output
  2865.     diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
  2866.  
  2867.  
  2868.     if(_item == _x select 0) then {
  2869.          _matsNeed = _x select 1;
  2870.         _invSize = count _matsNeed;
  2871.         for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
  2872.                 _str = [_matsNeed select _i] call life_fnc_varToStr;
  2873.                 _matsNum = _matsNeed select _i+1;  
  2874.                 if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
  2875.         };
  2876.     };
  2877. } foreach (_config);
  2878.  
  2879. if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
  2880.  
  2881. //declare
  2882. _newItem = "";
  2883.  
  2884. _oldItem = _matsNeed;
  2885. _newItem = _item;
  2886.  
  2887. //Some checks
  2888. if((count _matsNeed) == 0) exitWith {};
  2889.  
  2890. _weight = nil;
  2891. if(_itemFilter == "item") then {
  2892.     _weight = ([_item] call life_fnc_itemWeight);
  2893. };
  2894. if (isNil '_weight') then {
  2895.     _weight = 0;
  2896. };
  2897.  
  2898. if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith  {   hint localize "STR_NOTF_NoRoom"; };
  2899. if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith    {  hint localize "STR_NOTF_NoRoom"; };
  2900. if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";  };
  2901. if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  2902. if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  2903. if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  2904. if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  2905. if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  2906. if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";};
  2907.  
  2908. if(_itemFilter == "item") then    {
  2909.  
  2910.     //output
  2911.     diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
  2912.  
  2913.    _itemName = [_newItem] call life_fnc_varToStr;
  2914.  
  2915.    //output
  2916.     diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
  2917.  
  2918. } else        {  
  2919.     _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
  2920.  
  2921.    //output
  2922.     diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
  2923.  
  2924.     _itemName = _itemInfo select 1;
  2925. };
  2926.  
  2927.  
  2928. _upp = format["Crafting %1",_itemName];
  2929.  
  2930. //output
  2931. diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
  2932.  
  2933. closeDialog 0;
  2934.  
  2935. //Setup our progress bar.
  2936.  
  2937. 5 cutRsc ["life_progress","PLAIN"];
  2938. _ui = uiNameSpace getVariable "life_progress";
  2939. _progress = _ui displayCtrl 38201;
  2940. _pgText = _ui displayCtrl 38202;
  2941. _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
  2942. _progress progressSetPosition 0.01;
  2943. _cP = 0.01;
  2944. _removeItemSuccess = true;
  2945. _invSize = count _oldItem;
  2946.  
  2947. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do  {
  2948.    _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  2949.     if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
  2950. };
  2951.  
  2952. if(!_removeItemSuccess) exitWith {
  2953.     5 cutText ["","PLAIN"];
  2954.     life_is_processing = false;
  2955. };
  2956.  
  2957. [] call life_fnc_p_updateMenu;
  2958.  
  2959. life_is_processing = true;
  2960.  
  2961.  while{true} do{
  2962.     sleep  0.3;
  2963.     _cP = _cP + 0.01;
  2964.     _progress progressSetPosition _cP;
  2965.     _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
  2966.     if(_cP >= 1) exitWith {};
  2967. };
  2968.  
  2969. if(_itemFilter == "backpack") then{
  2970.     if(backpack player == "") then {    
  2971.         player addBackpack _newItem;
  2972.     }else{
  2973.           hint localize "STR_CRAFT_AR_Backpack";
  2974.         life_is_processing = false;
  2975.     };
  2976. };
  2977.  
  2978. if(_itemFilter == "attachments") then {
  2979.     if(player canAdd _newItem) then {  
  2980.         player addItem _newItem;
  2981.     } else {      
  2982.         if(currentWeapon player == "") then {
  2983.             player addWeapon _newItem;
  2984.         } else {
  2985.             5 cutText ["","PLAIN"];
  2986.         };
  2987.     };
  2988. };
  2989.  
  2990.  
  2991. //output
  2992. diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
  2993.  
  2994. if(_itemFilter == "item") then {
  2995.     _handledItem = [_newItem,1]  call life_fnc_varHandle;
  2996.  
  2997.     //output
  2998.     diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
  2999.  
  3000.     [true,_handledItem,1] call life_fnc_handleInv;
  3001. };
  3002.  
  3003.  
  3004. if(_itemFilter == "pweapon")
  3005. then{  
  3006. if(player canAdd _newItem)
  3007. then{  
  3008. player addItem _newItem;
  3009. } else {      
  3010. if(currentWeapon player == "")
  3011. then{   player addWeapon _newItem;
  3012. }else{    
  3013. 5 cutText ["","PLAIN"];      
  3014.  
  3015. if(_itemFilter == "rweapon")
  3016. then{  
  3017. if(player canAdd _newItem)
  3018. then{  
  3019. player addItem _newItem;
  3020. } else {      
  3021. if(currentWeapon player == "")
  3022. then{   player addWeapon _newItem;
  3023. }else{    
  3024. 5 cutText ["","PLAIN"];
  3025.  
  3026. if(_itemFilter == "rammunition")
  3027. then{  
  3028. if(player canAdd _newItem)
  3029. then{  
  3030. player addItem _newItem;
  3031. } else {      
  3032. if(currentWeapon player == "")
  3033. then{   player addWeapon _newItem;
  3034. }else{    
  3035. 5 cutText ["","PLAIN"];
  3036.  
  3037. if(_itemFilter == "pammunition")
  3038. then{  
  3039. if(player canAdd _newItem)
  3040. then{  
  3041. player addItem _newItem;
  3042. } else {      
  3043. if(currentWeapon player == "")
  3044. then{   player addWeapon _newItem;
  3045. }else{    
  3046. 5 cutText ["","PLAIN"];      
  3047.  
  3048. if(_itemFilter == "hidden")
  3049. then{  
  3050. if(player canAdd _newItem)
  3051. then{  
  3052. player addItem _newItem;
  3053. } else {      
  3054. if(currentWeapon player == "")
  3055. then{   player addWeapon _newItem;
  3056. }else{    
  3057. 5 cutText ["","PLAIN"];
  3058.  
  3059. if(_itemFilter == "gang")
  3060. then{  
  3061. if(player canAdd _newItem)
  3062. then{  
  3063. player addItem _newItem;
  3064. } else {      
  3065. if(currentWeapon player == "")
  3066. then{   player addWeapon _newItem;
  3067. }else{    
  3068. 5 cutText ["","PLAIN"];
  3069.  
  3070. if(_itemFilter == "gangattach")
  3071. then{  
  3072. if(player canAdd _newItem)
  3073. then{  
  3074. player addItem _newItem;
  3075. } else {      
  3076. if(currentWeapon player == "")
  3077. then{   player addWeapon _newItem;
  3078. }else{    
  3079. 5 cutText ["","PLAIN"];
  3080.  
  3081.  
  3082.  
  3083.  
  3084. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {             _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  3085. [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
  3086. };        
  3087. life_is_processing = false;    
  3088. };  };
  3089. };
  3090. 5 cutText ["","PLAIN"];
  3091. titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
  3092. life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
  3093. disableSerialization;
  3094.  
  3095. //declare
  3096. _dialog = displayNull;
  3097.  
  3098. //get
  3099. _dialog = findDisplay 666;
  3100.  
  3101. //validate
  3102. if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
  3103. if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
  3104. };
  3105.  
  3106. //declare
  3107. _item = "";
  3108.  
  3109. //get
  3110. _item = lbData[669,(lbCurSel 669)];
  3111.  
  3112. //validate
  3113. if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
  3114. if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
  3115. if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
  3116.  
  3117. //output
  3118. diag_log(format["fn_craftAction:ItemData:%1", _item]);
  3119.  
  3120. _allMaterial = true;
  3121.  
  3122. //declare
  3123. _itemFilter = "item";
  3124.  
  3125. //get
  3126. _itemFilter = lbData[673,(lbCurSel 673)];
  3127.  
  3128. //validate
  3129. if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
  3130. if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
  3131. if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
  3132.  
  3133.  
  3134. //output
  3135. diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
  3136.  
  3137.  
  3138. _matsNeed = 0;
  3139. _config = [_itemFilter] call life_fnc_craftCfg;
  3140.  
  3141. //output
  3142. diag_log(format["fn_craftAction:_config:%1", _config]);
  3143.  
  3144. {
  3145.     //output
  3146.     diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
  3147.  
  3148.  
  3149.     if(_item == _x select 0) then {
  3150.          _matsNeed = _x select 1;
  3151.         _invSize = count _matsNeed;
  3152.         for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
  3153.                 _str = [_matsNeed select _i] call life_fnc_varToStr;
  3154.                 _matsNum = _matsNeed select _i+1;  
  3155.                 if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
  3156.         };
  3157.     };
  3158. } foreach (_config);
  3159.  
  3160. if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
  3161.  
  3162. //declare
  3163. _newItem = "";
  3164.  
  3165. _oldItem = _matsNeed;
  3166. _newItem = _item;
  3167.  
  3168. //Some checks
  3169. if((count _matsNeed) == 0) exitWith {};
  3170.  
  3171. _weight = nil;
  3172. if(_itemFilter == "item") then {
  3173.     _weight = ([_item] call life_fnc_itemWeight);
  3174. };
  3175. if (isNil '_weight') then {
  3176.     _weight = 0;
  3177. };
  3178.  
  3179. if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith  {   hint localize "STR_NOTF_NoRoom"; };
  3180. if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith    {  hint localize "STR_NOTF_NoRoom"; };
  3181. if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";  };
  3182. if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  3183. if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  3184. if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  3185. if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  3186. if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  3187. if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";};
  3188.  
  3189. if(_itemFilter == "item") then    {
  3190.  
  3191.     //output
  3192.     diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
  3193.  
  3194.    _itemName = [_newItem] call life_fnc_varToStr;
  3195.  
  3196.    //output
  3197.     diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
  3198.  
  3199. } else        {  
  3200.     _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
  3201.  
  3202.    //output
  3203.     diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
  3204.  
  3205.     _itemName = _itemInfo select 1;
  3206. };
  3207.  
  3208.  
  3209. _upp = format["Crafting %1",_itemName];
  3210.  
  3211. //output
  3212. diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
  3213.  
  3214. closeDialog 0;
  3215.  
  3216. //Setup our progress bar.
  3217.  
  3218. 5 cutRsc ["life_progress","PLAIN"];
  3219. _ui = uiNameSpace getVariable "life_progress";
  3220. _progress = _ui displayCtrl 38201;
  3221. _pgText = _ui displayCtrl 38202;
  3222. _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
  3223. _progress progressSetPosition 0.01;
  3224. _cP = 0.01;
  3225. _removeItemSuccess = true;
  3226. _invSize = count _oldItem;
  3227.  
  3228. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do  {
  3229.    _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  3230.     if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
  3231. };
  3232.  
  3233. if(!_removeItemSuccess) exitWith {
  3234.     5 cutText ["","PLAIN"];
  3235.     life_is_processing = false;
  3236. };
  3237.  
  3238. [] call life_fnc_p_updateMenu;
  3239.  
  3240. life_is_processing = true;
  3241.  
  3242.  while{true} do{
  3243.     sleep  0.3;
  3244.     _cP = _cP + 0.01;
  3245.     _progress progressSetPosition _cP;
  3246.     _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
  3247.     if(_cP >= 1) exitWith {};
  3248. };
  3249.  
  3250. if(_itemFilter == "backpack") then{
  3251.     if(backpack player == "") then {    
  3252.         player addBackpack _newItem;
  3253.     }else{
  3254.           hint localize "STR_CRAFT_AR_Backpack";
  3255.         life_is_processing = false;
  3256.     };
  3257. };
  3258.  
  3259. if(_itemFilter == "attachments") then {
  3260.     if(player canAdd _newItem) then {  
  3261.         player addItem _newItem;
  3262.     } else {      
  3263.         if(currentWeapon player == "") then {
  3264.             player addWeapon _newItem;
  3265.         } else {
  3266.             5 cutText ["","PLAIN"];
  3267.         };
  3268.     };
  3269. };
  3270.  
  3271.  
  3272. //output
  3273. diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
  3274.  
  3275. if(_itemFilter == "item") then {
  3276.     _handledItem = [_newItem,1]  call life_fnc_varHandle;
  3277.  
  3278.     //output
  3279.     diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
  3280.  
  3281.     [true,_handledItem,1] call life_fnc_handleInv;
  3282. };
  3283.  
  3284.  
  3285. if(_itemFilter == "pweapon")
  3286. then{  
  3287. if(player canAdd _newItem)
  3288. then{  
  3289. player addItem _newItem;
  3290. } else {      
  3291. if(currentWeapon player == "")
  3292. then{   player addWeapon _newItem;
  3293. }else{    
  3294. 5 cutText ["","PLAIN"];      
  3295.  
  3296. if(_itemFilter == "rweapon")
  3297. then{  
  3298. if(player canAdd _newItem)
  3299. then{  
  3300. player addItem _newItem;
  3301. } else {      
  3302. if(currentWeapon player == "")
  3303. then{   player addWeapon _newItem;
  3304. }else{    
  3305. 5 cutText ["","PLAIN"];
  3306.  
  3307. if(_itemFilter == "rammunition")
  3308. then{  
  3309. if(player canAdd _newItem)
  3310. then{  
  3311. player addItem _newItem;
  3312. } else {      
  3313. if(currentWeapon player == "")
  3314. then{   player addWeapon _newItem;
  3315. }else{    
  3316. 5 cutText ["","PLAIN"];
  3317.  
  3318. if(_itemFilter == "pammunition")
  3319. then{  
  3320. if(player canAdd _newItem)
  3321. then{  
  3322. player addItem _newItem;
  3323. } else {      
  3324. if(currentWeapon player == "")
  3325. then{   player addWeapon _newItem;
  3326. }else{    
  3327. 5 cutText ["","PLAIN"];      
  3328.  
  3329. if(_itemFilter == "hidden")
  3330. then{  
  3331. if(player canAdd _newItem)
  3332. then{  
  3333. player addItem _newItem;
  3334. } else {      
  3335. if(currentWeapon player == "")
  3336. then{   player addWeapon _newItem;
  3337. }else{    
  3338. 5 cutText ["","PLAIN"];
  3339.  
  3340. if(_itemFilter == "gang")
  3341. then{  
  3342. if(player canAdd _newItem)
  3343. then{  
  3344. player addItem _newItem;
  3345. } else {      
  3346. if(currentWeapon player == "")
  3347. then{   player addWeapon _newItem;
  3348. }else{    
  3349. 5 cutText ["","PLAIN"];
  3350.  
  3351. if(_itemFilter == "gangattach")
  3352. then{  
  3353. if(player canAdd _newItem)
  3354. then{  
  3355. player addItem _newItem;
  3356. } else {      
  3357. if(currentWeapon player == "")
  3358. then{   player addWeapon _newItem;
  3359. }else{    
  3360. 5 cutText ["","PLAIN"];
  3361.  
  3362.  
  3363.  
  3364.  
  3365. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {             _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  3366. [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
  3367. };        
  3368. life_is_processing = false;    
  3369. };  };
  3370. };
  3371. 5 cutText ["","PLAIN"];
  3372. titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
  3373. life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
  3374. disableSerialization;
  3375.  
  3376. //declare
  3377. _dialog = displayNull;
  3378.  
  3379. //get
  3380. _dialog = findDisplay 666;
  3381.  
  3382. //validate
  3383. if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
  3384. if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
  3385. };
  3386.  
  3387. //declare
  3388. _item = "";
  3389.  
  3390. //get
  3391. _item = lbData[669,(lbCurSel 669)];
  3392.  
  3393. //validate
  3394. if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
  3395. if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
  3396. if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
  3397.  
  3398. //output
  3399. diag_log(format["fn_craftAction:ItemData:%1", _item]);
  3400.  
  3401. _allMaterial = true;
  3402.  
  3403. //declare
  3404. _itemFilter = "item";
  3405.  
  3406. //get
  3407. _itemFilter = lbData[673,(lbCurSel 673)];
  3408.  
  3409. //validate
  3410. if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
  3411. if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
  3412. if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
  3413.  
  3414.  
  3415. //output
  3416. diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
  3417.  
  3418.  
  3419. _matsNeed = 0;
  3420. _config = [_itemFilter] call life_fnc_craftCfg;
  3421.  
  3422. //output
  3423. diag_log(format["fn_craftAction:_config:%1", _config]);
  3424.  
  3425. {
  3426.     //output
  3427.     diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
  3428.  
  3429.  
  3430.     if(_item == _x select 0) then {
  3431.          _matsNeed = _x select 1;
  3432.         _invSize = count _matsNeed;
  3433.         for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
  3434.                 _str = [_matsNeed select _i] call life_fnc_varToStr;
  3435.                 _matsNum = _matsNeed select _i+1;  
  3436.                 if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
  3437.         };
  3438.     };
  3439. } foreach (_config);
  3440.  
  3441. if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
  3442.  
  3443. //declare
  3444. _newItem = "";
  3445.  
  3446. _oldItem = _matsNeed;
  3447. _newItem = _item;
  3448.  
  3449. //Some checks
  3450. if((count _matsNeed) == 0) exitWith {};
  3451.  
  3452. _weight = nil;
  3453. if(_itemFilter == "item") then {
  3454.     _weight = ([_item] call life_fnc_itemWeight);
  3455. };
  3456. if (isNil '_weight') then {
  3457.     _weight = 0;
  3458. };
  3459.  
  3460. if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith  {   hint localize "STR_NOTF_NoRoom"; };
  3461. if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith    {  hint localize "STR_NOTF_NoRoom"; };
  3462. if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";  };
  3463. if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  3464. if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  3465. if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  3466. if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  3467. if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  3468. if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";};
  3469.  
  3470. if(_itemFilter == "item") then    {
  3471.  
  3472.     //output
  3473.     diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
  3474.  
  3475.    _itemName = [_newItem] call life_fnc_varToStr;
  3476.  
  3477.    //output
  3478.     diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
  3479.  
  3480. } else        {  
  3481.     _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
  3482.  
  3483.    //output
  3484.     diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
  3485.  
  3486.     _itemName = _itemInfo select 1;
  3487. };
  3488.  
  3489.  
  3490. _upp = format["Crafting %1",_itemName];
  3491.  
  3492. //output
  3493. diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
  3494.  
  3495. closeDialog 0;
  3496.  
  3497. //Setup our progress bar.
  3498.  
  3499. 5 cutRsc ["life_progress","PLAIN"];
  3500. _ui = uiNameSpace getVariable "life_progress";
  3501. _progress = _ui displayCtrl 38201;
  3502. _pgText = _ui displayCtrl 38202;
  3503. _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
  3504. _progress progressSetPosition 0.01;
  3505. _cP = 0.01;
  3506. _removeItemSuccess = true;
  3507. _invSize = count _oldItem;
  3508.  
  3509. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do  {
  3510.    _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  3511.     if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
  3512. };
  3513.  
  3514. if(!_removeItemSuccess) exitWith {
  3515.     5 cutText ["","PLAIN"];
  3516.     life_is_processing = false;
  3517. };
  3518.  
  3519. [] call life_fnc_p_updateMenu;
  3520.  
  3521. life_is_processing = true;
  3522.  
  3523.  while{true} do{
  3524.     sleep  0.3;
  3525.     _cP = _cP + 0.01;
  3526.     _progress progressSetPosition _cP;
  3527.     _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
  3528.     if(_cP >= 1) exitWith {};
  3529. };
  3530.  
  3531. if(_itemFilter == "backpack") then{
  3532.     if(backpack player == "") then {    
  3533.         player addBackpack _newItem;
  3534.     }else{
  3535.           hint localize "STR_CRAFT_AR_Backpack";
  3536.         life_is_processing = false;
  3537.     };
  3538. };
  3539.  
  3540. if(_itemFilter == "attachments") then {
  3541.     if(player canAdd _newItem) then {  
  3542.         player addItem _newItem;
  3543.     } else {      
  3544.         if(currentWeapon player == "") then {
  3545.             player addWeapon _newItem;
  3546.         } else {
  3547.             5 cutText ["","PLAIN"];
  3548.         };
  3549.     };
  3550. };
  3551.  
  3552.  
  3553. //output
  3554. diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
  3555.  
  3556. if(_itemFilter == "item") then {
  3557.     _handledItem = [_newItem,1]  call life_fnc_varHandle;
  3558.  
  3559.     //output
  3560.     diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
  3561.  
  3562.     [true,_handledItem,1] call life_fnc_handleInv;
  3563. };
  3564.  
  3565.  
  3566. if(_itemFilter == "pweapon")
  3567. then{  
  3568. if(player canAdd _newItem)
  3569. then{  
  3570. player addItem _newItem;
  3571. } else {      
  3572. if(currentWeapon player == "")
  3573. then{   player addWeapon _newItem;
  3574. }else{    
  3575. 5 cutText ["","PLAIN"];      
  3576.  
  3577. if(_itemFilter == "rweapon")
  3578. then{  
  3579. if(player canAdd _newItem)
  3580. then{  
  3581. player addItem _newItem;
  3582. } else {      
  3583. if(currentWeapon player == "")
  3584. then{   player addWeapon _newItem;
  3585. }else{    
  3586. 5 cutText ["","PLAIN"];
  3587.  
  3588. if(_itemFilter == "rammunition")
  3589. then{  
  3590. if(player canAdd _newItem)
  3591. then{  
  3592. player addItem _newItem;
  3593. } else {      
  3594. if(currentWeapon player == "")
  3595. then{   player addWeapon _newItem;
  3596. }else{    
  3597. 5 cutText ["","PLAIN"];
  3598.  
  3599. if(_itemFilter == "pammunition")
  3600. then{  
  3601. if(player canAdd _newItem)
  3602. then{  
  3603. player addItem _newItem;
  3604. } else {      
  3605. if(currentWeapon player == "")
  3606. then{   player addWeapon _newItem;
  3607. }else{    
  3608. 5 cutText ["","PLAIN"];      
  3609.  
  3610. if(_itemFilter == "hidden")
  3611. then{  
  3612. if(player canAdd _newItem)
  3613. then{  
  3614. player addItem _newItem;
  3615. } else {      
  3616. if(currentWeapon player == "")
  3617. then{   player addWeapon _newItem;
  3618. }else{    
  3619. 5 cutText ["","PLAIN"];
  3620.  
  3621. if(_itemFilter == "gang")
  3622. then{  
  3623. if(player canAdd _newItem)
  3624. then{  
  3625. player addItem _newItem;
  3626. } else {      
  3627. if(currentWeapon player == "")
  3628. then{   player addWeapon _newItem;
  3629. }else{    
  3630. 5 cutText ["","PLAIN"];
  3631.  
  3632. if(_itemFilter == "gangattach")
  3633. then{  
  3634. if(player canAdd _newItem)
  3635. then{  
  3636. player addItem _newItem;
  3637. } else {      
  3638. if(currentWeapon player == "")
  3639. then{   player addWeapon _newItem;
  3640. }else{    
  3641. 5 cutText ["","PLAIN"];
  3642.  
  3643.  
  3644.  
  3645.  
  3646. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {             _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  3647. [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
  3648. };        
  3649. life_is_processing = false;    
  3650. };  };
  3651. };
  3652. 5 cutText ["","PLAIN"];
  3653. titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
  3654. life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
  3655. disableSerialization;
  3656.  
  3657. //declare
  3658. _dialog = displayNull;
  3659.  
  3660. //get
  3661. _dialog = findDisplay 666;
  3662.  
  3663. //validate
  3664. if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
  3665. if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
  3666. };
  3667.  
  3668. //declare
  3669. _item = "";
  3670.  
  3671. //get
  3672. _item = lbData[669,(lbCurSel 669)];
  3673.  
  3674. //validate
  3675. if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
  3676. if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
  3677. if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
  3678.  
  3679. //output
  3680. diag_log(format["fn_craftAction:ItemData:%1", _item]);
  3681.  
  3682. _allMaterial = true;
  3683.  
  3684. //declare
  3685. _itemFilter = "item";
  3686.  
  3687. //get
  3688. _itemFilter = lbData[673,(lbCurSel 673)];
  3689.  
  3690. //validate
  3691. if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
  3692. if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
  3693. if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
  3694.  
  3695.  
  3696. //output
  3697. diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
  3698.  
  3699.  
  3700. _matsNeed = 0;
  3701. _config = [_itemFilter] call life_fnc_craftCfg;
  3702.  
  3703. //output
  3704. diag_log(format["fn_craftAction:_config:%1", _config]);
  3705.  
  3706. {
  3707.     //output
  3708.     diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
  3709.  
  3710.  
  3711.     if(_item == _x select 0) then {
  3712.          _matsNeed = _x select 1;
  3713.         _invSize = count _matsNeed;
  3714.         for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
  3715.                 _str = [_matsNeed select _i] call life_fnc_varToStr;
  3716.                 _matsNum = _matsNeed select _i+1;  
  3717.                 if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
  3718.         };
  3719.     };
  3720. } foreach (_config);
  3721.  
  3722. if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
  3723.  
  3724. //declare
  3725. _newItem = "";
  3726.  
  3727. _oldItem = _matsNeed;
  3728. _newItem = _item;
  3729.  
  3730. //Some checks
  3731. if((count _matsNeed) == 0) exitWith {};
  3732.  
  3733. _weight = nil;
  3734. if(_itemFilter == "item") then {
  3735.     _weight = ([_item] call life_fnc_itemWeight);
  3736. };
  3737. if (isNil '_weight') then {
  3738.     _weight = 0;
  3739. };
  3740.  
  3741. if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith  {   hint localize "STR_NOTF_NoRoom"; };
  3742. if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith    {  hint localize "STR_NOTF_NoRoom"; };
  3743. if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";  };
  3744. if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  3745. if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  3746. if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  3747. if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  3748. if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  3749. if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";};
  3750.  
  3751. if(_itemFilter == "item") then    {
  3752.  
  3753.     //output
  3754.     diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
  3755.  
  3756.    _itemName = [_newItem] call life_fnc_varToStr;
  3757.  
  3758.    //output
  3759.     diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
  3760.  
  3761. } else        {  
  3762.     _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
  3763.  
  3764.    //output
  3765.     diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
  3766.  
  3767.     _itemName = _itemInfo select 1;
  3768. };
  3769.  
  3770.  
  3771. _upp = format["Crafting %1",_itemName];
  3772.  
  3773. //output
  3774. diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
  3775.  
  3776. closeDialog 0;
  3777.  
  3778. //Setup our progress bar.
  3779.  
  3780. 5 cutRsc ["life_progress","PLAIN"];
  3781. _ui = uiNameSpace getVariable "life_progress";
  3782. _progress = _ui displayCtrl 38201;
  3783. _pgText = _ui displayCtrl 38202;
  3784. _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
  3785. _progress progressSetPosition 0.01;
  3786. _cP = 0.01;
  3787. _removeItemSuccess = true;
  3788. _invSize = count _oldItem;
  3789.  
  3790. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do  {
  3791.    _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  3792.     if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
  3793. };
  3794.  
  3795. if(!_removeItemSuccess) exitWith {
  3796.     5 cutText ["","PLAIN"];
  3797.     life_is_processing = false;
  3798. };
  3799.  
  3800. [] call life_fnc_p_updateMenu;
  3801.  
  3802. life_is_processing = true;
  3803.  
  3804.  while{true} do{
  3805.     sleep  0.3;
  3806.     _cP = _cP + 0.01;
  3807.     _progress progressSetPosition _cP;
  3808.     _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
  3809.     if(_cP >= 1) exitWith {};
  3810. };
  3811.  
  3812. if(_itemFilter == "backpack") then{
  3813.     if(backpack player == "") then {    
  3814.         player addBackpack _newItem;
  3815.     }else{
  3816.           hint localize "STR_CRAFT_AR_Backpack";
  3817.         life_is_processing = false;
  3818.     };
  3819. };
  3820.  
  3821. if(_itemFilter == "attachments") then {
  3822.     if(player canAdd _newItem) then {  
  3823.         player addItem _newItem;
  3824.     } else {      
  3825.         if(currentWeapon player == "") then {
  3826.             player addWeapon _newItem;
  3827.         } else {
  3828.             5 cutText ["","PLAIN"];
  3829.         };
  3830.     };
  3831. };
  3832.  
  3833.  
  3834. //output
  3835. diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
  3836.  
  3837. if(_itemFilter == "item") then {
  3838.     _handledItem = [_newItem,1]  call life_fnc_varHandle;
  3839.  
  3840.     //output
  3841.     diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
  3842.  
  3843.     [true,_handledItem,1] call life_fnc_handleInv;
  3844. };
  3845.  
  3846.  
  3847. if(_itemFilter == "pweapon")
  3848. then{  
  3849. if(player canAdd _newItem)
  3850. then{  
  3851. player addItem _newItem;
  3852. } else {      
  3853. if(currentWeapon player == "")
  3854. then{   player addWeapon _newItem;
  3855. }else{    
  3856. 5 cutText ["","PLAIN"];      
  3857.  
  3858. if(_itemFilter == "rweapon")
  3859. then{  
  3860. if(player canAdd _newItem)
  3861. then{  
  3862. player addItem _newItem;
  3863. } else {      
  3864. if(currentWeapon player == "")
  3865. then{   player addWeapon _newItem;
  3866. }else{    
  3867. 5 cutText ["","PLAIN"];
  3868.  
  3869. if(_itemFilter == "rammunition")
  3870. then{  
  3871. if(player canAdd _newItem)
  3872. then{  
  3873. player addItem _newItem;
  3874. } else {      
  3875. if(currentWeapon player == "")
  3876. then{   player addWeapon _newItem;
  3877. }else{    
  3878. 5 cutText ["","PLAIN"];
  3879.  
  3880. if(_itemFilter == "pammunition")
  3881. then{  
  3882. if(player canAdd _newItem)
  3883. then{  
  3884. player addItem _newItem;
  3885. } else {      
  3886. if(currentWeapon player == "")
  3887. then{   player addWeapon _newItem;
  3888. }else{    
  3889. 5 cutText ["","PLAIN"];      
  3890.  
  3891. if(_itemFilter == "hidden")
  3892. then{  
  3893. if(player canAdd _newItem)
  3894. then{  
  3895. player addItem _newItem;
  3896. } else {      
  3897. if(currentWeapon player == "")
  3898. then{   player addWeapon _newItem;
  3899. }else{    
  3900. 5 cutText ["","PLAIN"];
  3901.  
  3902. if(_itemFilter == "gang")
  3903. then{  
  3904. if(player canAdd _newItem)
  3905. then{  
  3906. player addItem _newItem;
  3907. } else {      
  3908. if(currentWeapon player == "")
  3909. then{   player addWeapon _newItem;
  3910. }else{    
  3911. 5 cutText ["","PLAIN"];
  3912.  
  3913. if(_itemFilter == "gangattach")
  3914. then{  
  3915. if(player canAdd _newItem)
  3916. then{  
  3917. player addItem _newItem;
  3918. } else {      
  3919. if(currentWeapon player == "")
  3920. then{   player addWeapon _newItem;
  3921. }else{    
  3922. 5 cutText ["","PLAIN"];
  3923.  
  3924.  
  3925.  
  3926.  
  3927. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {             _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  3928. [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
  3929. };        
  3930. life_is_processing = false;    
  3931. };  };
  3932. };
  3933. 5 cutText ["","PLAIN"];
  3934. titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
  3935. life_is_processing = false;private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
  3936. disableSerialization;
  3937.  
  3938. //declare
  3939. _dialog = displayNull;
  3940.  
  3941. //get
  3942. _dialog = findDisplay 666;
  3943.  
  3944. //validate
  3945. if (isNull _dialog) exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Dialog Null"); };
  3946. if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";
  3947. };
  3948.  
  3949. //declare
  3950. _item = "";
  3951.  
  3952. //get
  3953. _item = lbData[669,(lbCurSel 669)];
  3954.  
  3955. //validate
  3956. if (isNil '_item') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item Nil"); };
  3957. if (typeName _item != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:Item not string:%1",_item]); };
  3958. if (_item == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:Item empty string"); };
  3959.  
  3960. //output
  3961. diag_log(format["fn_craftAction:ItemData:%1", _item]);
  3962.  
  3963. _allMaterial = true;
  3964.  
  3965. //declare
  3966. _itemFilter = "item";
  3967.  
  3968. //get
  3969. _itemFilter = lbData[673,(lbCurSel 673)];
  3970.  
  3971. //validate
  3972. if (isNil '_itemFilter') exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter Nil"); };
  3973. if (typeName _itemFilter != typeName "plyr2") exitWith { systemChat("Error with Item Crafting..."); diag_log(format["fn_craftAction:Error:_itemFilter not string:%1",_item]); };
  3974. if (_itemFilter == "") exitWith { systemChat("Error with Item Crafting..."); diag_log("fn_craftAction:Error:_itemFilter empty string"); };
  3975.  
  3976.  
  3977. //output
  3978. diag_log(format["fn_craftAction:_itemFilter:%1", _itemFilter]);
  3979.  
  3980.  
  3981. _matsNeed = 0;
  3982. _config = [_itemFilter] call life_fnc_craftCfg;
  3983.  
  3984. //output
  3985. diag_log(format["fn_craftAction:_config:%1", _config]);
  3986.  
  3987. {
  3988.     //output
  3989.     diag_log(format["fn_craftAction:_config:%2:%1", _config, _forEachIndex]);
  3990.  
  3991.  
  3992.     if(_item == _x select 0) then {
  3993.          _matsNeed = _x select 1;
  3994.         _invSize = count _matsNeed;
  3995.         for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
  3996.                 _str = [_matsNeed select _i] call life_fnc_varToStr;
  3997.                 _matsNum = _matsNeed select _i+1;  
  3998.                 if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith { _allMaterial = false; };
  3999.         };
  4000.     };
  4001. } foreach (_config);
  4002.  
  4003. if(!_allMaterial) exitWith { hint localize "STR_PM_NoMaterial"; };
  4004.  
  4005. //declare
  4006. _newItem = "";
  4007.  
  4008. _oldItem = _matsNeed;
  4009. _newItem = _item;
  4010.  
  4011. //Some checks
  4012. if((count _matsNeed) == 0) exitWith {};
  4013.  
  4014. _weight = nil;
  4015. if(_itemFilter == "item") then {
  4016.     _weight = ([_item] call life_fnc_itemWeight);
  4017. };
  4018. if (isNil '_weight') then {
  4019.     _weight = 0;
  4020. };
  4021.  
  4022. if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith  {   hint localize "STR_NOTF_NoRoom"; };
  4023. if(_itemFilter == "pammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith    {  hint localize "STR_NOTF_NoRoom"; };
  4024. if(_itemFilter == "rammunition" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";  };
  4025. if(_itemFilter == "pweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  4026. if(_itemFilter == "rweapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  4027. if(_itemFilter == "attachments" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  4028. if(_itemFilter == "hidden" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  4029. if(_itemFilter == "gang" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom"; };
  4030. if(_itemFilter == "gangattach" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {   hint localize "STR_NOTF_NoRoom";};
  4031.  
  4032. if(_itemFilter == "item") then    {
  4033.  
  4034.     //output
  4035.     diag_log(format["fn_craftAction:_itemFilter:IsItem"]);
  4036.  
  4037.    _itemName = [_newItem] call life_fnc_varToStr;
  4038.  
  4039.    //output
  4040.     diag_log(format["fn_craftAction:_itemName:%1", _itemName]);
  4041.  
  4042. } else        {  
  4043.     _itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
  4044.  
  4045.    //output
  4046.     diag_log(format["fn_craftAction:_itemInfo:%1", _itemInfo]);
  4047.  
  4048.     _itemName = _itemInfo select 1;
  4049. };
  4050.  
  4051.  
  4052. _upp = format["Crafting %1",_itemName];
  4053.  
  4054. //output
  4055. diag_log(format["fn_craftAction:Crafting:%1", _itemName]);
  4056.  
  4057. closeDialog 0;
  4058.  
  4059. //Setup our progress bar.
  4060.  
  4061. 5 cutRsc ["life_progress","PLAIN"];
  4062. _ui = uiNameSpace getVariable "life_progress";
  4063. _progress = _ui displayCtrl 38201;
  4064. _pgText = _ui displayCtrl 38202;
  4065. _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
  4066. _progress progressSetPosition 0.01;
  4067. _cP = 0.01;
  4068. _removeItemSuccess = true;
  4069. _invSize = count _oldItem;
  4070.  
  4071. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do  {
  4072.    _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  4073.     if (!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith { _removeItemSuccess = false; };
  4074. };
  4075.  
  4076. if(!_removeItemSuccess) exitWith {
  4077.     5 cutText ["","PLAIN"];
  4078.     life_is_processing = false;
  4079. };
  4080.  
  4081. [] call life_fnc_p_updateMenu;
  4082.  
  4083. life_is_processing = true;
  4084.  
  4085.  while{true} do{
  4086.     sleep  0.3;
  4087.     _cP = _cP + 0.01;
  4088.     _progress progressSetPosition _cP;
  4089.     _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
  4090.     if(_cP >= 1) exitWith {};
  4091. };
  4092.  
  4093. if(_itemFilter == "backpack") then{
  4094.     if(backpack player == "") then {    
  4095.         player addBackpack _newItem;
  4096.     }else{
  4097.           hint localize "STR_CRAFT_AR_Backpack";
  4098.         life_is_processing = false;
  4099.     };
  4100. };
  4101.  
  4102. if(_itemFilter == "attachments") then {
  4103.     if(player canAdd _newItem) then {  
  4104.         player addItem _newItem;
  4105.     } else {      
  4106.         if(currentWeapon player == "") then {
  4107.             player addWeapon _newItem;
  4108.         } else {
  4109.             5 cutText ["","PLAIN"];
  4110.         };
  4111.     };
  4112. };
  4113.  
  4114.  
  4115. //output
  4116. diag_log(format["fn_craftAction:CheckingIfVirtalItem:_itemFilter%1", _itemFilter]);
  4117.  
  4118. if(_itemFilter == "item") then {
  4119.     _handledItem = [_newItem,1]  call life_fnc_varHandle;
  4120.  
  4121.     //output
  4122.     diag_log(format["fn_craftAction:VirtualItem:_itemFilter%1:Item:%2:HandledItem:%3", _itemFilter,_newItem,_handledItem]);
  4123.  
  4124.     [true,_handledItem,1] call life_fnc_handleInv;
  4125. };
  4126.  
  4127.  
  4128. if(_itemFilter == "pweapon") then {  
  4129.     if(player canAdd _newItem) then{  
  4130.         player addItem _newItem;
  4131.     } else {      
  4132.         if(currentWeapon player == "") then {
  4133.             player addWeapon _newItem;
  4134.          }else{    
  4135.             5 cutText ["","PLAIN"];  
  4136.          };
  4137.     };
  4138. };
  4139.  
  4140. if(_itemFilter == "rweapon")then{  
  4141.     if(player canAdd _newItem)then{  
  4142.         player addItem _newItem;
  4143.     } else {      
  4144.         if(currentWeapon player == "")then{
  4145.            player addWeapon _newItem;
  4146.         }else{    
  4147.             5 cutText ["","PLAIN"];
  4148.         };
  4149.     };
  4150. };
  4151.  
  4152. if(_itemFilter == "rammunition")then{  
  4153.     if(player canAdd _newItem)then{  
  4154.         player addItem _newItem;
  4155.     } else {      
  4156.         if(currentWeapon player == "")then{
  4157.            player addWeapon _newItem;
  4158.         }else{    
  4159.             5 cutText ["","PLAIN"];
  4160.         };
  4161.     };
  4162. };
  4163.  
  4164. if(_itemFilter == "pammunition")then{  
  4165.     if(player canAdd _newItem)then{  
  4166.         player addItem _newItem;
  4167.     } else {      
  4168.         if(currentWeapon player == "")then{
  4169.             player addWeapon _newItem;
  4170.         }else{    
  4171.             5 cutText ["","PLAIN"];      
  4172.         };
  4173.     };
  4174. };
  4175.  
  4176. if(_itemFilter == "hidden")then{  
  4177.     if(player canAdd _newItem)then{  
  4178.         player addItem _newItem;
  4179.     } else {      
  4180.         if(currentWeapon player == "")then{
  4181.             player addWeapon _newItem;
  4182.         }else{    
  4183.             5 cutText ["","PLAIN"];
  4184.         };
  4185.     };
  4186. };
  4187.  
  4188. if(_itemFilter == "gang")then{  
  4189.     if(player canAdd _newItem)then{  
  4190.         player addItem _newItem;
  4191.     } else {      
  4192.         if(currentWeapon player == "")then{
  4193.             player addWeapon _newItem;
  4194.         }else{    
  4195.             5 cutText ["","PLAIN"];
  4196.         };
  4197.     };
  4198. };
  4199.  
  4200. if(_itemFilter == "gangattach")then{  
  4201.     if(player canAdd _newItem)then{  
  4202.         player addItem _newItem;
  4203.     } else {      
  4204.         if(currentWeapon player == "")then{
  4205.             player addWeapon _newItem;
  4206.         }else{    
  4207.             5 cutText ["","PLAIN"];
  4208.         };
  4209.     };
  4210. };
  4211.  
  4212.  
  4213. for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
  4214.     _handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
  4215.     [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
  4216. };
  4217.  
  4218. life_is_processing = false;    
  4219.  
  4220. 5 cutText ["","PLAIN"];
  4221. titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
  4222. life_is_processing = false;
Advertisement
Add Comment
Please, Sign In to add comment