Skip to content

Commit

Permalink
Add taking max fuel level from handling
Browse files Browse the repository at this point in the history
  • Loading branch information
thers committed Aug 9, 2017
1 parent 139a31f commit 51b02f2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 403 deletions.
8 changes: 1 addition & 7 deletions DevMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class DevMenu
protected UIMenuItem vehicleModelId;
protected UIMenuItem vehicleFuelTank;
protected UIMenuItem drainFuelTank;
protected UIMenuItem knownVehicle;

protected UIMenuItem netVehicleId;
protected UIMenuItem netVehicleIdControl;
Expand Down Expand Up @@ -51,16 +50,12 @@ public DevMenu()
vehicleModelId = new UIMenuItem("Vehicle model ID");
vehicleModelId.Enabled = false;

knownVehicle = new UIMenuItem("Is known vehicle");
knownVehicle.Enabled = false;

vehicleFuelTank = new UIMenuItem("Vehicle fuel tank");
drainFuelTank = new UIMenuItem("Almost drain fuel tank");

mainMenu.AddItem(position);
mainMenu.AddItem(teleport);
mainMenu.AddItem(deleteVehicle);
mainMenu.AddItem(knownVehicle);
mainMenu.AddItem(vehicleModelId);
mainMenu.AddItem(vehicleFuelTank);
mainMenu.AddItem(drainFuelTank);
Expand Down Expand Up @@ -126,8 +121,7 @@ public void OnTick()
if (Game.PlayerPed.IsInVehicle())
{
Vehicle vehicle = Game.PlayerPed.CurrentVehicle;

knownVehicle.SetRightLabel(VehiclesPetrolTanks.dict.ContainsKey(vehicle.Model.Hash) ? "Yes" : "No");

vehicleModelId.SetRightLabel(vehicle.DisplayName.ToString());
vehicleFuelTank.SetRightLabel(vehicle.FuelLevel.ToString());
}
Expand Down
23 changes: 7 additions & 16 deletions FRFuel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,14 +407,7 @@ public void InitFuel(Vehicle vehicle)
{
currentVehicleFuelLevelInitialized = true;

if (VehiclesPetrolTanks.Has(vehicle))
{
fuelTankCapacity = VehiclesPetrolTanks.Get(vehicle);
}
else
{
fuelTankCapacity = 65f;
}
fuelTankCapacity = VehicleMaxFuelLevel(vehicle);

if (!vehicle.HasDecor(fuelLevelPropertyName))
{
Expand Down Expand Up @@ -482,14 +475,12 @@ public float VehicleFuelLevel(Vehicle vehicle)
/// <returns></returns>
public float VehicleMaxFuelLevel(Vehicle vehicle)
{
if (VehiclesPetrolTanks.Has(vehicle))
{
return VehiclesPetrolTanks.Get(vehicle);
}
else
{
return 65f;
}
return Function.Call<float>(
(Hash)0x642FC12F,
vehicle,
"CHandlingData",
"fPetrolTankVolume"
);
}

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion FRFuel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
<Compile Include="HUD.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TinyTween.cs" />
<Compile Include="VehiclesPetrolTanks.cs" />
</ItemGroup>
<ItemGroup>
<None Include=".gitignore" />
Expand Down
Loading

0 comments on commit 51b02f2

Please sign in to comment.