Advertisement
Guest User

player_build2

a guest
May 23rd, 2014
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 42.58 KB | None | 0 0
  1. /*
  2. Base Building DayZ by Daimyo
  3. */
  4. private["_authorizedUID","_allFlags","_newAttachCoords","_startingPos","_buildables","_flagradius","_okToBuild","_allowedExtendedMode","_flagNearest","_flagNearby","_requireFlag","_funcExitScript","_playerCombat","_isSimulated","_isDestructable","_townRange","_longWloop","_medWloop","_smallWloop","_inTown","_inProgress","_modDir","_startPos","_tObjectPos","_buildable","_chosenRecipe","_cnt","_cntLoop","_dialog","_buildCheck","_isInCombat","_playerCombat","_check_town","_eTool","_toolBox","_town_pos","_town_name","_closestTown","_roadAllowed","_toolsNeeded","_inBuilding","_attachCoords","_requirements","_result","_alreadyBuilt","_uidDir","_p1","_p2","_uid","_worldspace","_panelNearest2","_staticObj","_onRoad","_itemL","_itemM","_itemG","_qtyL","_qtyM","_qtyG","_cntLoop","_finished","_checkComplete","_objectTemp","_locationPlayer","_object","_id","_isOk","_text","_mags","_hasEtool","_canDo","_hasToolbox","_inVehicle","_isWater","_onLadder","_building","_medWait","_longWait","_location","_isOk","_dir","_classname","_item","_itemT","_itemS","_itemW","_qtyT","_qtyS","_qtyW","_qtyE","_qtyCr","_qtyC","_qtyB","_qtySt","_qtyDT","_itemE","_itemCr","_itemC","_itemB","_itemSt","_itemDT","_authorizedPUID","_canUseFlag"];
  5.  
  6. //Used for repositioning later
  7. builderChooses = false;
  8. buildCancel = false;
  9. if (buildReposition) then {
  10. _repoObjectPos = _this select 0;
  11. _repoObjectDirR = _this select 1;
  12. } else {
  13. _repoObjectPos = [];
  14. _repoObjectDirR = 0;
  15. };
  16.  
  17. // Location placement declarations
  18. _locationPlayer = player modeltoworld [0,0,0];
  19. _location = player modeltoworld [0,0,0]; // Used for object start location and to keep track of object position throughout
  20. _attachCoords = [0,0,0];
  21. _dir = getDir player;
  22. _building = nearestObject [player, "Building"];
  23. _staticObj = nearestObject [player, "Static"];
  24.  
  25. // Restriction Checks
  26.  
  27. _hasEtool = "ItemEtool" in weapons player;
  28. _hasToolbox = "ItemToolbox" in items player;
  29. _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
  30. _canDo = (!r_drag_sqf and !r_player_unconscious and !_onLadder); //USE!!
  31. _isWater = (surfaceIsWater _locationPlayer) or dayz_isSwimming;
  32. _inVehicle = (vehicle player != player);
  33. _isOk = [player,_building] call fnc_isInsideBuilding;
  34. _closestTown = (nearestLocations [player,["NameCityCapital","NameCity","NameVillage","Airport"],25600]) select 0;
  35. _town_name = text _closestTown;
  36. _town_pos = position _closestTown;
  37.  
  38. // Booleans Some not used, possibly use later
  39. _roadAllowed = false;
  40. _medWait = false;
  41. _longWait = false;
  42. _checkComplete = false;
  43. _finished = false;
  44. _eTool = false;
  45. _toolBox = false;
  46. _alreadyBuilt = false;
  47. _inBuilding = false;
  48. _inTown = false;
  49. _inProgress = false;
  50. _result = false;
  51. _isSimulated = false;
  52. _isDestructable = false;
  53. _requireFlag = false;
  54. _flagNearby = false;
  55. _okToBuild = false;
  56. // Strings
  57. _classname = "";
  58. _check_town = "";
  59.  
  60. // Other
  61. _flagRadius = BBFlagRadius; //Meters around flag that players can build
  62. _cntLoop = 0;
  63. _chosenRecipe = [];
  64. _requirements = [];
  65. _buildable = [];
  66. _buildables = [];
  67. _longWloop = 2;
  68. _medWloop = 1;
  69. _smallWloop = 0;
  70. _cnt = 0;
  71. _playerCombat = player;
  72.  
  73. // Function to exit script without combat activate
  74. _funcExitScript = {
  75. player removeAction attachGroundAction;
  76. player removeAction previewAction;
  77. player removeAction restablishAction;
  78. player removeAction repositionAction;
  79. player removeAction finishAction;
  80. player removeAction cancelAction;
  81. procBuild = false;
  82. if(bbCDReload == 1)then{missionNameSpace setVariable [format["%1",BBCustomDebug],true];[] spawn fnc_debug;bbCDReload=0;};//Reload Debug Monitor if it was active before
  83. _playerCombat setVariable["startcombattimer", 1, true];
  84. breakOut "exit";
  85. };
  86. // Do first checks to see if player can build before counting
  87. if (procBuild) then {cutText ["You're already building!", "PLAIN DOWN"];call _funcExitScript;};
  88. if(_isWater) then {cutText [localize "str_player_26", "PLAIN DOWN"];call _funcExitScript;};
  89. if(_onLadder) then {cutText [localize "str_player_21", "PLAIN DOWN"];call _funcExitScript;};
  90. if (_inVehicle) then {cutText ["Can't do this in vehicle", "PLAIN DOWN"];call _funcExitScript;};
  91. disableSerialization;
  92. closedialog 1;
  93. // Ashfor Fix: Did player try to drop mag and keep action active (not really needed but leave here just in case)
  94. //_item = _this;
  95. //if (_item in (magazines player) ) then { // needs };
  96. // Global variables for loop method, procBuild may not be needed if implemented in fn_selfactions.sqf
  97. if (dayz_combat == 1) then {
  98. cutText ["You're currently in combat, time reduced to 3 seconds. \nCanceling/escaping will set you back into combat", "PLAIN DOWN"];
  99. sleep 3;
  100. _playerCombat setVariable["combattimeout", 0, true];
  101. dayz_combat = 0;
  102. };
  103. r_interrupt = false;
  104. r_doLoop = true;
  105. procBuild = true;
  106. //Global build_list reference params:
  107. //[_qtyT, _qtyS, _qtyW, _qtyL, _qtyM, _qtyG], "Classname", [_attachCoords, _toolBox, _eTool, _medWait, _longWait, _inBuilding, _roadAllowed, _inTown];
  108. call gear_ui_init;
  109. // Count mags in player inventory and add to an array
  110. _mags = magazines player;
  111. if ("ItemTankTrap" in _mags) then {
  112. _qtyT = {_x == "ItemTankTrap"} count magazines player;
  113. _buildables set [count _buildables, _qtyT];
  114. _itemT = "ItemTankTrap";
  115. } else { _qtyT = 0; _buildables set [count _buildables, _qtyT]; };
  116.  
  117. if ("ItemSandbag" in _mags) then {
  118. _qtyS = {_x == "ItemSandbag"} count magazines player;
  119. _buildables set [count _buildables, _qtyS];
  120. _itemS = "ItemSandbag";
  121. } else { _qtyS = 0; _buildables set [count _buildables, _qtyS]; };
  122.  
  123. if ("ItemWire" in _mags) then {
  124. _qtyW = {_x == "ItemWire"} count magazines player;
  125. _buildables set [count _buildables, _qtyW];
  126. _itemW = "ItemWire";
  127. } else { _qtyW = 0; _buildables set [count _buildables, _qtyW]; };
  128.  
  129. if ("PartWoodPile" in _mags) then {
  130. _qtyL = {_x == "PartWoodPile"} count magazines player;
  131. _buildables set [count _buildables, _qtyL];
  132. _itemL = "PartWoodPile";
  133. } else { _qtyL = 0; _buildables set [count _buildables, _qtyL]; };
  134.  
  135. if ("PartGeneric" in _mags) then {
  136. _qtyM = {_x == "PartGeneric"} count magazines player;
  137. _buildables set [count _buildables, _qtyM];
  138. _itemM = "PartGeneric";
  139. } else { _qtyM = 0; _buildables set [count _buildables, _qtyM]; };
  140.  
  141. if ("HandGrenade_West" in _mags) then {
  142. _qtyG = {_x == "HandGrenade_West"} count magazines player;
  143. _buildables set [count _buildables, _qtyG];
  144. _itemG = "HandGrenade_West";
  145. } else { _qtyG = 0; _buildables set [count _buildables, _qtyG]; };
  146.  
  147. if ("equip_scrapelectronics" in _mags) then {
  148. _qtyE = {_x == "equip_scrapelectronics"} count magazines player;
  149. _buildables set [count _buildables, _qtyE];
  150. _itemE = "equip_scrapelectronics";
  151. } else { _qtyE = 0; _buildables set [count _buildables, _qtyE]; };
  152.  
  153. if ("equip_crate" in _mags) then {
  154. _qtyCr = {_x == "equip_crate"} count magazines player;
  155. _buildables set [count _buildables, _qtyCr];
  156. _itemCr = "equip_crate";
  157. } else { _qtyCr = 0; _buildables set [count _buildables, _qtyCr]; };
  158.  
  159. if ("ItemCamoNet" in _mags) then {
  160. _qtyC = {_x == "ItemCamoNet"} count magazines player;
  161. _buildables set [count _buildables, _qtyC];
  162. _itemC = "ItemCamoNet";
  163. } else { _qtyC = 0; _buildables set [count _buildables, _qtyC]; };
  164.  
  165. if ("equip_brick" in _mags) then {
  166. _qtyB = {_x == "equip_brick"} count magazines player;
  167. _buildables set [count _buildables, _qtyB];
  168. _itemB = "equip_brick";
  169. } else { _qtyB = 0; _buildables set [count _buildables, _qtyB]; };
  170.  
  171. if ("equip_string" in _mags) then {
  172. _qtySt = {_x == "equip_string"} count magazines player;
  173. _buildables set [count _buildables, _qtySt];
  174. _itemSt = "equip_string";
  175. } else { _qtySt = 0; _buildables set [count _buildables, _qtySt]; };
  176.  
  177. if ("equip_duct_tape" in _mags) then {
  178. _qtyDT = {_x == "equip_duct_tape"} count magazines player;
  179. _buildables set [count _buildables, _qtyDT];
  180. _itemDt = "equip_duct_tape";
  181. } else { _qtyDT = 0; _buildables set [count _buildables, _qtyDT]; };
  182.  
  183. /*-- Add another item for recipe here by changing _qtyI, "Item_Classname", and add recipe into build_list.sqf array!
  184. Dont forget to add recipe to recipelist so your players can know how to make object via recipe
  185. // if ("Item_Classname" in _mags) then {
  186. // _qtyI = {_x == "Item_Classname"} count magazines player;
  187. // _buildables set [count _buildables, _qtyI];
  188. // _itemG = "Item_Classname";
  189. // } else { _qtyI = 0; _buildables set [count _buildables, _qtyI]; };
  190. */
  191.  
  192. // Check what object is returned from global array, then return classname
  193. for "_i" from 0 to ((count allbuildables) - 1) do
  194. {
  195. _buildable = (allbuildables select _i) select _i - _i;
  196. _result = [_buildables,_buildable] call BIS_fnc_areEqual;
  197. if (_result) then {
  198. _classname = (allbuildables select _i) select _i - _i + 1;
  199. _requirements = (allbuildables select _i) select _i - _i + 2;
  200. _chosenRecipe = _buildable;
  201. };
  202. _buildable = [];
  203. };
  204. // Quit here if no proper recipe is acquired else set names properly
  205. if (_classname == "") then {cutText ["You need the EXACT amount of whatever you are trying to build without extras.", "PLAIN DOWN"];call _funcExitScript;};
  206. if (_classname == "Grave") then {_text = "Booby Trap";};
  207. if (_classname == "Concrete_Wall_EP1") then {_text = "Gate Concrete Wall";};
  208. if (_classname == "Infostand_2_EP1") then {_text = "Gate Panel Keypad Access";};
  209. if (_classname == BBTypeOfZShield) then {_text = "Zombie Shield Generator";};
  210. if (_classname != "Infostand_2_EP1" &&
  211. _classname != "Concrete_Wall_EP1" &&
  212. _classname != "Grave" &&
  213. _classname != BBTypeOfZShield) then {
  214. //_text = _classname;
  215. _text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
  216. };
  217. _buildable = [];
  218.  
  219. //Get Requirements from build_list.sqf global array [_attachCoords, _startPos, _modDir, _toolBox, _eTool, _medWait, _longWait, _inBuilding, _roadAllowed, _inTown];
  220. _attachCoords = _requirements select 0;
  221. _startPos = _requirements select 1;
  222. _modDir = _requirements select 2;
  223. _toolBox = _requirements select 3;
  224. _eTool = _requirements select 4;
  225. _medWait = _requirements select 5;
  226. _longWait = _requirements select 6;
  227. _inBuilding = _requirements select 7;
  228. _roadAllowed = _requirements select 8;
  229. _inTown = _requirements select 9;
  230. _isSimulated = _requirements select 12;
  231. _isDestrutable = _requirements select 13;
  232. _requireFlag = _requirements select 14;
  233. // Get _startPos for object
  234. _location = player modeltoworld _startPos;
  235. //Set flag radius for zombie shield generator, reduce by generator radius to avoid players building them on the edge of their flag radius
  236. if (BBZShieldDis == 1 && _classname == BBTypeOfZShield) then {_flagRadius = _flagRadius-BBZShieldRadius};
  237. //Make sure player isn't registered on more than allowed number of flags
  238. if (_classname == BBTypeOfFlag) then {
  239. _allFlags = nearestObjects [player, [BBTypeOfFlag], 25000];
  240. _flagcount = 0;
  241. _flagMarkerArr = [];
  242. {
  243. if (typeOf(_x) == BBTypeOfFlag) then {
  244. _authorizedUID = _x getVariable ["AuthorizedUID", []];
  245. _authorizedPUID = _authorizedUID select 1;
  246. if ((getPlayerUid player) in _authorizedPUID && (_classname == BBTypeOfFlag)) then {
  247. _flagcount = _flagcount + 1;
  248. _flagname = format ["Flag_%1",_x];
  249. _flagMarker = createMarkerLocal [_flagName,position _x];
  250. _flagMarker setMarkerTypeLocal "Town";
  251. _flagMarker setMarkerColorLocal("ColorGreen");
  252. _flagMarker setMarkerTextLocal format ["%1's Flag", (name player)];
  253. _flagMarkerArr = _flagMarkerArr + [_flagMarker];
  254. if (_flagcount >= BBMaxPlayerFlags) then {
  255. cutText [format["Your playerUID is already registered to %1 flagpoles, you can only be added on upto %1 flag poles. Check Map for temporary flag markers, 10 seconds!\nBuild canceled for %2",BBMaxPlayerFlags,_text], "PLAIN DOWN"];
  256. sleep 10;
  257. {
  258. deleteMarkerLocal _x
  259. } forEach _flagMarkerArr;
  260. call _funcExitScript;
  261. };
  262. };
  263. };
  264. } foreach _allFlags;
  265. {
  266. deleteMarkerLocal _x
  267. } forEach _flagMarkerArr;
  268. };
  269. //Special check for zombie shields
  270. if (_classname == BBTypeOfZShield) then {
  271. _allShields = nearestObjects [player, [BBTypeOfZShield], 25000];
  272. _shieldCount = 0;
  273. {
  274. if (typeOf(_x) == BBTypeOfZShield) then {
  275. _authorizedUID = _x getVariable ["AuthorizedUID", []];
  276. _authorizedPUID = _authorizedUID select 1;
  277. if ((getPlayerUID player) in _authorizedPUID && (_classname == BBTypeOfZShield)) then {
  278. _shieldCount = _shieldCount + 1;
  279. if (_shieldCount >= BBMaxZShields) then {
  280. cutText [format["Your playerUID is already registered to %1 zombie shield generators, you can only be added on upto %1 zombie shield generators.\nBuild canceled for %2",BBMaxZShields,_text], "PLAIN DOWN"];
  281. sleep 1;
  282. call _funcExitScript;
  283. };
  284. };
  285. };
  286. } forEach _allShields;
  287. };
  288.  
  289. //Don't allow players to build in other's bases
  290. if (_classname != "Grave" && _classname != BBTypeOfFlag) then {
  291. _allFlags = nearestObjects [player, [BBTypeOfFlag], 25000];
  292. if (count _allFlags <= 0) then {
  293. _flagNearby = false;
  294. _okToBuild = false;
  295. if (!_okToBuild && _requireFlag && !_flagNearby) then {cutText [format["Either no flag is within %1 meters or you have not built a flag pole and claimed your land.\nBuild canceled for %2",_flagRadius, _text], "PLAIN DOWN"];call _funcExitScript;};
  296. };
  297. {
  298. if (typeOf(_x) == BBTypeOfFlag) then {
  299. _authorizedUID = _x getVariable ["AuthorizedUID", []];
  300. _authorizedPUID = _authorizedUID select 1;
  301. if ((getPlayerUid player) in _authorizedPUID && _x distance player <= _flagRadius) then {
  302. _flagNearby = true;
  303. _okToBuild = true;
  304. } else { //TEST THIS
  305. _flagNearby = false;
  306. _okToBuild = false;
  307. };
  308. };
  309. if (_okToBuild) exitWith {};
  310. if (!_okToBuild && (!_requireFlag || _requireFlag) && _x distance player <= _flagRadius) then {cutText [format["Build canceled for %1\nCannot build in other player's bases, only Booby traps are allowed.",_text], "PLAIN DOWN"];call _funcExitScript;};
  311. if (!_okToBuild && _requireFlag && !_flagNearby) then {cutText [format["Either no flag is within %1 meters or you have not built a flag pole and claimed your land.\nBuild canceled for %2",_flagRadius, _text], "PLAIN DOWN"];call _funcExitScript;};
  312. } foreach _allFlags;
  313. };
  314.  
  315. if (_toolBox) then {
  316. if (!_hasToolbox) then {cutText [format["You need a tool box to build %1",_text], "PLAIN DOWN"];call _funcExitScript; };
  317. };
  318. if (_eTool) then {
  319. if (!_hasEtool) then {cutText [format["You need an entrenching tool to build %1",_text], "PLAIN DOWN"];call _funcExitScript; };
  320. };
  321. if (!_inBuilding) then {
  322. if (_isOk) then {cutText [format["%1 cannot be built inside of buildings!",_text], "PLAIN DOWN"];call _funcExitScript; };
  323. };
  324. if (!_roadAllowed) then { // Do another check for object being on road
  325. _onRoad = isOnRoad _locationPlayer;
  326. if(_onRoad) then {cutText [format["You cannot build %1 on the road",_text], "PLAIN DOWN"];call _funcExitScript;};
  327. };
  328. if (!_inTown) then {
  329. for "_i" from 0 to ((count allbuild_notowns) - 1) do
  330. {
  331. _check_town = (allbuild_notowns select _i) select _i - _i;
  332. if (_town_name == _check_town) then {
  333. _townRange = (allbuild_notowns select _i) select _i - _i + 1;
  334. if (_locationPlayer distance _town_pos <= _townRange) then {
  335. cutText [format["You cannot build %1 within %2 meters of area %3",_text, _townRange, _town_name], "PLAIN DOWN"];call _funcExitScript;
  336. };
  337. };
  338. };
  339. };
  340.  
  341. //Check to make sure not building flag too near another base
  342. _flagNearest = nearestObjects [player, [BBTypeOfFlag], (_flagRadius * 2)];
  343. if (_classname == BBTypeOfFlag && (count _flagNearest > 0)) then {cutText [format["Only 1 flagpole per base in a %1 meter radius! Remember, this includes the other base's build radius as well.",(_flagRadius * 2)], "PLAIN DOWN"];call _funcExitScript;};
  344.  
  345. // Begin building process
  346. _buildCheck = false;
  347. buildReady = false;
  348. player allowdamage false;
  349. if (buildReposition) then {
  350. _object = createVehicle [_classname, _repoObjectPos, [], 0, "NONE"]; //Restore previous position if repositioning
  351. _repoObjectPos = [];
  352. if (_classname != "grave") then {
  353. _object setVariable ["characterID",dayz_characterID,true]; //Do this to prevent loot spawning during build process but not for bombs
  354. };
  355. } else {
  356. _object = createVehicle [_classname, _location, [], 0, "NONE"];
  357. _object setDir (getDir player);
  358. if (_classname != "grave") then {
  359. _object setVariable ["characterID",dayz_characterID,true]; //DO this to prevent loot spawning during build process but not for bombs
  360. } else {
  361. objectHeight=0;
  362. objectDistance=0;
  363. objectParallelDistance=0;
  364. };
  365. };
  366. if (_modDir > 0) then {
  367. _object setDir (getDir player) + _modDir;
  368. };
  369. _allowedExtendedMode = (typeOf(_object) in allExtendables);
  370. _allBuildables = (typeof(_object) in allbuildables_class);
  371. player removeAction attachGroundAction;
  372. player removeAction previewAction;
  373. player removeAction restablishAction;
  374. player removeAction repositionAction;
  375. player removeAction finishAction;
  376. player removeAction cancelAction;
  377.  
  378. if(_allBuildables)then {
  379. previewAction = player addAction ["Preview (do this to complete)!", "dayz_code\actions\buildActions\previewBuild.sqf",_object, 6, true, true, "", ""];
  380. restablishAction = player addAction ["Restablish", "dayz_code\actions\buildActions\restablishObject.sqf",_object, 6, true, true, "", ""];
  381. attachGroundAction = player addAction ["Attach to ground", "dayz_code\actions\buildActions\attachGroundObject.sqf",_object, 6, true, true, "", ""];
  382. };
  383. if (buildReposition) then {
  384. rotateDir = _repoObjectDirR; //Restore previous rotation direction if repositioning
  385. _repoObjectDirR = 0;
  386. buildReposition = false;
  387. } else {
  388. rotateDir = _modDir;
  389. };
  390. player allowdamage true;
  391. hint "";
  392. //_startingPos = getPos player; // used to restrict distance of build
  393. while {!buildReady} do {
  394. bbCDebug = missionNameSpace getVariable [format["%1",BBCustomDebug],false];
  395. if (bbCDebug) then {missionNameSpace setVariable [format["%1",BBCustomDebug],false]; hintSilent ""; bbCDReload = 1;};
  396. if (_allowedExtendedMode) then {
  397. //Lets make a nice hint window to tell people the controls
  398. hintsilent parseText format ["
  399. <t align='center' color='#0074E8'>Build process started</t><br/>
  400. <t align='center' color='#0074E8'>Move around to re-position</t><br/><br/>
  401. <t align='left' color='#F5CF36'>Controls</t> <t align='right' color='#F5CF36'>NumPad</t><br/>
  402. <t align='left' color='#85E67E'>Rotate</t> <t align='right' color='#E7F5E6'>7 + 9</t><br/>
  403. <t align='left' color='#85E67E'>Push/Pull</t> <t align='right' color='#E7F5E6'>4 + 1</t><br/>
  404. <t align='left' color='#85E67E'>Left/Right</t> <t align='right' color='#E7F5E6'>2 + 3</t><br/>
  405. <t align='left' color='#85E67E'>Elevate/Lower</t> <t align='right' color='#E7F5E6'>8 + 5</t><br/>
  406. <t align='center' color='#F5CF36'>You can hold SHIFT for slower rotation/elevation</t><br/><br/>
  407. <t align='center' color='#85E67E'>Select 'Preview' when ready</t><br/>
  408. "];
  409. } else {
  410. if (_classname != "Grave") then {
  411. //Non extendables can't be elevated/lowered so we need a slightly different list
  412. hintsilent parseText format ["
  413. <t align='center' color='#0074E8'>Build process started</t><br/>
  414. <t align='center' color='#0074E8'>Move around to re-position</t><br/><br/>
  415. <t align='left' color='#F5CF36'>Controls</t> <t align='right' color='#F5CF36'>NumPad</t><br/>
  416. <t align='left' color='#85E67E'>Rotate</t> <t align='right' color='#E7F5E6'>7 + 9</t><br/>
  417. <t align='left' color='#85E67E'>Push/Pull</t> <t align='right' color='#E7F5E6'>4 + 1</t><br/>
  418. <t align='left' color='#85E67E'>Left/Right</t> <t align='right' color='#E7F5E6'>2 + 3</t><br/>
  419. <t align='center' color='#F5CF36'>You can hold SHIFT for slower rotation</t><br/><br/>
  420. <t align='center' color='#85E67E'>Select 'Preview' when ready</t><br/>
  421. "];
  422. } else {
  423. //We don't want graves to have push/pull, or left/right
  424. hintsilent parseText format ["
  425. <t align='center' color='#0074E8'>Build process started</t><br/>
  426. <t align='center' color='#0074E8'>Move around to re-position</t><br/>
  427. <t align='center' color='#0074E8'>If grave is floating, use 'Attach to Ground' option</t><br/><br/>
  428. <t align='left' color='#F5CF36'>Controls</t> <t align='right' color='#F5CF36'>NumPad</t><br/>
  429. <t align='left' color='#85E67E'>Rotate</t> <t align='right' color='#E7F5E6'>7 + 9</t><br/>
  430. <t align='center' color='#F5CF36'>You can hold SHIFT for slower rotation</t><br/><br/>
  431. <t align='center' color='#85E67E'>Select 'Preview' when ready</t><br/>
  432. "];
  433. };
  434. };
  435. if(_allBuildables) then {
  436. //Rotations + Push Pull + Move Left or Right set to keys
  437. //Rotate Left
  438. if (DZ_BB_Rl) then {
  439. DZ_BB_Rl = false;
  440. rotateDir = rotateDir - rotateIncrement;
  441. if(rotateDir >= 360) then {
  442. rotateDir = 0;
  443. };
  444. _object setDir (getDir player) + rotateDir ;
  445. };
  446. //Rotate Right
  447. if (DZ_BB_Rr) then {
  448. DZ_BB_Rr = false;
  449. rotateDir = rotateDir + rotateIncrement;
  450. if(rotateDir >= 360) then {
  451. rotateDir = 0;
  452. };
  453. _object setDir (getDir player) + rotateDir ;
  454. };
  455. //Rotate Left Small
  456. if (DZ_BB_Rls) then {
  457. DZ_BB_Rls = false;
  458. rotateDir = rotateDir - rotateIncrementSmall;
  459. if(rotateDir >= 360) then {
  460. rotateDir = 0;
  461. };
  462. _object setDir (getDir player) + rotateDir ;
  463. };
  464. //Rotate Right Small
  465. if (DZ_BB_Rrs) then {
  466. DZ_BB_Rrs = false;
  467. rotateDir = rotateDir + rotateIncrementSmall;
  468. if(rotateDir >= 360) then {
  469. rotateDir = 0;
  470. };
  471. _object setDir (getDir player) + rotateDir ;
  472. };
  473. if (_classname != "Grave") then {
  474. //Push Away
  475. if (DZ_BB_A) then {
  476. DZ_BB_A = false;
  477. if(objectDistance<maxObjectDistance) then {
  478. objectDistance= objectDistance + 0.5;
  479. };
  480. };
  481. //Pull Near
  482. if (DZ_BB_N) then {
  483. DZ_BB_N = false;
  484. if(objectDistance>minObjectDistance) then {
  485. objectDistance= objectDistance - 0.3;
  486. };
  487. };
  488. //Move Right
  489. if (DZ_BB_Le) then {
  490. DZ_BB_Le = false;
  491. if(objectParallelDistance>minObjectDistance) then {
  492. objectParallelDistance= objectParallelDistance - 0.5;
  493. };
  494. };
  495. //Move Left
  496. if (DZ_BB_Ri) then {
  497. DZ_BB_Ri = false;
  498. if(objectParallelDistance<maxObjectDistance) then {
  499. objectParallelDistance= objectParallelDistance + 0.5;
  500. };
  501. };
  502. };
  503. };
  504. if (_allowedExtendedMode) then {
  505. //Additional keybinds for lifing + lowering only to be used with extended build objects
  506. //Elevate
  507. if (DZ_BB_E) then {
  508. DZ_BB_E = false;
  509. if(objectHeight<objectTopHeight) then {
  510. objectHeight= objectHeight + objectIncrement;
  511. };
  512. };
  513. //Lower
  514. if (DZ_BB_L) then {
  515. DZ_BB_L = false;
  516. if(objectHeight>objectLowHeight) then {
  517. objectHeight= objectHeight - objectIncrement;
  518. };
  519. };
  520. //Elevate Small
  521. if (DZ_BB_Es) then {
  522. DZ_BB_Es = false;
  523. if(objectHeight<objectTopHeight) then {
  524. objectHeight= objectHeight + objectIncrementSmall;
  525. };
  526. };
  527. //Lower Small
  528. if (DZ_BB_Ls) then {
  529. DZ_BB_Ls = false;
  530. if(objectHeight>objectLowHeight) then {
  531. objectHeight= objectHeight - objectIncrementSmall;
  532. };
  533. };
  534. };
  535.  
  536. _playerCombat = player;
  537. _isInCombat = _playerCombat getVariable["startcombattimer",0];
  538. _dialog = findDisplay 106;
  539. //This section handles the placement where you can change position etc
  540. if ((speed player <= 12) && (speed player >= -9)) then {
  541. _newAttachCoords = [];
  542. _newAttachCoords = [(objectParallelDistance+(_attachCoords select 0)),(objectDistance + (_attachCoords select 1)),(objectHeight + (_attachCoords select 2))];
  543. _object attachto [player, _newAttachCoords];
  544. _object setDir (getDir player) + rotateDir;
  545. };
  546.  
  547. //Make sure players don't move into another players base, or outside their own flag radius
  548. if (_classname != "Grave" && _classname != BBTypeOfFlag) then {
  549. _allFlags = nearestObjects [player, [BBTypeOfFlag], 25000];
  550. {
  551. if (typeOf(_x) == BBTypeOfFlag) then {
  552. _authorizedUID = _x getVariable ["AuthorizedUID", []];
  553. _authorizedPUID = _authorizedUID select 1;
  554. if ((getPlayerUid player) in _authorizedPUID && _x distance player <= _flagRadius && _x distance _object <= _flagRadius) then {
  555. _flagNearby = true;
  556. _okToBuild = true;
  557. } else {
  558. _flagNearby = false;
  559. _okToBuild = false;
  560. };
  561. };
  562. if (_okToBuild) exitWIth {};
  563. if (!_okToBuild && !_flagNearby) then {cutText [format["Build canceled for %1\nYou and the Object need to stay within %2 meters of your flag to build.",_text, _flagRadius], "PLAIN DOWN"];hint "";detach _object;deletevehicle _object;call _funcExitScript;};
  564. } foreach _allFlags;
  565. };
  566. //Check to make sure not building flag too near another base
  567. _flagNearest = nearestObjects [player, [BBTypeOfFlag], (_flagRadius * 2)];
  568. if (_classname == BBTypeOfFlag && (count _flagNearest > 1)) then {cutText [format["Only 1 flagpole per base in a %1 meter radius! Remember, this includes the other base's build radius as well.",(_flagRadius * 2)], "PLAIN DOWN"];hint "";detach _object;deletevehicle _object;call _funcExitScript;};
  569.  
  570. // Cancel build if rules broken
  571. if ((!(isNull _dialog) || (speed player >= 12 || speed player <= -9) || _isInCombat > 0) && (isPlayer _playerCombat) ) then {
  572. detach _object;
  573. deletevehicle _object;
  574. cutText [format["Build canceled for %1. Player moving too fast, in combat, or opened gear.",_text], "PLAIN DOWN"];hint "";call _funcExitScript;
  575. };
  576. sleep 0.03;
  577. };
  578.  
  579. //This section triggers when you select preview
  580. if (buildReady) then {
  581. _objectDir = getDir _object;
  582. detach _object;
  583. _objectPos = getPosATL _object;
  584. deletevehicle _object;
  585. _object = createVehicle [_classname, _objectPos, [], 0, "CAN_COLLIDE"];
  586. _object setDir _objectDir;
  587. if (_classname != "grave") then {
  588. _object setVariable ["characterID",dayz_characterID,true]; //Do this to prevent loot spawning during build process but not for bombs
  589. };
  590. buildReady=false;
  591. _location = _objectPos;//getposATL _object;
  592. _dir = _objectDir;//getDir _object;
  593. if (!(_allowedExtendedMode)) then {//Handle only non extendables
  594. _object setpos [(getposATL _object select 0),(getposATL _object select 1), if (typeOf(_object) == "Grave") then {-0.12}else{0}]; //Sets non extendables to follow land contours, tells graves to sink slightly into the ground
  595. };
  596. /*******************************************This Section Handles Objects Which Move Excessively During the Build Process***********************************************/
  597. /*******************************If added build objects move excessively, you can add a condition for them here and adjust as needed!***********************************/
  598. if (typeOf(_object) == "Land_sara_hasic_zbroj") then {
  599. _object setPosATL [((getPosATL _object select 0)+5.5),((getPosATL _object select 1)-1),(getPosATL _object select 2)];
  600. };
  601. if (typeOf(_object) == "Fence_Ind_long") then {
  602. _object setPosATL [((getPosATL _object select 0)-3.5),((getPosATL _object select 1)-0),(getPosATL _object select 2)];
  603. };
  604. if (typeOf(_object) == "Fort_RazorWire" || typeOf(_object) == "Land_Shed_wooden") then {
  605. _object setPosATL [((getPosATL _object select 0)-1.5),((getPosATL _object select 1)-0.5),(getPosATL _object select 2)];
  606. };
  607. if (typeOf(_object) == "Land_vez") then {
  608. _object setPosATL [((getPosATL _object select 0)-3.5),((getPosATL _object select 1)+1.5),(getPosATL _object select 2)];
  609. };
  610. if (typeOf(_object) == "Land_Misc_Scaffolding") then {
  611. _object setPosATL [((getPosATL _object select 0)-0.5),((getPosATL _object select 1)+3),(getPosATL _object select 2)];
  612. };
  613. /**************************************************************End of Excessive Movement Section***********************************************************************/
  614. cutText [format["AFTER RESTART: This is how the %1 object will look.\nYou can reposition the object, or complete the build.",_text], "PLAIN DOWN"];
  615. finishAction = player addAction ["Finish Build", "dayz_code\actions\buildActions\finishBuild.sqf", "", 6, true, true, "", ""];
  616. repositionAction = player addAction ["Reposition", "dayz_code\actions\buildActions\repositionObject.sqf", [_object,_objectPos,rotateDir], 6, true, true, "", ""];
  617. cancelAction = player addAction ["Cancel Build", "dayz_code\actions\buildActions\cancelBuild.sqf", [_object,_text], 6, true, true, "", ""];
  618. waitUntil {builderChooses}; //Let player decide if they want to reposition, or build as is.
  619. if (buildReposition || buildCancel) then {
  620. call _funcExitScript
  621. };
  622. } else {cutText [format["Build canceled for %1. Something went wrong!",_text], "PLAIN DOWN"];hint "";call _funcExitScript;};
  623.  
  624. // Begin Building
  625. //Do quick check to see if player is not playing nice after placing object
  626. _locationPlayer = player modeltoworld [0,0,0];
  627. _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
  628. _canDo = (!r_drag_sqf and !r_player_unconscious and !_onLadder); //USE!!
  629. _isWater = (surfaceIsWater _locationPlayer) or dayz_isSwimming;
  630. _inVehicle = (vehicle player != player);
  631. _isOk = [player,_building] call fnc_isInsideBuilding;
  632. if (!_inBuilding) then {
  633. if (_isOk) then {deletevehicle _object; cutText [format["%1 cannot be built inside of buildings!",_text], "PLAIN DOWN"];call _funcExitScript; };
  634. };
  635. // Did player walk object into restricted town?
  636. _closestTown = (nearestLocations [player,["NameCityCapital","NameCity","NameVillage"],25600]) select 0;
  637. _town_name = text _closestTown;
  638. _town_pos = position _closestTown;
  639. if (!_inTown) then {
  640. for "_i" from 0 to ((count allbuild_notowns) - 1) do
  641. {
  642. _check_town = (allbuild_notowns select _i) select _i - _i;
  643. if (_town_name == _check_town) then {
  644. _townRange = (allbuild_notowns select _i) select _i - _i + 1;
  645. if (_locationPlayer distance _town_pos <= _townRange || _object distance _town_pos <= _townRange) then {
  646. deletevehicle _object; cutText [format["You cannot build %1 within %2 meters of area %3",_text, _townRange, _town_name], "PLAIN DOWN"];call _funcExitScript;
  647. };
  648. if (_classname == BBTypeOfFlag) then {
  649. if (_object distance _town_pos <= (_townRange + _flagRadius)) then {
  650. deletevehicle _object; cutText [format["You cannot build %1 within %2 meters of area %3\nWhen building a %1, you must consider the %4 meter radius around the %1 conflicting with town radius of %5 meters",_text, (_townRange + _flagRadius), _town_name, _flagRadius, _townRange], "PLAIN DOWN"];call _funcExitScript;
  651. };
  652. };
  653. };
  654. };
  655. };
  656.  
  657. r_interrupt = false;
  658. r_doLoop = true;
  659. _cntLoop = 0;
  660. //Physically begin building
  661. switch (true) do
  662. {
  663. case(_longWait):
  664. {
  665. _cnt = _longWloop;
  666. _cnt = _cnt * 10;
  667. for "_i" from 0 to _longWloop do
  668. {
  669. cutText [format["Building %1. %2 seconds left.\nMove from current position to cancel",_text,_cnt + 10], "PLAIN DOWN"];
  670. if (player distance _locationPlayer > 1) then {deletevehicle _object; cutText [format["Build canceled for %1, position of player moved",_text], "PLAIN DOWN"];hint "";call _funcExitScript;};
  671. if (!_canDo || _onLadder || _inVehicle || _isWater) then {deletevehicle _object; cutText [format["Build canceled for %1, player is unable to continue",_text], "PLAIN DOWN"];hint "";call _funcExitScript;};
  672. sleep 1;
  673. [player,"repair",0,false] call dayz_zombieSpeak;
  674. _id = [player,50,true,(getPosATL player)] spawn player_alertZombies;
  675. //DayZ interrupt feature like when canceling bandaging
  676. while {r_doLoop} do {
  677. player playActionNow "Medic"; //Moved here so the animation plays during the entire build process
  678. if (r_interrupt) then {
  679. r_doLoop = false;
  680. };
  681. if (_cntLoop >= 80) then {
  682. r_doLoop = false;
  683. _finished = true;
  684. };
  685. sleep .1;
  686. _cntLoop = _cntLoop + 1;
  687. };
  688. if (r_interrupt) then {
  689. deletevehicle _object;
  690. [objNull, player, rSwitchMove,""] call RE;
  691. player playActionNow "stop";
  692. cutText [format["Build canceled for %1, position of player moved",_text], "PLAIN DOWN"];
  693. procBuild = false;_playerCombat setVariable["startcombattimer", 1, true];
  694. breakOut "exit";
  695. };
  696. r_doLoop = true;
  697. _cntLoop = 0;
  698. _cnt = _cnt - 10;
  699. };
  700. sleep 1.5;
  701. };
  702. case(_medWait):
  703. {
  704. _cnt = _medWloop;
  705. _cnt = _cnt * 10;
  706. for "_i" from 0 to _medWloop do
  707. {
  708. cutText [format["Building %1. %2 seconds left.\nMove from current position to cancel",_text,_cnt + 10], "PLAIN DOWN"];
  709. if (player distance _locationPlayer > 1) then {deletevehicle _object; cutText [format["Build canceled for %1, position of player moved",_text], "PLAIN DOWN"];hint "";call _funcExitScript;};
  710. if (!_canDo || _onLadder || _inVehicle || _isWater) then {deletevehicle _object; cutText [format["Build canceled for %1, player is unable to continue",_text], "PLAIN DOWN"];hint "";call _funcExitScript;};
  711. sleep 1;
  712. [player,"repair",0,false] call dayz_zombieSpeak;
  713. _id = [player,50,true,(getPosATL player)] spawn player_alertZombies;
  714. while {r_doLoop} do {
  715. player playActionNow "Medic"; //Moved here so the animation plays during the entire build process
  716. if (r_interrupt) then {
  717. r_doLoop = false;
  718. };
  719. if (_cntLoop >= 80) then {
  720. r_doLoop = false;
  721. _finished = true;
  722. };
  723. sleep .1;
  724. _cntLoop = _cntLoop + 1;
  725. };
  726. if (r_interrupt) then {
  727. deletevehicle _object;
  728. [objNull, player, rSwitchMove,""] call RE;
  729. player playActionNow "stop";
  730. cutText [format["Build canceled for %1, position of player moved",_text], "PLAIN DOWN"];
  731. procBuild = false;_playerCombat setVariable["startcombattimer", 1, true];
  732. breakOut "exit";
  733. };
  734. r_doLoop = true;
  735. _cntLoop = 0;
  736. _cnt = _cnt - 10;
  737. };
  738. sleep 1.5;
  739. };
  740. case(!_medWait && !_longWait):
  741. {
  742. _cnt = _smallWloop;
  743. _cnt = _cnt * 10;
  744. for "_i" from 0 to _smallWloop do
  745. {
  746. cutText [format["Building %1. %2 seconds left.\nMove from current position to cancel",_text,_cnt + 10], "PLAIN DOWN"];
  747. if (player distance _locationPlayer > 1) then {deletevehicle _object; cutText [format["Build canceled for %1, position of player moved",_text], "PLAIN DOWN"];hint "";call _funcExitScript;};
  748. if (!_canDo || _onLadder || _inVehicle || _isWater) then {deletevehicle _object; cutText [format["Build canceled for %1, player is unable to continue",_text], "PLAIN DOWN"];hint "";call _funcExitScript;};
  749. sleep 1;
  750. [player,"repair",0,false] call dayz_zombieSpeak;
  751. _id = [player,50,true,(getPosATL player)] spawn player_alertZombies;
  752. while {r_doLoop} do {
  753. player playActionNow "Medic"; //Moved here so the animation plays during the entire build process
  754. if (r_interrupt) then {
  755. r_doLoop = false;
  756. };
  757. if (_cntLoop >= 80) then {
  758. r_doLoop = false;
  759. _finished = true;
  760. };
  761. sleep .1;
  762. _cntLoop = _cntLoop + 1;
  763. };
  764. if (r_interrupt) then {
  765. deletevehicle _object;
  766. [objNull, player, rSwitchMove,""] call RE;
  767. player playActionNow "stop";
  768. cutText [format["Build canceled for %1, position of player moved",_text], "PLAIN DOWN"];
  769. procBuild = false;_playerCombat setVariable["startcombattimer", 1, true];
  770. breakOut "exit";
  771. };
  772. r_doLoop = true;
  773. _cntLoop = 0;
  774. _cnt = _cnt - 10;
  775. };
  776. sleep 1.5;
  777. };
  778. };
  779.  
  780. // Do last check to see if player attempted to remove buildables
  781. _mags = magazines player;
  782. _buildables = []; // reset original buildables
  783. if ("ItemTankTrap" in _mags) then {
  784. _qtyT = {_x == "ItemTankTrap"} count magazines player;
  785. _buildables set [count _buildables, _qtyT];
  786. } else { _qtyT = 0; _buildables set [count _buildables, _qtyT]; };
  787.  
  788. if ("ItemSandbag" in _mags) then {
  789. _qtyS = {_x == "ItemSandbag"} count magazines player;
  790. _buildables set [count _buildables, _qtyS];
  791. } else { _qtyS = 0; _buildables set [count _buildables, _qtyS]; };
  792.  
  793. if ("ItemWire" in _mags) then {
  794. _qtyW = {_x == "ItemWire"} count magazines player;
  795. _buildables set [count _buildables, _qtyW];
  796. } else { _qtyW = 0; _buildables set [count _buildables, _qtyW]; };
  797.  
  798. if ("PartWoodPile" in _mags) then {
  799. _qtyL = {_x == "PartWoodPile"} count magazines player;
  800. _buildables set [count _buildables, _qtyL];
  801. } else { _qtyL = 0; _buildables set [count _buildables, _qtyL]; };
  802.  
  803. if ("PartGeneric" in _mags) then {
  804. _qtyM = {_x == "PartGeneric"} count magazines player;
  805. _buildables set [count _buildables, _qtyM];
  806. } else { _qtyM = 0; _buildables set [count _buildables, _qtyM]; };
  807.  
  808. if ("HandGrenade_West" in _mags) then {
  809. _qtyG = {_x == "HandGrenade_West"} count magazines player;
  810. _buildables set [count _buildables, _qtyG];
  811. } else { _qtyG = 0; _buildables set [count _buildables, _qtyG]; };
  812.  
  813. if ("equip_scrapelectronics" in _mags) then {
  814. _qtyE = {_x == "equip_scrapelectronics"} count magazines player;
  815. _buildables set [count _buildables, _qtyE];
  816. } else { _qtyE = 0; _buildables set [count _buildables, _qtyE]; };
  817.  
  818. if ("equip_crate" in _mags) then {
  819. _qtyCr = {_x == "equip_crate"} count magazines player;
  820. _buildables set [count _buildables, _qtyCr];
  821. } else { _qtyCr = 0; _buildables set [count _buildables, _qtyCr]; };
  822.  
  823. if ("ItemCamoNet" in _mags) then {
  824. _qtyC = {_x == "ItemCamoNet"} count magazines player;
  825. _buildables set [count _buildables, _qtyC];
  826. } else { _qtyC = 0; _buildables set [count _buildables, _qtyC]; };
  827.  
  828. if ("equip_brick" in _mags) then {
  829. _qtyB = {_x == "equip_brick"} count magazines player;
  830. _buildables set [count _buildables, _qtyB];
  831. } else { _qtyB = 0; _buildables set [count _buildables, _qtyB]; };
  832.  
  833. if ("equip_string" in _mags) then {
  834. _qtySt = {_x == "equip_string"} count magazines player;
  835. _buildables set [count _buildables, _qtySt];
  836. } else { _qtySt = 0; _buildables set [count _buildables, _qtySt]; };
  837.  
  838. if ("equip_duct_tape" in _mags) then {
  839. _qtyDT = {_x == "equip_duct_tape"} count magazines player;
  840. _buildables set [count _buildables, _qtyDT];
  841. } else { _qtyDT = 0; _buildables set [count _buildables, _qtyDT]; };
  842.  
  843. // Check if it matches again
  844. disableUserInput true;
  845. cutText ["Keyboard disabled while confirm recipes\n -Anti-Dupe", "PLAIN DOWN"];
  846. _result = [_buildables,_chosenRecipe] call BIS_fnc_areEqual;
  847. if (_result) then {
  848. //Build final product!
  849.  
  850. //Finish last requirement checks, _isSimulated disables objects physics if specified, _isDestructable checks if object needs to be invincible
  851. if (!_isSimulated) then {
  852. _object enablesimulation false;
  853. };
  854. if (!_isDestructable) then {
  855. _object addEventHandler ["HandleDamage", {false}];
  856. };
  857.  
  858.  
  859. // set the codes for gate
  860. //--------------------------------
  861.  
  862. // New Method
  863. _uidDir = _dir;
  864. _uidDir = round(_uidDir);
  865. _uid = "";
  866. {
  867. _x = _x * 10;
  868. if ( _x < 0 ) then { _x = _x * -10 };
  869. _uid = _uid + str(round(_x));
  870. } forEach _location;
  871. _uid = _uid + str(round(_dir));
  872.  
  873. //--------------------------------
  874.  
  875. switch (_classname) do
  876. {
  877. case "Grave":
  878. {
  879. _object setVariable ["isBomb", 1, true];//this will be known as a bomb instead of checking with classnames in player_bomb
  880. cutText [format["You have constructed a %1\nIt will only set off for enemies, add friendly playerUIDs so it will not trigger for them",_text], "PLAIN DOWN"];
  881. };
  882. case "Infostand_2_EP1":
  883. {
  884. cutText [format["You have constructed a %1\nBuild one outside as well. Look at Object to give base owners access as well!",_text,_uid], "PLAIN DOWN"];
  885. };
  886. case BBTypeOfFlag:
  887. {
  888. cutText [format["You have constructed a %1\nYou can now build within a %2 meter radius around this area, add friends playerUIDs to allow them to build too.",_text,_flagRadius], "PLAIN DOWN"];
  889. };
  890. default {
  891. cutText [format["You have constructed a %1",_text,_uid], "PLAIN DOWN"];
  892. //cutText [format[localize "str_build_01",_text], "PLAIN DOWN"];
  893. };
  894. };
  895. //Remove required magazines
  896. if (_qtyT > 0) then {
  897. for "_i" from 0 to _qtyT do
  898. {
  899. player removeMagazine _itemT;
  900. };
  901. };
  902. if (_qtyS > 0) then {
  903. for "_i" from 0 to _qtyS do
  904. {
  905. player removeMagazine _itemS;
  906. };
  907. };
  908. if (_qtyW > 0) then {
  909. for "_i" from 0 to _qtyW do
  910. {
  911. player removeMagazine _itemW;
  912. };
  913. };
  914. if (_qtyL > 0) then {
  915. for "_i" from 0 to _qtyL do
  916. {
  917. player removeMagazine _itemL;
  918. };
  919. };
  920. if (_qtyM > 0) then {
  921. for "_i" from 0 to _qtyM do
  922. {
  923. player removeMagazine _itemM;
  924. };
  925. };
  926. if (_qtyE > 0) then {
  927. for "_i" from 0 to _qtyE do
  928. {
  929. player removeMagazine _itemE;
  930. };
  931. };
  932. if (_qtyCr > 0) then {
  933. for "_i" from 0 to _qtyCr do
  934. {
  935. player removeMagazine _itemCR;
  936. };
  937. };
  938. if (_qtyC > 0) then {
  939. for "_i" from 0 to _qtyC do
  940. {
  941. player removeMagazine _itemC;
  942. };
  943. };
  944. if (_qtyB > 0) then {
  945. for "_i" from 0 to _qtyB do
  946. {
  947. player removeMagazine _itemB;
  948. };
  949. };
  950.  
  951. if (_qtySt > 0) then {
  952. for "_i" from 0 to _qtySt do
  953. {
  954. player removeMagazine _itemSt;
  955. };
  956. };
  957.  
  958. if (_qtyDT > 0) then {
  959. for "_i" from 0 to _qtyDT do
  960. {
  961. player removeMagazine _itemDt;
  962. };
  963. };
  964.  
  965. //Grenade only is needed when building booby trap
  966. if (_qtyG > 0 && _classname == "Grave") then {
  967. for "_i" from 0 to _qtyG do
  968. {
  969. player removeMagazine _itemG;
  970. };
  971. };
  972. sleep 0.5; //Give it time to remove items
  973. disableUserInput false; //Allow gear access now items have been removed
  974. _playerUID = [];
  975. _playerUID set [count _playerUID, (getPlayerUID player)];
  976. _object setVariable ["AuthorizedUID", _playerUID , true];
  977. _object setVariable ["characterID",dayz_characterID,true];
  978. //dayzPublishObj = [dayz_characterID,_object,[_dir,_location],_classname];
  979. PVDZ_obj_Publish = [dayz_characterID,_object,[_dir,_location],_classname,_playerUID];
  980. publicVariableServer "PVDZ_obj_Publish";
  981. if (isServer) then {
  982. PVDZ_obj_Publish call server_publishObj;
  983. };
  984. } else {
  985. detach _object;
  986. deletevehicle _object;
  987. cutText ["You need the EXACT amount of whatever you are trying to build without extras.", "PLAIN DOWN"];call _funcExitScript;};
  988.  
  989. player allowdamage true;
  990. procBuild = false;_playerCombat setVariable["startcombattimer", 1, true];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement