Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.83 KB | None | 0 0
  1. ;/*
  2.  
  3. Examples for config variable DZE_maintainCurrencyRate:
  4.  
  5. Now that we have gem based currency, maintaining is priced via a "worth".
  6.  
  7. If you want the price per item to be 1 gold, DZE_maintainCurrencyRate needs to be 100.
  8. 600 items * 100 would be worth 6 briefcases or 60k coins on a single currency server.
  9. 600 items * 150 would be worth 9 briefcases or 90k coins on a single currency server.
  10.  
  11. 1 10oz silver = 10 worth
  12. 1 gold = 100 worth
  13. 1 10oz gold = 1,000 worth
  14. 1 briefcase = 10,000 worth
  15.  
  16. Please see configVariables.sqf for the value of gems (DZE_GemWorthArray) and their relevant worth.
  17.  
  18. */
  19.  
  20. private ["_objectID","_objectUID","_target","_objects","_requirements","_count","_objects_filtered","_itemText","_type","_amount","_success","_wealth","_message1","_message2","_option","_line1","_line2","_plotDialog"];
  21. disableSerialization;
  22.  
  23. if (dayz_actionInProgress) exitWith {localize "STR_EPOCH_ACTIONS_2" call dayz_rollingMessages;};
  24. dayz_actionInProgress = true;
  25.  
  26. player removeAction s_player_maintain_area;
  27. s_player_maintain_area = 1;
  28. player removeAction s_player_maintain_area_force;
  29. s_player_maintain_area_force = 1;
  30. player removeAction s_player_maintain_area_preview;
  31. s_player_maintain_area_preview = 1;
  32.  
  33. _target = (([player] call FNC_getPos) nearEntities ["Plastic_Pole_EP1_DZ",15]) select 0;
  34. _objects = nearestObjects [_target, DZE_maintainClasses, DZE_maintainRange];
  35.  
  36. _objects_filtered = [];
  37. _requirements = [];
  38. _count = 0;
  39. _plotDialog = findDisplay 711194;
  40. _line1 = _plotDialog displayCtrl 7012;
  41. _line2 = _plotDialog displayCtrl 7013;
  42.  
  43. _req = {
  44. private ["_count","_amount","_itemText"];
  45.  
  46. _count = _this;
  47. _amount = _count * DZE_maintainCurrencyRate;
  48. _itemText = if (Z_SingleCurrency) then { CurrencyName } else { [_amount,true] call z_calcCurrency };
  49.  
  50. [_amount,_itemText]
  51. };
  52.  
  53. _maintain = {
  54. private ["_bank","_requirements","_count","_amount","_itemText","_wealth","_success","_message1","_message2","_enoughMoney","_moneyInfo"];
  55.  
  56. _count = count (_this select 0);
  57. _requirements = _count call _req;
  58.  
  59. _amount = _requirements select 0;
  60. _itemText = _requirements select 1;
  61.  
  62. _enoughMoney = false;
  63. _moneyInfo = [false, [], [], [], 0];
  64. _bank = player getVariable [Z_bankVariable,0];
  65.  
  66. if (Z_SingleCurrency) then {
  67. _enoughMoney = (_bank >= _amount);
  68. } else {
  69. Z_Selling = false; // Initialize gem currency before Z_canAfford.
  70. _moneyInfo = _amount call Z_canAfford;
  71. _enoughMoney = _moneyInfo select 0;
  72. };
  73.  
  74. _success = if (Z_SingleCurrency) then { true } else { [player,_amount,_moneyInfo,true,0] call Z_payDefault };
  75.  
  76. if (!_success && _enoughMoney) exitWith { systemChat localize "STR_EPOCH_TRADE_GEAR_AND_BAG_FULL"; }; // Not enough room in gear or bag to accept change
  77.  
  78. if (_enoughMoney) then {
  79. _success = if (Z_SingleCurrency) then {_amount <= _bank} else {[player,_amount,_moneyInfo,false,0] call Z_payDefault};
  80. if (_success) then {
  81.  
  82. PVDZE_maintainArea = [player,1,_this select 0];
  83. publicVariableServer "PVDZE_maintainArea";
  84.  
  85. systemChat format[localize "STR_EPOCH_ACTIONS_4",_count];
  86. if (Z_SingleCurrency) then {
  87. player setVariable [Z_bankVariable,(_bank - _amount),true];
  88. _message1 = format [localize "STR_EPOCH_PLOTMANAGEMENT_OBJECTS_MAINTAINED_SUCCESS",_count,[_amount] call BIS_fnc_numberText,_itemText];
  89. } else {
  90. _message1 = format [localize "STR_EPOCH_PLOTMANAGEMENT_OBJECTS_MAINTAINED_SUCCESS",_count,_itemText,""];
  91. };
  92. _message2 = " ";
  93. call player_forceSave; // Call player_forceSave BEFORE the medic animation because it can override the animation and make it finish prematurely.
  94.  
  95. player playActionNow "Medic";
  96.  
  97. [player,"repair",0,false,20] call dayz_zombieSpeak;
  98. [player,DZE_maintainRange,true,(getPosATL player)] spawn player_alertZombies;
  99. ["Working",0,[250,30,30,0]] call dayz_NutritionSystem;
  100.  
  101. if (DZE_permanentPlot) then {
  102. _line1 ctrlSetText _message1;
  103. _line2 ctrlSetText _message2;
  104. } else {
  105. _message1 call dayz_rollingMessages;
  106. };
  107. } else {
  108. systemChat localize "STR_EPOCH_TRADE_DEBUG";
  109. };
  110. } else {
  111. if (Z_SingleCurrency) then {
  112. _message1 = format[localize "STR_EPOCH_PLOTMANAGEMENT_OBJECTS_MAINTAINED_FAILED",_count,[_amount] call BIS_fnc_numberText,_itemText];
  113. } else {
  114. _message1 = format[localize "STR_EPOCH_PLOTMANAGEMENT_OBJECTS_MAINTAINED_FAILED",_count,_itemText,""];
  115. };
  116. _message2 = " ";
  117. if (DZE_permanentPlot) then {
  118. _line1 ctrlSetText _message1;
  119. _line2 ctrlSetText _message2;
  120. } else {
  121. _message1 call dayz_rollingMessages;
  122. };
  123. };
  124. };
  125.  
  126. {
  127. if (damage _x >= DZE_DamageBeforeMaint) then {
  128. _objectUID = _x getVariable ["ObjectUID","0"];
  129. _objectID = _x getVariable ["ObjectID","0"];
  130. _objects_filtered set [count _objects_filtered, [_x, _objectID, _objectUID]];
  131. _count = _count + 1;
  132. };
  133. } count _objects;
  134.  
  135. _option = if (typeName _this == "ARRAY") then {_this select 3} else {_this};
  136.  
  137. switch _option do {
  138. case "maintain": {
  139. if (_count != 0) then {
  140. [_objects_filtered] call _maintain;
  141. } else {
  142. systemChat localize "STR_EPOCH_PLOTMANAGEMENT_MAINTAIN_NONE";
  143. };
  144. };
  145. case "preview": {
  146. if (_count == 0) then {
  147. _message1 = localize "STR_EPOCH_PLOTMANAGEMENT_MAINTAIN_NONE";
  148. if (DZE_permanentPlot) then {
  149. _line1 ctrlSetText _message1;
  150. } else {
  151. _message1 call dayz_rollingMessages;
  152. };
  153. } else {
  154. _requirements = _count call _req;
  155.  
  156. if (Z_SingleCurrency) then {
  157. _message1 = format [localize "STR_EPOCH_PLOTMANAGEMENT_MAINTAIN_PRICE", _count,[_requirements select 0] call BIS_fnc_numberText,_requirements select 1];
  158. } else {
  159. _message1 = format [localize "STR_EPOCH_PLOTMANAGEMENT_MAINTAIN_PRICE", _count,_requirements select 1,""];
  160. };
  161. if (DZE_permanentPlot) then {
  162. _line1 ctrlSetText _message1;
  163. } else {
  164. _message1 call dayz_rollingMessages;
  165. };
  166. };
  167. _requirements = count _objects call _req;
  168. if (Z_SingleCurrency) then {
  169. _message2 = format [localize "STR_EPOCH_PLOTMANAGEMENT_MAINTAIN_FORCE",count _objects,[_requirements select 0] call BIS_fnc_numberText,_requirements select 1];
  170. } else {
  171. _message2 = format [localize "STR_EPOCH_PLOTMANAGEMENT_MAINTAIN_FORCE",count _objects,_requirements select 1,""];
  172. };
  173. if (_count != count _objects) then {
  174. if (DZE_permanentPlot) then {
  175. _line2 ctrlSetText _message2;
  176. } else {
  177. _message2 call dayz_rollingMessages;
  178. };
  179. };
  180. };
  181. case "force": {
  182. _count = 0;
  183. _objects_filtered = [];
  184. {
  185. _objectUID = _x getVariable ["ObjectUID","0"];
  186. _objectID = _x getVariable ["ObjectID","0"];
  187. _objects_filtered set [count _objects_filtered, [_x, _objectID, _objectUID]];
  188. _count = _count + 1;
  189. } count _objects;
  190.  
  191. [_objects_filtered] call _maintain;
  192. };
  193. };
  194.  
  195. dayz_actionInProgress = false;
  196. s_player_maintain_area = -1;
  197. s_player_maintain_area_force = -1;
  198. s_player_maintain_area_preview = -1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement