Advertisement
ElDubya

Untitled

Apr 5th, 2015
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 3.95 KB | None | 0 0
  1. private ["_newWealth","_missing","_missingQty","_proceed","_itemIn","_countIn","_target","_objectClasses","_range","_objects","_requirements","_count","_cost","_option"];
  2. disableSerialization;
  3.  
  4. IF (DZE_ActionInProgress) exitWith { cutText [(localize "STR_EPOCH_ACTIONS_2") , "PLAIN DOWN"]; };
  5. DZE_ActionInProgress = TRUE;
  6.  
  7. player removeAction s_player_maintain_area;
  8. s_player_maintain_area = 1;
  9. player removeAction s_player_maintain_area_preview;
  10. s_player_maintain_area_preview = 1;
  11.  
  12. _target = cursorTarget;
  13.  
  14. _objectClasses = DZE_maintainClasses;
  15. _range = DZE_PlotPole SELECT 0;
  16. _objects = nearestObjects [_target, _objectClasses, _range];
  17.  
  18. _objects_filtered = [];
  19. {
  20.     IF (damage _x >= DZE_DamageBeforeMaint) THEN {
  21.         _objects_filtered SET [COUNT _objects_filtered, _x];
  22.    };
  23. } COUNT _objects;
  24. _objects = _objects_filtered;
  25.  
  26. _count = COUNT _objects;
  27.  
  28. IF (_count == 0) exitWith {
  29.             _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7012);
  30.             _result =  format["Objects to maintain: %1" , _count];
  31.             _ctrl ctrlSetText   _result;
  32.        
  33.             _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7013);
  34.             _result =  format["Price to maintain: %1 %2" , 0, CurrencyName];
  35.            
  36.             _ctrl ctrlSetText   _result;   
  37.     DZE_ActionInProgress = FALSE;
  38.     s_player_maintain_area = -1;
  39.     s_player_maintain_area_preview = -1;
  40. };
  41.  
  42. _theCost = _count * 200;
  43. _requirements = [[CurrencyName,_theCost]];
  44.  
  45.  
  46. _option = _this SELECT 0;
  47. switch _option do {
  48.     CASE "maintain": {
  49.        
  50.         _wealth = player getVariable["cashMoney",0];
  51.         _missing = "";
  52.         _missingQty = 0;
  53.         _proceed = TRUE;
  54.         {
  55.             _itemIn = _x SELECT 0;
  56.             _countIn = _x SELECT 1;
  57.             IF (_wealth < _countIn) exitWith { _missing = _itemIn; _missingQty = (_countIn - _wealth); _proceed = FALSE; };
  58.         } COUNT _requirements;
  59.  
  60.         IF (_proceed) THEN {
  61.             _newWealth = (_wealth - _countIn);
  62.             player playActionNow "Medic";
  63.             [player,_range,TRUE,(getPosATL player)] spawn player_alertZombies;
  64.  
  65.             player setVariable["cashMoney",_newWealth,TRUE];
  66.  
  67.             PVDZE_plr_Save = [player,(magazines player),TRUE,TRUE];
  68.             publicVariableServer "PVDZE_plr_Save";
  69.            
  70.             PVDZE_maintainArea = [player,1,_target];
  71.             publicVariableServer "PVDZE_maintainArea";
  72.            
  73.            
  74.             cutText [format[(localize "STR_EPOCH_ACTIONS_4"), _count], "PLAIN DOWN", 5];           
  75.            
  76.             _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7012);
  77.             _result =  format["SUCCESS : Objects maintained: %1" , _count];
  78.             _ctrl ctrlSetText   _result;
  79.        
  80.             _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7013);
  81.             _result =  format["SUCCESS : Price maintained: %1 %2" , _theCost, CurrencyName];
  82.             _ctrl ctrlSetText   _result;   
  83.                
  84.         } ELSE {
  85.             _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7012);
  86.             _result =  format["FAILED: Objects to maintain: %1" , _count];
  87.             _ctrl ctrlSetText   _result;
  88.        
  89.             _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7013);
  90.             _result =  format["FAILED: Price to maintain: %1 %2" , _theCost, CurrencyName];
  91.             _ctrl ctrlSetText   _result;   
  92.            
  93.             cutText [format[(localize "STR_EPOCH_ACTIONS_6"), _missingQty, CurrencyName], "PLAIN DOWN"];
  94.         };
  95.     };
  96.     CASE "preview": {
  97.         _cost = "";
  98.         {
  99.             _itemIn = _x SELECT 0;
  100.             _countIn = _x SELECT 1;
  101.             IF (_cost != "") THEN {
  102.                 _cost = _cost + " and ";
  103.             };
  104.             _cost = _cost + (str(_countIn) + " " + CurrencyName);
  105.         } COUNT _requirements;
  106.            
  107.         cutText [format[(localize "STR_EPOCH_ACTIONS_7"), _count, _cost], "PLAIN DOWN"];
  108.            
  109.         _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7012);
  110.         _result =  format["Objects to maintain: %1" , _count];
  111.         _ctrl ctrlSetText   _result;
  112.        
  113.         _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7013);
  114.         _result =  format["Price to maintain: %1 %2" , _theCost, CurrencyName];
  115.         _ctrl ctrlSetText   _result;                               
  116.     };
  117. };
  118.  
  119. DZE_ActionInProgress = FALSE;
  120. s_player_maintain_area = -1;
  121. s_player_maintain_area_preview = -1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement