Advertisement
Guest User

Untitled

a guest
Sep 10th, 2015
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.26 KB | None | 0 0
  1. private ["_item","_classname","_require","_text","_playerUID","_itemOldCount","_itemNewCount","_cancel","_reason","_started","_finished","_animState","_isMedic","_dis","_sfx","_hasbuilditem","_tmpbuilt","_onLadder","_isWater","_require","_text","_offset","_IsNearPlot","_isOk","_location1","_location2","_counter","_limit","_proceed","_num_removed","_position","_object","_canBuildOnPlot","_friendlies","_nearestPole","_ownerID","_findNearestPoles","_findNearestPole","_distance","_classnametmp","_ghost","_isPole","_needText","_lockable","_zheightchanged","_rotate","_combination","_zheightdirection","_abort","_isNear","_need","_needNear","_vehicle","_inVehicle","_requireplot","_objHDiff","_isLandFireDZ","_isTankTrap"];
  2.  
  3. if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_40") , "PLAIN DOWN"]; };
  4. DZE_ActionInProgress = true;
  5. _limit = 3;
  6.  
  7. _object = _this;
  8. _object setVehicleLock "LOCKED";
  9.  
  10. _classname = typeOf _object;
  11. _text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
  12.  
  13. _curStage = _object getVariable ["buildStage", 0];
  14. _curStageText = format["Stage%1",_curStage];
  15. _nextStage = _curStage + 1;
  16. _nextStageText = format["Stage%1",_nextStage];
  17. _object setVariable ["buildStage",_nextStage,true];
  18.  
  19. diag_log format["%1 upgrade from %2 to %3", _classname, _curStageText, _nextStageText];
  20.  
  21. if (_curStage > 0 && isClass (configFile >> "CfgBuildingReceipt" >> _classname)) then {
  22. _curlockable = getNumber (configFile >> "CfgBuildingReceipt" >> _classname >> _curStageText >> "lockable");
  23. _nextlockable = getNumber (configFile >> "CfgBuildingReceipt" >> _classname >> _nextStageText >> "lockable");
  24. _combination = "";
  25. diag_log format["lockable: %1 -> %2", _curlockable, _nextlockable];
  26. if (_curlockable != _nextlockable) then {
  27. _round = 0;
  28. _prevNumber = 0;
  29.  
  30. while {_round < _nextlockable} do {
  31. _tmp = floor(random 10);
  32. // prevent multiple same numbers like 666 and leading zero
  33. if (_tmp != _prevNumber) then {
  34. _prevNumber = _tmp;
  35. _combination = _combination + str(_prevNumber);
  36. _round = _round + 1;
  37. };
  38. };
  39.  
  40. dayz_combination = _combination;
  41.  
  42. /*
  43. _deagOK = createDialog "KeypadHouse";
  44. waitUntil { !dialog };
  45. if (CODE != "") then {
  46. _object setVariable ["CharacterID",dayz_characterID,true];
  47. _passUch = [CODEINPUT,CODE] call _chePsw;
  48. } else {
  49. exitWith {DZE_ActionInProgress = false; cutText ["Your Code cannot be Empty" , "PLAIN DOWN"]; };
  50. };
  51. */
  52. };
  53.  
  54. _stageMaterials = getArray (configFile >> "CfgBuildingReceipt" >> _classname >> _nextStageText >> "stageMaterials");
  55. _animationStates = getArray (configFile >> "CfgBuildingReceipt" >> _classname >> _nextStageText >> "animationStates");
  56. _isOK = [[_object], _stageMaterials] call object_hasMaterial;
  57.  
  58. diag_log format["%1 -> %2", _isOK, _stageMaterials];
  59.  
  60. if (_isOK) then {
  61. _proceed = [_text, _limit] call player_doActionLoop;
  62. if (_proceed) then {
  63. /* does only work on units
  64. {
  65. //_removed = [_object,(_x select 0),(_x select 1)] call BIS_fnc_invRemove;
  66.  
  67. diag_log format["Removing %2 times %1",(_x select 0),(_x select 1)];
  68. } forEach _stageMaterials;
  69. */
  70. [_object,_stageMaterials] call object_removeItems;
  71.  
  72. {
  73. _object animate _x;
  74. } forEach _animationStates;
  75.  
  76. cutText [format["You have upgraded %1 to Stage %2",_text,_nextStage], "PLAIN DOWN"];
  77. /*
  78. we need something like PVDZE_obj_Swap for setting new owners
  79. */
  80. if (_curlockable != _nextlockable) then {
  81. PVDZE_veh_Update = [_object,"changeCharacterID",_combination,player];
  82. publicVariableServer "PVDZE_veh_Update";
  83. sleep 5;
  84. cutText [format[(localize "str_epoch_player_140"),_combination,_text], "PLAIN DOWN", 5]; //display new combination
  85. } else {
  86. PVDZE_veh_Update = [_object,"all"];
  87. publicVariableServer "PVDZE_veh_Update";
  88. };
  89. } else {
  90. cutText [(localize "str_epoch_player_46") , "PLAIN DOWN"];
  91. _object setVariable ["buildStage",_curStage,true];
  92. };
  93. } else {
  94. cutText ["You are missing some materials", "PLAIN DOWN"];
  95. _object setVariable ["buildStage",_curStage,true];
  96. };
  97. } else {
  98. cutText ["You cannot upgrade this Object", "PLAIN DOWN"];
  99. _object setVariable ["buildStage",_curStage,true];
  100. };
  101.  
  102. _object setVehicleLock "UNLOCKED";
  103. DZE_ActionInProgress = false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement