diff --git a/SQF/dayz_code/actions/fill_nearestVehicle.sqf b/SQF/dayz_code/actions/fill_nearestVehicle.sqf
index 95c169eee..b814b8287 100644
--- a/SQF/dayz_code/actions/fill_nearestVehicle.sqf
+++ b/SQF/dayz_code/actions/fill_nearestVehicle.sqf
@@ -1,79 +1,120 @@
if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;};
dayz_actionInProgress = true;
-private ["_isFuelTruck","_fuelTruckCapacity","_finished","_newFuel","_abort","_newFuelSrc","_canSize","_vehicle","_configVeh","_capacity","_nameText","_fuelTruck","_findNearestVehicle"];
+local _isFuelTruck = [false,true] select ((_this select 3 select 0) == 2);
+local _fuelSource = _this select 3 select 1;
+if (isNull _fuelSource) exitWith {dayz_actionInProgress = false; systemChat localize "str_cursorTargetNotFound";};
-_fuelTruck = _this select 3;
-_abort = false;
+local _typeFuelSource = typeOf _fuelSource;
+local _abort = false;
+local _fuelSourceCapacity = 0;
+local _pos = [_fuelSource] call fnc_getPos;
+local _fuelSourceFound = true;
-if (!isNull _fuelTruck) then {
- _isFuelTruck = true;
- // If fuel source is vehicle get actual capacity
- _fuelTruckCapacity = getNumber (configFile >> "cfgVehicles" >> typeOf _fuelTruck >> "fuelCapacity");
-} else {
- _isFuelTruck = false;
+if (_isFuelTruck) then {
+ _fuelSourceCapacity = getNumber (configFile >> "cfgVehicles" >> _typeFuelSource >> "fuelCapacity");
+} else {
+ if (_typeFuelSource == "FuelPump_DZ") then {
+ local _findNearestFuel = [];
+
+ {
+ if (_x != _fuelSource && {!(_x isKindOf "StaticWeapon") && {!(typeOf _x in DZE_StaticWeapons)}}) exitWith {
+ _findNearestFuel set [count _findNearestFuel,_x];
+ };
+ } foreach nearestObjects [_pos,DayZ_fuelSources,10];
+
+ if (count _findNearestFuel > 0) then {
+ _fuelSource = _findNearestFuel select 0;
+ } else {
+ _fuelSourceFound = false;
+ };
+ };
+ _fuelSourceCapacity = _fuelSource getVariable "FuelAmount";
+
+ if (isNil "_fuelSourceCapacity" && _fuelSourceFound) then {
+ _fuelSourceCapacity = floor(random dayz_randomMaxFuelAmount) max (dayz_randomMaxFuelAmount * 0.10);
+ _fuelSource setVariable ["FuelAmount",_fuelSourceCapacity, true];
+ };
};
-_findNearestVehicle = [];
-{
- if (_x != _fuelTruck) exitWith {
- _findNearestVehicle set [(count _findNearestVehicle),_x];
- };
-} count (([player] call fnc_getPos) nearEntities [["Air","LandVehicle","Ship"],30]);
+if !(_fuelSourceFound) exitwith {dayz_actionInProgress = false;localize "str_epoch_player_131_1" call dayz_rollingMessages;};
-if (count _findNearestVehicle >= 1) then {
+local _findNearestVehicle = [];
+
+{
+ if (_x != _fuelSource && {!(_x isKindOf "StaticWeapon") && {!(typeOf _x in DZE_StaticWeapons)}}) exitWith {
+ _findNearestVehicle set [count _findNearestVehicle,_x];
+ };
+} foreach nearestObjects [_pos,["Air","LandVehicle","Ship"],30]; // Using nearestObjects, because it is sorted by distance
+
+if (count _findNearestVehicle > 0) then {
// select the nearest one
- _vehicle = _findNearestVehicle select 0;
+ local _vehicle = _findNearestVehicle select 0;
// Static vehicle fuel information
- _configVeh = configFile >> "cfgVehicles" >> TypeOf(_vehicle);
- _capacity = getNumber(_configVeh >> "fuelCapacity");
- _nameText = getText(_configVeh >> "displayName");
+ local _configVeh = configFile >> "cfgVehicles" >> typeOf(_vehicle);
+ local _capacity = getNumber(_configVeh >> "fuelCapacity");
+ local _canSize = (_capacity / 10);
+ local _nameText = getText(_configVeh >> "displayName");
+ local _newFuel = 0;
+ local _newFuelSrc = 0;
+ local _availableFuel = 0;
- // perform fuel up
- while {true} do {
- // qty to add per loop
- _canSize = (_capacity / 10);
+ if (_isFuelTruck) then {
+ _availableFuel = ((fuel _fuelSource) * _fuelSourceCapacity) - _canSize;
+ } else {
+ _availableFuel = _fuelSourceCapacity;
+ };
+ if (_availableFuel < 0) then {_availableFuel = (fuel _fuelSource) * _fuelSourceCapacity;};
+
+ if (_availableFuel < _canSize) exitwith {
+ format[localize "STR_EPOCH_PLAYER_131_2",_availableFuel,_canSize] call dayz_rollingMessages;
+ };
+
+ while {1==1} do {
format[localize "str_epoch_player_131",_nameText] call dayz_rollingMessages;
[player,(getPosATL player),20,"refuel"] spawn fnc_alertZombies;
- _finished = ["Medic",1] call fn_loopAction;
+
+ local _finished = ["Medic",1] call fn_loopAction;
if (!_finished) then {
_abort = true;
} else {
- _newFuel = (((fuel _vehicle) * _capacity) + _canSize);
if (_isFuelTruck) then {
- _newFuelSrc = ((((fuel _fuelTruck) * _fuelTruckCapacity) - _canSize) / _fuelTruckCapacity);
- if (_newFuelSrc > 0) then {
- if (local _fuelTruck) then {
- [_fuelTruck,_newFuelSrc] call local_setFuel;
- } else {
- PVDZ_send = [_fuelTruck,"SetFuel",[_fuelTruck,_newFuelSrc]];
- publicVariableServer "PVDZ_send";
- };
- if (_newFuel >= _capacity) then {_newFuel = 1; _abort = true;} else {_newFuel = (_newFuel / _capacity);};
- if (local _vehicle) then {
- [_vehicle,_newFuel] call local_setFuel;
- } else {
- PVDZ_send = [_vehicle,"SetFuel",[_vehicle,_newFuel]];
- publicVariableServer "PVDZ_send";
- };
- format[localize "str_epoch_player_132",_nameText,round(_newFuel*100)] call dayz_rollingMessages;
- } else {
- _abort = true;
- };
- } else {
- //Filling near vehicle at gas station with generator
- if (_newFuel >= _capacity) then {_newFuel = 1; _abort = true;} else {_newFuel = (_newFuel / _capacity);};
+ _newFuelSrc = ((((fuel _fuelSource) * _fuelSourceCapacity) - _canSize) / _fuelSourceCapacity);
- if (local _vehicle) then {
- [_vehicle,_newFuel] call local_setFuel;
- } else {
- PVDZ_send = [_vehicle,"SetFuel",[_vehicle,_newFuel]];
- publicVariableServer "PVDZ_send";
- };
+ if (_newFuelSrc >= 0) then {
+ if (local _fuelSource) then {
+ [_fuelSource,_newFuelSrc] call local_setFuel;
+ } else {
+ PVDZ_send = [_fuelSource,"SetFuel",[_fuelSource,_newFuelSrc]];
+ publicVariableServer "PVDZ_send";
+ };
+ } else {_abort = true;};
+ } else {
+ local _fuelSourceCapacity = _fuelSource getVariable "FuelAmount";
+ _newFuelSrc = _fuelSourceCapacity - _canSize;
+
+ if (_newFuelSrc < 1) then {_newFuelSrc = 0;_abort = true;};
+ _fuelSource setVariable ["FuelAmount",_newFuelSrc, true];
+ };
+
+ _newFuel = (((fuel _vehicle) * _capacity) + _canSize);
+
+ if (_newFuel >= _capacity) then {_newFuel = 1; _abort = true;} else {_newFuel = (_newFuel / _capacity);};
+
+ if (local _vehicle) then {
+ [_vehicle,_newFuel] call local_setFuel;
+ } else {
+ PVDZ_send = [_vehicle,"SetFuel",[_vehicle,_newFuel]];
+ publicVariableServer "PVDZ_send";
+ };
+
+ if (_isFuelTruck) then {
format[localize "str_epoch_player_132",_nameText,round(_newFuel*100)] call dayz_rollingMessages;
+ } else {
+ format[localize "STR_EPOCH_PLAYER_132_1",_nameText,round(_newFuel*100),_newFuelSrc] call dayz_rollingMessages;
};
};
@@ -85,4 +126,5 @@ if (count _findNearestVehicle >= 1) then {
} else {
localize "str_epoch_player_27" call dayz_rollingMessages;
};
-dayz_actionInProgress = false;
+
+dayz_actionInProgress = false;
\ No newline at end of file
diff --git a/SQF/dayz_code/compile/fn_selfActions.sqf b/SQF/dayz_code/compile/fn_selfActions.sqf
index 1b5f14dcc..5708bbddf 100644
--- a/SQF/dayz_code/compile/fn_selfActions.sqf
+++ b/SQF/dayz_code/compile/fn_selfActions.sqf
@@ -716,7 +716,7 @@ if (!isNull _cursorTarget && _noChange && !_inVehicle && !_isPZombie && _canDo &
if (s_player_fuelauto < 0) then {
local _findNearestGen = {((alive _x) && (_x getVariable ["GeneratorRunning",false]))} count (([player] call FNC_getPos) nearObjects ["Generator_DZ",30]);
if (_findNearestGen > 0) then {
- s_player_fuelauto = player addAction [localize "STR_EPOCH_ACTIONS_FILLVEH", "\z\addons\dayz_code\actions\fill_nearestVehicle.sqf",objNull, 0, false, true];
+ s_player_fuelauto = player addAction [localize "STR_EPOCH_ACTIONS_FILLVEH", "\z\addons\dayz_code\actions\fill_nearestVehicle.sqf",[1,_cursorTarget], 0, false, true];
} else {
s_player_fuelauto = player addAction [format["%1",localize "STR_EPOCH_ACTIONS_NEEDPOWER"], "",[], 0, false, true];
};
@@ -730,7 +730,7 @@ if (!isNull _cursorTarget && _noChange && !_inVehicle && !_isPZombie && _canDo &
if (_isAlive && {_typeOfCursorTarget in DZE_fueltruckarray}) then {
if (s_player_fuelauto2 < 0) then {
if (isEngineOn _cursorTarget) then {
- s_player_fuelauto2 = player addAction [localize "STR_EPOCH_ACTIONS_FILLVEH", "\z\addons\dayz_code\actions\fill_nearestVehicle.sqf",_cursorTarget, 0, false, true];
+ s_player_fuelauto2 = player addAction [localize "STR_EPOCH_ACTIONS_FILLVEH", "\z\addons\dayz_code\actions\fill_nearestVehicle.sqf",[2,_cursorTarget ], 0, false, true];
} else {
s_player_fuelauto2 = player addAction [format["%1",localize "STR_EPOCH_ACTIONS_NEEDPOWER"], "",[], 0, false, true];
};
diff --git a/SQF/dayz_code/stringtable.xml b/SQF/dayz_code/stringtable.xml
index ddc912af3..8fc9d2bc9 100644
--- a/SQF/dayz_code/stringtable.xml
+++ b/SQF/dayz_code/stringtable.xml
@@ -23864,6 +23864,14 @@
Remplissage de %1, déplacez vous pour annuler.
Plnění %1, pohněte se pro zrušení.
+
+ Abort refueling, no fuel source.
+ Betanken abgebrochen, es konnte keine Treibstoffquelle gefunden werden.
+
+
+ Abort refueling, the fuel source has only %1 liters left. You need at least %2 liters of fuel.
+ Betanken abgebrochen, die Treibstoffquelle hat nur noch %1 Liter übrig. Benötigt werden %2 Liter Treibstoff.
+
%1 filled to %2 percent capacity.
%1 wurde zu %2 Prozent betankt.
@@ -23872,6 +23880,10 @@
%1 est rempli(e) à %2 pourcents de sa capacité.
%1 je naplněno do %2 procent kapacity.
+
+ %1 filled to %2 percent capacity. It is about %3 litres of fuel left in the fuel source.
+ %1 wurde zu %2 Prozent betankt. Es sind noch ca. %3 Liter Treibstoff in der Treibstoffquelle übrig.
+
You can only own %1 plot pole(s)
Du kannst nur %1 Grundstück(e) besitzen.