diff --git a/DevMenu.cs b/DevMenu.cs index c2263ec..12423d0 100644 --- a/DevMenu.cs +++ b/DevMenu.cs @@ -18,6 +18,7 @@ public class DevMenu protected UIMenuItem vehicleModelId; protected UIMenuItem vehicleFuelTank; + protected UIMenuItem drainFuelTank; protected UIMenuItem knownVehicle; protected UIMenuItem netVehicleId; @@ -54,6 +55,7 @@ public DevMenu() knownVehicle.Enabled = false; vehicleFuelTank = new UIMenuItem("Vehicle fuel tank"); + drainFuelTank = new UIMenuItem("Almost drain fuel tank"); mainMenu.AddItem(position); mainMenu.AddItem(teleport); @@ -61,6 +63,7 @@ public DevMenu() mainMenu.AddItem(knownVehicle); mainMenu.AddItem(vehicleModelId); mainMenu.AddItem(vehicleFuelTank); + mainMenu.AddItem(drainFuelTank); mainMenu.OnItemSelect += (sende, item, index) => { @@ -84,6 +87,11 @@ public DevMenu() Screen.ShowNotification("Fuel to model saved"); } + if (item == drainFuelTank && Game.PlayerPed.IsInVehicle()) + { + Game.PlayerPed.CurrentVehicle.SetDecor(FRFuel.fuelLevelPropertyName, .5f); + } + if (item == deleteVehicle) { if (Game.PlayerPed.LastVehicle != null) diff --git a/FRFuel.cs b/FRFuel.cs index f60f85f..f283e31 100644 --- a/FRFuel.cs +++ b/FRFuel.cs @@ -272,17 +272,25 @@ public void ConsumeFuel(Vehicle vehicle) fuel -= normalizedRPMValue * fuelRPMImpact; fuel -= vehicle.Acceleration * fuelAccelerationImpact; fuel -= vehicle.MaxTraction * fuelTractionImpact; + + fuel = fuel < 0f ? 0f : fuel; + } + + // FIXME: Temp engine cut-off + if (fuel == 0f && vehicle.IsEngineRunning) + { + vehicle.IsEngineRunning = false; } // Refueling at gas station if ( // If we have gas station near us currentGasStationIndex != -1 && - // And ped is in range of sqrt(80) to it + // And near any pump IsVehicleNearAnyPump(vehicle) ) { - if (vehicle.Speed < 0.1f) + if (vehicle.Speed < 0.1f && fuel != 0) // Temp check for out of fuel as we're cutting engine off before { ControlEngine(vehicle); } @@ -306,7 +314,7 @@ public void ConsumeFuel(Vehicle vehicle) } } - if (Game.IsControlJustReleased(0, Control.Jump)) + if (Game.IsControlJustReleased(0, Control.Jump) && addedFuelCapacitor > 0f) { TriggerEvent("frfuel:fuelAdded", addedFuelCapacitor); TriggerServerEvent("frfuel:fuelAdded", addedFuelCapacitor); @@ -321,6 +329,12 @@ public void ConsumeFuel(Vehicle vehicle) } else { + // FIXME: Temp engine cut-off + if (fuel != 0f && !vehicle.IsEngineRunning) + { + vehicle.IsEngineRunning = true; + } + hudActive = false; } @@ -581,7 +595,6 @@ public async Task OnTick() ConsumeFuel(vehicle); RenderUI(playerPed); - } else {