Better maintain

Intensive commands are processed on the client only, as opposed to
twice. an array of objects, their corresponding UID and ID are sent to
the server. Sending the objects as an array, despite the size the array
can reach, should be better than the way this was set up before.

Needs testing on a full server however.
This commit is contained in:
icomrade
2016-08-03 19:54:06 -04:00
parent b2eacfbe73
commit 657fe60f26
5 changed files with 55 additions and 51 deletions

View File

@@ -17,16 +17,18 @@ _objects = nearestObjects [_target, _objectClasses, _range];
//filter to only those that have 10% damage
_objects_filtered = [];
_count = 0;
{
if (damage _x >= DZE_DamageBeforeMaint) then {
_objects_filtered set [count _objects_filtered, _x];
_objectUID = _x getVariable ["ObjectUID","0"];
_objectID = _x getVariable ["ObjectID","0"];
_objects_filtered set [count _objects_filtered, [_x, _objectID, _objectUID]];
_count = _count + 1;
};
} count _objects;
_objects = _objects_filtered;
// TODO dynamic requirements based on used building parts?
_count = count _objects;
if (_count == 0) exitWith {
format[localize "STR_EPOCH_ACTIONS_22",_count] call dayz_rollingMessages;
DZE_ActionInProgress = false;
@@ -97,7 +99,7 @@ switch _option do {
// all required items removed from player gear
if (_tobe_removed_total == _removed_total) then {
format[localize "STR_EPOCH_ACTIONS_4",_count] call dayz_rollingMessages;
PVDZE_maintainArea = [player,1,_target];
PVDZE_maintainArea = [player,1, _objects];
publicVariableServer "PVDZE_maintainArea";
} else {
{player addMagazine _x;} count _temp_removed_array;

View File

@@ -78,7 +78,7 @@ if (_proceed) then {
// all parts removed proceed
if (_tobe_removed_total == _removed_total) then {
format[localize "STR_EPOCH_ACTIONS_4",1] call dayz_rollingMessages;
PVDZE_maintainArea = [player,2,_obj];
PVDZE_maintainArea = [player,2,[_obj, _objectID, _objectUID]];
publicVariableServer "PVDZE_maintainArea";
} else {
{player addMagazine _x;} count _temp_removed_array;

View File

@@ -16,15 +16,18 @@ _range = DZE_PlotPole select 0;
_objects = nearestObjects [_target, _objectClasses, _range];
_objects_filtered = [];
_count = 0;
{
if (damage _x >= DZE_DamageBeforeMaint) then {
_objects_filtered set [count _objects_filtered, _x];
_objectUID = _x getVariable ["ObjectUID","0"];
_objectID = _x getVariable ["ObjectID","0"];
_objects_filtered set [count _objects_filtered, [_x, _objectID, _objectUID]];
_count = _count + 1;
};
} count _objects;
_objects = _objects_filtered;
_count = count _objects;
// TODO dynamic requirements based on used building parts?
if (_count == 0) exitWith {
_ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7012);
_result = format[localize "STR_EPOCH_PLOTMANAGEMENT_MAINTAIN_OBJECTS", _count];
@@ -99,7 +102,7 @@ switch _option do {
// all required items removed from player gear
if (_tobe_removed_total == _removed_total) then {
format[localize "STR_EPOCH_ACTIONS_4", _count] call dayz_rollingMessages;
PVDZE_maintainArea = [player,1,_target];
PVDZE_maintainArea = [player,1,_objects];
publicVariableServer "PVDZE_maintainArea";
_ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7012);
_result = format[localize "STR_EPOCH_PLOTMANAGEMENT_OBJECTS_MAINTAINED_SUCCESS", _count];

View File

@@ -18,14 +18,17 @@ _objects = nearestObjects [_target, _objectClasses, _range];
_objects_filtered = [];
{
if (damage _x >= DZE_DamageBeforeMaint) then {
_objects_filtered set [count _objects_filtered, _x];
_objectUID = _x getVariable ["ObjectUID","0"];
_objectID = _x getVariable ["ObjectID","0"];
_objects_filtered set [count _objects_filtered, [_x, _objectID, _objectUID]];
_count = _count + 1;
};
} count _objects;
_objects = _objects_filtered;
_count = count _objects;
// TODO dynamic requirements based on used building parts?
if (_count == 0) exitWith {
_ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7012);
_result = format["Objects to maintain: %1" , _count];
_ctrl ctrlSetText _result;
@@ -47,7 +50,7 @@ _option = _this select 0;
switch _option do {
case "maintain": {
_wealth = player getVariable["cashMoney",0];
_wealth = player getVariable[Z_MoneyVariable,0];
_missing = "";
_missingQty = 0;
_proceed = true;
@@ -62,10 +65,10 @@ switch _option do {
player playActionNow "Medic";
[player,_range,true,(getPosATL player)] spawn player_alertZombies;
player setVariable["cashMoney",_newWealth,true];
player setVariable[Z_MoneyVariable,_newWealth,true];
call player_forceSave;
PVDZE_maintainArea = [player,1,_target];
PVDZE_maintainArea = [player,1,_objects];
publicVariableServer "PVDZE_maintainArea";