Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.25 KB | None | 0 0
  1. // use only with DZE_permanentplot=true;
  2.  
  3.  
  4. private ["_playerPos","_nearRestr","_hastool","_hasitem","_removed","_abort","_reason","_distance","_isNear","_lockable","_isAllowedUnderGround","_offset","_classname","_zheightdirection","_zheightchanged","_rotate","_objectHelperPos","_objectHelperDir","_objHDiff","_position","_isOk","_dir","_vector","_cancel","_location2","_buildOffset","_location","_limit","_started","_finished","_animState","_isMedic","_proceed","_counter","_dis","_sfx","_combination_1_Display","_combination_1","_combination_2","_combination_3","_combination","_combinationDisplay","_combination_4","_num_removed","_tmpbuilt","_vUp","_classnametmp","_text","_ghost","_objectHelper","_location1","_object","_helperColor","_canDo","_pos","_onLadder","_vehicle","_inVehicle","_needNear","_canBuild"];
  5.  
  6. //Check if building already in progress, exit if so.
  7. if (dayz_actionInProgress) exitWith {localize "str_epoch_player_40" call dayz_rollingMessages;};
  8. dayz_actionInProgress = true;
  9.  
  10. _pos = [player] call FNC_GetPos;
  11.  
  12. _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
  13.  
  14. _vehicle = vehicle player;
  15. _inVehicle = (_vehicle != player);
  16.  
  17.  
  18.  
  19. ////////////////////////////TOOLS AND ITEMS REQUIRED
  20. _inventory = items player;
  21. _hastool = "ItemToolbox" in _inventory;
  22. _hasitem = [["PartWoodLumber",4],["PartWoodPlywood",4]] call player_checkItems;
  23. ////////////////////////////////////////////////////
  24.  
  25.  
  26. /////////////////////////////RESTRICT IF ANOTHER OBJET IS NEAR
  27. _playerPos = getPosATL player;
  28. _nearRestr = count nearestObjects [_playerPos, ["Plastic_Pole_EP1_DZ"], 45] > 0;
  29.  
  30. if !(_nearRestr) exitWith {
  31. DZE_ActionInProgress = false;
  32. cutText [format["Needs be in plot pole area"], "PLAIN DOWN"];
  33. };
  34.  
  35. if (!_hasitem) exitWith {cutText
  36. [format["Needs 4x woodlumbers + 4xPlywood"], "PLAIN DOWN"];
  37. dayz_actionInProgress = false;
  38. };
  39. if (!_hastool) exitWith {cutText
  40. [format["Needs a Toolbox"], "PLAIN DOWN"];
  41. dayz_actionInProgress = false;
  42. };
  43.  
  44. if (_hasitem && _hastool) then {
  45.  
  46. DZE_Q = false;
  47. DZE_Z = false;
  48.  
  49. DZE_Q_alt = false;
  50. DZE_Z_alt = false;
  51.  
  52. DZE_Q_ctrl = false;
  53. DZE_Z_ctrl = false;
  54.  
  55. DZE_5 = false;
  56. DZE_4 = false;
  57. DZE_6 = false;
  58.  
  59. DZE_F = false;
  60.  
  61. DZE_cancelBuilding = false;
  62.  
  63. DZE_updateVec = false;
  64. DZE_memDir = 0;
  65. DZE_memForBack = 0;
  66. DZE_memLeftRight = 0;
  67.  
  68. call gear_ui_init;
  69. closeDialog 1;
  70.  
  71. if (dayz_isSwimming) exitWith {dayz_actionInProgress = false; localize "str_player_26" call dayz_rollingMessages;};
  72. if (_inVehicle) exitWith {dayz_actionInProgress = false; localize "str_epoch_player_42" call dayz_rollingMessages;};
  73. if (_onLadder) exitWith {dayz_actionInProgress = false; localize "str_player_21" call dayz_rollingMessages;};
  74. if (player getVariable["combattimeout",0] >= diag_tickTime) exitWith {dayz_actionInProgress = false; localize "str_epoch_player_43" call dayz_rollingMessages;};
  75.  
  76.  
  77.  
  78. //////////////////////////////PUT YOUR OBJET ID BELLOW
  79. _classname = "MAP_Phone_Box";
  80. ///////////////////////////////////////////////
  81. _classnametmp = _classname;
  82. _text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
  83. _ghost = getText (configFile >> "CfgVehicles" >> _classname >> "ghostpreview");
  84.  
  85.  
  86. _lockable = 0; //default define if lockable not found in config file below
  87. if(isNumber (configFile >> "CfgVehicles" >> _classname >> "lockable")) then { //find out if item is lockable object
  88. _lockable = getNumber(configFile >> "CfgVehicles" >> _classname >> "lockable"); // 2=lockbox, 3=combolock, 4=safe
  89. };
  90.  
  91. _isAllowedUnderGround = 1; //check if allowed to build under terrain
  92. if(isNumber (configFile >> "CfgVehicles" >> _classname >> "nounderground")) then {
  93. _isAllowedUnderGround = getNumber(configFile >> "CfgVehicles" >> _classname >> "nounderground");
  94. };
  95.  
  96. _offset = getArray (configFile >> "CfgVehicles" >> _classname >> "offset");
  97. if((count _offset) <= 0) then {
  98. _offset = [0,5,1];
  99. };
  100.  
  101. _objectHelper = objNull;
  102. _isOk = true;
  103. _location1 = [player] call FNC_GetPos; // get inital players position
  104. _dir = getDir player; //required to pass direction when building
  105.  
  106. // if ghost preview available use that instead
  107. if (_ghost != "") then {
  108. _classname = _ghost;
  109. };
  110.  
  111. _object = createVehicle [_classname, [0,0,0], [], 0, "CAN_COLLIDE"]; //object preview, not an actual object that will be built
  112.  
  113.  
  114.  
  115. _objectHelper = "Sign_sphere10cm_EP1" createVehicle [0,0,0];
  116. _helperColor = "#(argb,8,8,3)color(0,0,0,0,ca)";
  117. _objectHelper setobjecttexture [0,_helperColor];
  118. _objectHelper attachTo [player,_offset];
  119. _object attachTo [_objectHelper,[0,0,0]];
  120.  
  121. if (isClass (configFile >> "SnapBuilding" >> _classname)) then {
  122. ["","","",["Init",_object,_classname,_objectHelper]] spawn snap_build;
  123. };
  124.  
  125.  
  126. ["","","",["Init","Init",0]] spawn build_vectors;
  127.  
  128.  
  129. _objHDiff = 0;
  130. _cancel = false;
  131. _reason = "";
  132.  
  133. helperDetach = false;
  134. _canDo = (!r_drag_sqf and !r_player_unconscious);
  135. _position = [_objectHelper] call FNC_GetPos;
  136.  
  137. while {_isOk} do {
  138.  
  139. _zheightchanged = false;
  140. _zheightdirection = "";
  141. _rotate = false;
  142.  
  143. if (DZE_Q) then {
  144. DZE_Q = false;
  145. _zheightdirection = "up";
  146. _zheightchanged = true;
  147. };
  148. if (DZE_Z) then {
  149. DZE_Z = false;
  150. _zheightdirection = "down";
  151. _zheightchanged = true;
  152. };
  153. if (DZE_Q_alt) then {
  154. DZE_Q_alt = false;
  155. _zheightdirection = "up_alt";
  156. _zheightchanged = true;
  157. };
  158. if (DZE_Z_alt) then {
  159. DZE_Z_alt = false;
  160. _zheightdirection = "down_alt";
  161. _zheightchanged = true;
  162. };
  163. if (DZE_Q_ctrl) then {
  164. DZE_Q_ctrl = false;
  165. _zheightdirection = "up_ctrl";
  166. _zheightchanged = true;
  167. };
  168. if (DZE_Z_ctrl) then {
  169. DZE_Z_ctrl = false;
  170. _zheightdirection = "down_ctrl";
  171. _zheightchanged = true;
  172. };
  173. if (DZE_4) then {
  174. _rotate = true;
  175. DZE_4 = false;
  176. if(DZE_dirWithDegrees) then{
  177. DZE_memDir = DZE_memDir - DZE_curDegree;
  178. }else{
  179. DZE_memDir = DZE_memDir - 45;
  180. };
  181. };
  182. if (DZE_6) then {
  183. _rotate = true;
  184. DZE_6 = false;
  185. if(DZE_dirWithDegrees) then{
  186. DZE_memDir = DZE_memDir + DZE_curDegree;
  187. }else{
  188. DZE_memDir = DZE_memDir + 45;
  189. };
  190. };
  191.  
  192. if(DZE_updateVec) then{
  193. [_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYaw;
  194. DZE_updateVec = false;
  195. };
  196.  
  197. if (DZE_F and _canDo) then {
  198. if (helperDetach) then {
  199. _objectHelper attachTo [player];
  200. DZE_memDir = DZE_memDir-(getDir player);
  201. helperDetach = false;
  202. [_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYaw;
  203. } else {
  204. _objectHelperPos = getPosATL _objectHelper;
  205. detach _objectHelper;
  206. DZE_memDir = getDir _objectHelper;
  207. [_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYaw;
  208. _objectHelper setPosATL _objectHelperPos;
  209. _objectHelper setVelocity [0,0,0]; //fix sliding glitch
  210. helperDetach = true;
  211. };
  212. DZE_F = false;
  213. };
  214.  
  215. if(_rotate) then {
  216. [_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYaw;
  217. };
  218.  
  219. if(_zheightchanged) then {
  220. if (!helperDetach) then {
  221. detach _objectHelper;
  222. _objectHelperDir = getDir _objectHelper;
  223. };
  224.  
  225. _position = [_objectHelper] call FNC_GetPos;
  226.  
  227. if(_zheightdirection == "up") then {
  228. _position set [2,((_position select 2)+0.1)];
  229. _objHDiff = _objHDiff + 0.1;
  230. };
  231. if(_zheightdirection == "down") then {
  232. _position set [2,((_position select 2)-0.1)];
  233. _objHDiff = _objHDiff - 0.1;
  234. };
  235.  
  236. if(_zheightdirection == "up_alt") then {
  237. _position set [2,((_position select 2)+1)];
  238. _objHDiff = _objHDiff + 1;
  239. };
  240. if(_zheightdirection == "down_alt") then {
  241. _position set [2,((_position select 2)-1)];
  242. _objHDiff = _objHDiff - 1;
  243. };
  244.  
  245. if(_zheightdirection == "up_ctrl") then {
  246. _position set [2,((_position select 2)+0.01)];
  247. _objHDiff = _objHDiff + 0.01;
  248. };
  249. if(_zheightdirection == "down_ctrl") then {
  250. _position set [2,((_position select 2)-0.01)];
  251. _objHDiff = _objHDiff - 0.01;
  252. };
  253.  
  254. if((_isAllowedUnderGround == 0) && ((_position select 2) < 0)) then {
  255. _position set [2,0];
  256. };
  257.  
  258. if (surfaceIsWater _position) then {
  259. _objectHelper setPosASL _position;
  260. } else {
  261. _objectHelper setPosATL _position;
  262. };
  263.  
  264. if (!helperDetach) then {
  265. _objectHelper attachTo [player];
  266. };
  267. [_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYaw;
  268. };
  269.  
  270. uiSleep 0.5;
  271.  
  272. _location2 = [player] call FNC_GetPos;
  273. _objectHelperPos = [_objectHelper] call FNC_GetPos;
  274.  
  275. if(DZE_5) exitWith {
  276. _isOk = false;
  277. _position = [_object] call FNC_GetPos;
  278. detach _object;
  279. _dir = getDir _object;
  280. _vector = [(vectorDir _object),(vectorUp _object)];
  281. deleteVehicle _object;
  282. detach _objectHelper;
  283. deleteVehicle _objectHelper;
  284. };
  285.  
  286. if(_location1 distance _location2 > DZE_buildMaxMoveDistance) exitWith {
  287. _isOk = false;
  288. _cancel = true;
  289. _reason = format[localize "STR_EPOCH_BUILD_FAIL_MOVED",DZE_buildMaxMoveDistance];
  290. detach _object;
  291. deleteVehicle _object;
  292. detach _objectHelper;
  293. deleteVehicle _objectHelper;
  294. };
  295.  
  296. if(_location1 distance _objectHelperPos > DZE_buildMaxMoveDistance) exitWith {
  297. _isOk = false;
  298. _cancel = true;
  299. _reason = format[localize "STR_EPOCH_BUILD_FAIL_TOO_FAR",DZE_buildMaxMoveDistance];
  300. detach _object;
  301. deleteVehicle _object;
  302. detach _objectHelper;
  303. deleteVehicle _objectHelper;
  304. };
  305.  
  306. if(abs(_objHDiff) > DZE_buildMaxHeightDistance) exitWith {
  307. _isOk = false;
  308. _cancel = true;
  309. _reason = format[localize "STR_EPOCH_BUILD_FAIL_HEIGHT",DZE_buildMaxHeightDistance];
  310. detach _object;
  311. deleteVehicle _object;
  312. detach _objectHelper;
  313. deleteVehicle _objectHelper;
  314. };
  315.  
  316. if (player getVariable["combattimeout",0] >= diag_tickTime) exitWith {
  317. _isOk = false;
  318. _cancel = true;
  319. _reason = localize "str_epoch_player_43";
  320. detach _object;
  321. deleteVehicle _object;
  322. detach _objectHelper;
  323. deleteVehicle _objectHelper;
  324. };
  325.  
  326. if (DZE_cancelBuilding) exitWith {
  327. _isOk = false;
  328. _cancel = true;
  329. _reason = localize "STR_EPOCH_PLAYER_46";
  330. detach _object;
  331. deleteVehicle _object;
  332. detach _objectHelper;
  333. deleteVehicle _objectHelper;
  334. };
  335. };
  336.  
  337. _isOk = true;
  338. _proceed = false;
  339. _counter = 0;
  340. _location = [0,0,0];
  341.  
  342. //No building on roads unless toggled
  343. if (!DZE_BuildOnRoads) then {
  344. if (isOnRoad _position) then { _cancel = true; _reason = localize "STR_EPOCH_BUILD_FAIL_ROAD"; };
  345. };
  346.  
  347. // No building in trader zones
  348. if(!canbuild) then { _cancel = true; _reason = format[localize "STR_EPOCH_PLAYER_136",localize "STR_EPOCH_TRADER"]; };
  349.  
  350. if(!_cancel) then {
  351.  
  352. _classname = _classnametmp;
  353.  
  354. // Start Build
  355. _tmpbuilt = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"]; //create actual object that will be published to database
  356.  
  357. _tmpbuilt setdir _dir; //set direction inherited from passed args from control
  358. _tmpbuilt setVariable["memDir",_dir,true];
  359.  
  360. // Get position based on object
  361. _location = _position;
  362.  
  363. if((_isAllowedUnderGround == 0) && ((_location select 2) < 0)) then { //check Z axis if not allowed to build underground
  364. _location set [2,0]; //reset Z axis to zero (above terrain)
  365. };
  366.  
  367. _tmpbuilt setVectorDirAndUp _vector;
  368.  
  369. _buildOffset = [0,0,0];
  370. _vUp = _vector select 1;
  371. switch (_classname) do {
  372. case "MetalFloor_DZ": { _buildOffset = [(_vUp select 0) * .148, (_vUp select 1) * .148,0]; };
  373. };
  374.  
  375. _location = [
  376. (_location select 0) - (_buildOffset select 0),
  377. (_location select 1) - (_buildOffset select 1),
  378. (_location select 2) - (_buildOffset select 2)
  379. ];
  380.  
  381. if (surfaceIsWater _location) then {
  382. _tmpbuilt setPosASL _location;
  383. _location = ASLtoATL _location; //Database uses ATL
  384. } else {
  385. _tmpbuilt setPosATL _location;
  386. };
  387.  
  388. format[localize "str_epoch_player_138",_text] call dayz_rollingMessages;
  389.  
  390. //////////////////////////////////////////////////##########START TO BUILD AND REMOVE OBJETS
  391. player playActionNow "Medic";
  392. [player,"repair",0,false,10] call dayz_zombieSpeak;
  393. [player,10,true,(getPosATL player)] spawn player_alertZombies;
  394. sleep 3;
  395.  
  396. //////////Change items bellow by your owns in _hasitems variable
  397. _removed = [["PartWoodLumber",4],["PartWoodPlywood",4]] call player_removeItems;
  398. cutText [format[localize "str_build_01",_text], "PLAIN DOWN"];
  399. ////////////////////////////////////////////////////////////////////////////////
  400. _limit = 3; //times it takes to build by default
  401.  
  402. if (DZE_StaticConstructionCount > 0) then { //if count is manually overridden inside init.sqf, use that instead, else use limits configured in config files
  403. _limit = DZE_StaticConstructionCount;
  404. }
  405. else {
  406. if (isNumber (configFile >> "CfgVehicles" >> _classname >> "constructioncount")) then {
  407. _limit = getNumber(configFile >> "CfgVehicles" >> _classname >> "constructioncount");
  408. };
  409. };
  410.  
  411.  
  412.  
  413.  
  414.  
  415. _tmpbuilt setVariable ["OEMPos",_location,true]; //store original location as a variable
  416.  
  417. //if not lockable item
  418.  
  419. _tmpbuilt setVariable ["CharacterID",dayz_characterID,true];
  420.  
  421. if (DZE_permanentPlot) then {
  422. _tmpbuilt setVariable ["ownerPUID",dayz_playerUID,true];
  423.  
  424. _friendsArr = [[dayz_playerUID,toArray (name player)]];
  425. _tmpbuilt setVariable ["plotfriends", _friendsArr, true];
  426. PVDZ_obj_Publish = [dayz_characterID,_tmpbuilt,[_dir,_location,dayz_playerUID,_vector],_friendsArr];
  427. publicVariableServer "PVDZ_obj_Publish";
  428. //customize msg bellow
  429. cutText [format["Nice phonebox!"], "PLAIN DOWN",3];
  430. };
  431.  
  432. } else { //if magazine was not removed, cancel publish
  433. deleteVehicle _tmpbuilt;
  434. localize "str_epoch_player_46" call dayz_rollingMessages;
  435. };
  436.  
  437. };
  438.  
  439. //by juandayz writed with base on modular_build.sqf
  440.  
  441. dayz_actionInProgress = false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement