SHARE
TWEET

Untitled

a guest Aug 13th, 2017 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     File: fn_Blacksmith_OrderItem.sqf
  3.     Function: life_fnc_Blacksmith_OrderItem
  4.     Author: ZKB1325
  5.    
  6.     Description: Handles opening blacksmith
  7. */
  8.  
  9. private ["_selecteddata","_itemInfo","_successfulorder","_xitemvarorder","_exception","_ordercrate","_item","_itemamount","_xitemvar","_xitemamount","_itemType"];
  10. disableSerialization;
  11.  
  12. _selecteddata = call compile (_this select 0);
  13. _itemInfo = [((_selecteddata select 0) select 0)] call life_fnc_fetchCfgDetails;
  14. _successfulorder = true;
  15.  
  16. try
  17. {
  18. if ((_selecteddata select 2) > 0) then
  19.     {
  20.     if (KWEFookxWQOk < (_selecteddata select 2)) throw format ["You lack $%1 to order %2",[((_selecteddata select 2) - KWEFookxWQOk)] call life_fnc_numberText,(_itemInfo select 1)];
  21.     };
  22.    
  23. {
  24. _xitemvarorder = [(_x select 0),0] call life_fnc_varHandle;
  25. if ((missionNamespace getVariable [_xitemvarorder,0]) < (_x select 1)) throw format ["You don't have enough %1",[_xitemvarorder] call life_fnc_vartostr];
  26. }forEach (_selecteddata select 1);
  27. }
  28. catch
  29. {
  30. systemChat _exception;
  31. _successfulorder = false;
  32. };
  33.  
  34. if (_successfulorder) then
  35.     {
  36.     _item = ((_selecteddata select 0) select 0);
  37.     _itemamount = ((_selecteddata select 0) select 1);
  38.    
  39.     systemChat format ["Your order of %1x %2 will arrive in 15 Minutes",_itemamount,(_itemInfo select 1)];
  40.    
  41.     KWEFookxWQOk = KWEFookxWQOk - (_selecteddata select 2);
  42.     {
  43.     _xitemvar = [(_x select 0),0] call life_fnc_varHandle;
  44.     _xitemamount = missionNamespace getVariable [_xitemvar,0];
  45.     missionNamespace setVariable [_xitemvar,_xitemamount - (_x select 1)];
  46.     }forEach (_selecteddata select 1);
  47.    
  48.     closeDialog 0;
  49.     sleep(15*60);
  50.     //sleep 30;
  51.    
  52.     _ordercrate = Blacksmith_DeliveryPoint;
  53.    
  54.     _itemType = [_item] call BIS_fnc_itemType;
  55.  
  56.     switch (_itemType select 0) do
  57.         {
  58.         case "Weapon": {_ordercrate addWeaponCargoGlobal [_item,_itemamount];};
  59.         case "Mine";
  60.         case "Magazine": {_ordercrate addMagazineCargoGlobal [_item,_itemamount];};
  61.         case "Item": {_ordercrate addItemCargoGlobal [_item,_itemamount];};
  62.         case "Equipment": {
  63.                         if ((_itemType select 1) == "Backpack" ) then
  64.                             {
  65.                             _ordercrate addBackpackCargoGlobal [_item,_itemamount];
  66.                             }
  67.                             else
  68.                             {
  69.                             _ordercrate addItemCargoGlobal [_item,_itemamount];
  70.                             };
  71.                         };         
  72.         };
  73.        
  74.     systemChat format ["You order of %1x %2 has arrived at the delivery location",_itemamount,(_itemInfo select 1)];
  75.     };
RAW Paste Data
Top