mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-17 09:10:27 +03:00
Fix refuel at gas station with generator #1806
Fixed mistake from: e398250
The refuel code was only running if a fuel truck was passed to the
script.
Also removed fuel truck classes that do not exist from the
dze_fueltruckarray.
This commit is contained in:
@@ -1,36 +1,26 @@
|
||||
private ["_isVehicle","_configSrcVeh","_capacitySrc","_nameTextSrc","_started","_finished","_animState","_isMedic","_newFuel","_abort","_newFuelSrc","_canSize","_vehicle","_configVeh","_capacity","_nameText","_isOk","_vehicleSrc","_findNearestVehicles","_findNearestVehicle","_IsNearVehicle"];
|
||||
private ["_isFuelTruck","_fuelTruckCapacity","_started","_finished","_animState","_isMedic","_newFuel","_abort","_newFuelSrc","_canSize","_vehicle","_configVeh","_capacity","_nameText","_fuelTruck","_findNearestVehicle"];
|
||||
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_24" call dayz_rollingMessages;};
|
||||
dayz_actionInProgress = true;
|
||||
|
||||
_isVehicle = false;
|
||||
|
||||
_vehicleSrc = _this select 3;
|
||||
|
||||
_fuelTruck = _this select 3;
|
||||
_abort = false;
|
||||
|
||||
if(!(isNull _vehicleSrc)) then {
|
||||
|
||||
_isVehicle = ((_vehicleSrc isKindOf "AllVehicles") && !(_vehicleSrc isKindOf "Man"));
|
||||
if (!isNull _fuelTruck) then {
|
||||
_isFuelTruck = true;
|
||||
// If fuel source is vehicle get actual capacity
|
||||
_configSrcVeh = configFile >> "cfgVehicles" >> TypeOf(_vehicleSrc);
|
||||
_capacitySrc = getNumber(_configSrcVeh >> "fuelCapacity");
|
||||
_nameTextSrc = getText(_configSrcVeh >> "displayName");
|
||||
_fuelTruckCapacity = getNumber (configFile >> "cfgVehicles" >> typeOf _fuelTruck >> "fuelCapacity");
|
||||
} else {
|
||||
_isFuelTruck = false;
|
||||
};
|
||||
|
||||
// Get all nearby vehicles within 30m
|
||||
_findNearestVehicles = nearestObjects [player, ["AllVehicles"], 30];
|
||||
_findNearestVehicle = [];
|
||||
{
|
||||
//diag_log ("FILL = " + str(_x) + " = " + str(_vehicleSrc));
|
||||
if ((alive _x) && {_x != _vehicleSrc} && {!(_x isKindOf "Man")}) exitWith {
|
||||
if ((alive _x) && {_x != _fuelTruck} && {!(_x isKindOf "Man")}) exitWith {
|
||||
_findNearestVehicle set [(count _findNearestVehicle),_x];
|
||||
};
|
||||
} count _findNearestVehicles;
|
||||
|
||||
_IsNearVehicle = count (_findNearestVehicle);
|
||||
|
||||
if(_IsNearVehicle >= 1) then {
|
||||
} count (nearestObjects [player, ["AllVehicles"], 30]);
|
||||
|
||||
if (count _findNearestVehicle >= 1) then {
|
||||
// select the nearest one
|
||||
_vehicle = _findNearestVehicle select 0;
|
||||
|
||||
@@ -39,10 +29,8 @@ if(_IsNearVehicle >= 1) then {
|
||||
_capacity = getNumber(_configVeh >> "fuelCapacity");
|
||||
_nameText = getText(_configVeh >> "displayName");
|
||||
|
||||
_isOk = true;
|
||||
// perform fuel up
|
||||
while {_isOk} do {
|
||||
|
||||
while {true} do {
|
||||
// qty to add per loop
|
||||
_canSize = (_capacity / 10);
|
||||
|
||||
@@ -87,15 +75,14 @@ if(_IsNearVehicle >= 1) then {
|
||||
};
|
||||
_abort = true;
|
||||
} else {
|
||||
if(_isVehicle) then {
|
||||
_newFuelSrc = ((((fuel _vehicleSrc) * _capacitySrc) - _canSize) / _capacitySrc);
|
||||
_newFuel = (((fuel _vehicle) * _capacity) + _canSize);
|
||||
_newFuel = (((fuel _vehicle) * _capacity) + _canSize);
|
||||
if (_isFuelTruck) then {
|
||||
_newFuelSrc = ((((fuel _fuelTruck) * _fuelTruckCapacity) - _canSize) / _fuelTruckCapacity);
|
||||
if (_newFuelSrc > 0) then {
|
||||
if (local _vehicleSrc) then {
|
||||
[_vehicleSrc,_newFuelSrc] call local_setFuel;
|
||||
//_vehicleSrc setFuel _newFuelSrc;
|
||||
if (local _fuelTruck) then {
|
||||
[_fuelTruck,_newFuelSrc] call local_setFuel;
|
||||
} else {
|
||||
PVDZ_send = [_vehicleSrc,"SetFuel",[_vehicleSrc,_newFuelSrc]];
|
||||
PVDZ_send = [_fuelTruck,"SetFuel",[_fuelTruck,_newFuelSrc]];
|
||||
publicVariableServer "PVDZ_send";
|
||||
};
|
||||
if (_newFuel >= _capacity) then {_newFuel = 1; _abort = true;} else {_newFuel = (_newFuel / _capacity);};
|
||||
@@ -110,13 +97,24 @@ if(_IsNearVehicle >= 1) then {
|
||||
} else {
|
||||
_abort = true;
|
||||
};
|
||||
} else {
|
||||
//Filling near vehicle at gas station with generator
|
||||
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";
|
||||
};
|
||||
[player,"refuel",0,false] call dayz_zombieSpeak;
|
||||
format[localize "str_epoch_player_132",_nameText,round(_newFuel*100)] call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
|
||||
if(_abort) exitWith {};
|
||||
uiSleep 1;
|
||||
};
|
||||
|
||||
} else {
|
||||
localize "str_epoch_player_27" call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
@@ -518,7 +518,7 @@ dayz_humanitytarget = "";
|
||||
dayz_selectedVault = objNull;
|
||||
dayz_selectedDoor = objNull;
|
||||
DAYZ_woundHit_dog = [["body","hands","legs"],[0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2]];
|
||||
DZE_fueltruckarray = ["KamazRefuel_DZ","UralRefuel_TK_EP1_DZ","MtvrRefuel_DES_EP1_DZ","V3S_Refuel_TK_GUE_EP1_DZ","MtvrRefuel_DZ","KamazRefuel_DZE","KamazRefuel_DZE1","KamazRefuel_DZE2","KamazRefuel_DZE3","KamazRefuel_DZE4","UralRefuel_TK_EP1_DZE","MtvrRefuel_DES_EP1_DZE","V3S_Refuel_TK_GUE_EP1_DZE","MtvrRefuel_DZE"];
|
||||
DZE_fueltruckarray = ["KamazRefuel_DZ","UralRefuel_TK_EP1_DZ","MtvrRefuel_DES_EP1_DZ","V3S_Refuel_TK_GUE_EP1_DZ","MtvrRefuel_DZ","KamazRefuel_DZE1","KamazRefuel_DZE2","KamazRefuel_DZE3","KamazRefuel_DZE4"];
|
||||
DZE_Lock_Door = "";
|
||||
DZE_HeliAllowTowFrom = ["CH_47F_EP1_DZE","CH_47F_EP1_DZ","CH_47F_BAF","CH_47F_EP1","BAF_Merlin_DZE","CH53_DZE"];
|
||||
DZE_HeliAllowToTow = ["hilux1_civil_1_open","HMMWV_Base","Lada_base","Offroad_DSHKM_base","Pickup_PK_base","SkodaBase","tractor","VWGolf","Volha_TK_CIV_Base_EP1","S1203_TK_CIV_EP1","SUV_Base_EP1","ArmoredSUV_Base_PMC","UAZ_Base","LandRover_Base","Ship"];
|
||||
|
||||
Reference in New Issue
Block a user