Advertisement
Guest User

@Maddin_DQS_CC_Craft.sqf

a guest
May 27th, 2014
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.91 KB | None | 0 0
  1. private ["_args","_item","_itemRem","_cost","_magType","_magNeeded"];
  2.  
  3. if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_40") , "PLAIN DOWN"]; };
  4. DZE_ActionInProgress = true;
  5.  
  6. _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
  7. _isWater = dayz_isSwimming;
  8. _vehicle = vehicle player;
  9. _inVehicle = (_vehicle != player);
  10.  
  11. if (_isWater) exitWith {DZE_ActionInProgress = false; cutText [localize "str_player_26", "PLAIN DOWN"];};
  12. if (_inVehicle) exitWith {DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_42"), "PLAIN DOWN"];};
  13. if (_onLadder) exitWith {DZE_ActionInProgress = false; cutText [localize "str_player_21", "PLAIN DOWN"];};
  14. if (player getVariable["combattimeout", 0] >= time) exitWith {DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_43"), "PLAIN DOWN"];};
  15.  
  16. _args = _this;
  17. _req = _args select 0;
  18. _cost = _args select 1;
  19. _item = _args select 2;
  20. _itemRem = _args select 3;
  21. _objNeeded = _args select 4;
  22. _type = [_item] call DQS_fnc_getType;
  23.  
  24. // Now checking objects are near
  25. _hasObj = [_objNeeded,DQS_CC_MinDistance] call DQS_fnc_objNear;
  26. if (_hasObj > 0) exitWith {
  27. _string = ["CC_ObjCheck",_objNeeded] call DQS_CC_getString;
  28. _stringFailed = format["You cannot do this. You need %1 within %2m.",_string,DQS_CC_MinDistance];
  29. titleText [_stringFailed,"PLAIN DOWN"]; titleFadeOut DQS_UI_TitleTextFade;
  30. systemChat ("Crafting System: "+str _stringFailed+"");
  31. DZE_ActionInProgress = false;
  32. };
  33.  
  34. // Now checking we have the items
  35. _hasItem = ["ITEM",_req] call DQS_fnc_hasItem;
  36. if (_hasItem > 0) exitWith {
  37. _string = ["CC_ItemCheck",_req] call DQS_CC_getString;
  38. _stringFailed = format["You cannot do this. You need %1 in your inventory.",_string];
  39. titleText [_stringFailed,"PLAIN DOWN"]; titleFadeOut DQS_UI_TitleTextFade;
  40. systemChat ("Crafting System: "+str _stringFailed+"");
  41. DZE_ActionInProgress = false;
  42. };
  43.  
  44. // Now checking we have the consumables
  45. _hasMag = ["MAG",_cost] call DQS_fnc_hasItem;
  46. if (_hasMag > 0) exitWith {
  47. _string = ["CC_MagCheck",_cost] call DQS_CC_getString;
  48. _stringFailed = format["You cannot do this. You need %1 in your inventory.",_string];
  49. titleText [_stringFailed,"PLAIN DOWN"]; titleFadeOut DQS_UI_TitleTextFade;
  50. systemChat ("Crafting System: "+str _stringFailed+"");
  51. DZE_ActionInProgress = false;
  52. };
  53. diag_log format["DQS_CC_Craft: _type = %1 | _checks = %2 and %3",_type,_hasItem,_hasMag];
  54. if ((_hasObj < 1) && (_hasItem < 1) && (_hasMag < 1)) then {
  55. switch (_type) do
  56. {
  57. case "MAG":
  58. {
  59. player playActionNow "Medic";
  60. if (!(_itemRem == "")) then {player removeWeapon _itemRem;};
  61. r_interrupt = false;
  62. [player,_cost] call DQS_fnc_invRemove;
  63. [player,DQS_CC_CraftingSound,0,false,DQS_CC_AlertDistance] call dayz_zombieSpeak;
  64. [player,DQS_CC_AlertDistance,true,(getPosATL player)] spawn player_alertZombies;
  65. sleep 6;
  66. player addMagazine _item;
  67. _oName = getText (configFile >> "cfgMagazines" >> _item >> "displayName");
  68. titleText [format["You have crafted a %1.",_oName], "PLAIN DOWN"]; titleFadeOut DQS_UI_TitleTextFade;
  69. DZE_ActionInProgress = false;
  70. };
  71. case "WEAPON":
  72. {
  73. r_interrupt = false;
  74. player playActionNow "Medic";
  75. if (!(_itemRem == "")) then {player removeWeapon _itemRem;};
  76. [player,_cost] call DQS_fnc_invRemove;
  77. [player,DQS_CC_CraftingSound,0,false,DQS_CC_AlertDistance] call dayz_zombieSpeak;
  78. [player,DQS_CC_AlertDistance,true,(getPosATL player)] spawn player_alertZombies;
  79. sleep 6;
  80. player addWeapon _item;
  81. _oName = getText (configFile >> "cfgWeapons" >> _item >> "displayName");
  82. titleText [format["You have crafted a %1.",_oName], "PLAIN DOWN"]; titleFadeOut DQS_UI_TitleTextFade;
  83. DZE_ActionInProgress = false;
  84. };
  85. case "VEHICLE":
  86. {
  87. private ["_pos"];
  88. r_interrupt = false;
  89. player playActionNow "Medic";
  90. if (!(_itemRem == "")) then {player removeWeapon _itemRem;};
  91. [player,_cost] call DQS_fnc_invRemove;
  92. [player,DQS_CC_CraftingSound,0,false,DQS_CC_AlertDistance] call dayz_zombieSpeak;
  93. [player,DQS_CC_AlertDistance,true,(getPosATL player)] spawn player_alertZombies;
  94. sleep 6;
  95. _dir = getdir (vehicle player);
  96. _pos = getPos (vehicle player);
  97. _pos = [(_pos select 0)+4*sin(_dir),(_pos select 1)+4*cos(_dir),0];
  98. DQS_OBJ_DEPLOY = [_item,player,_pos];
  99. publicVariableServer "DQS_OBJ_DEPLOY";
  100. _oName = getText (configFile >> "cfgVehicles" >> _item >> "displayName");
  101. titleText [format["You have crafted a %1.",_oName], "PLAIN DOWN"]; titleFadeOut DQS_UI_TitleTextFade;
  102. DZE_ActionInProgress = false;
  103. };
  104. };
  105. } else {
  106. _stringFailed = format["ERROR - Please let an admin know this error code: CC_Craft FAILED Item/Mag check."];
  107. titleText [_stringFailed,"PLAIN DOWN"]; titleFadeOut DQS_UI_TitleTextFade;
  108. systemChat ("Crafting System: "+str _stringFailed+"");
  109. DZE_ActionInProgress = false;
  110. };
  111.  
  112. DZE_ActionInProgress = false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement