[Release] FRFuel [v1.7.0]

Any news about update?

New release has been pushed disabling temporary manual engine cut-off workaround. This will eliminate compatibility issues with other engine controlling mods.

1 Like

i’m on it :slight_smile:

Is fuel working correctly now?? Can anyone confirm?

yes, its working correctly.

This is a client function, so you have to make an event handler on the client, that sets the wanted level.

How can I access methods like VehicleFuelLevel and VehicleSetFuelLevel from a lua script?


I’ve added this to FRFuel.cs (in the constructor)

EventHandlers["frfuel:removeFuel"] += new Action<Vehicle, float>((Vehicle vehicle, float amount) =>
{
  float current = VehicleFuelLevel(vehicle);
  VehicleSetFuelLevel(vehicle, current - amount);
});

And I’m calling it in server.lua (working properly otherwise) with

TriggerClientEvent('frfuel:removeFuel', vehicle, fuelAmount)

Not getting any error, but it’s not setting the fuel level.

I am also interested in being able to obtain the current fuel level from an external script, if that would be a possible addition.

Try:

EventHandlers["frfuel:removeFuel"] += new Action<int, float>((vehicleHandle, amount) =>
{
  Vehicle veh = new Vehicle(vehicleHandle);
  float currentFuelLevel = VehicleFuelLevel(veh);
  float newFuelLevel = currentFuelLevel - amount;
  if (newFuelLevel > 0f)
  {
    VehicleSetFuelLevel(veh, newFuelLevel);
  }
  else
  {
    VehicleSetFuelLevel(veh, 0f);
  }
});

A vehicle in Lua is only a number, you have to create a new vehicle with that handle in C#.
Not tested, might not work.

TriggerClientEvent('frfuel:removeFuel', vehicle, fuelAmount)

Make sure fuelAmount is a float number (e.g. 2.0)

Tried that, even tried making them dynamic then casting, but that didn’t work either. Script gets the vehicle and fuelAmount fine, but FRFuel doesn’t seem to accept the arguments properly. It didn’t seem to even be triggering the event (Console.WriteLine wasn’t sending anything to the in-game F8 console).

EDIT: Have since tried implementing the _Fuel_Level decor myself through my client script with

    currentFuel = DecorGetFloat(vehicle, '_Fuel_Level')
    DecorSetFloat(vehicle, '_Fuel_Level', currentFuel - fuelAmount)

but it still isn’t setting it, or at least not visually in the fuel bar.

hey man quick question,

Love your script, always used it but ever since some sorta update or so it’s been corrupting my server (your script)

Don’t matter what type of script it is, any form that directly interferes with my car’s engine will get ignored because of your script.

(example: car damage script, enough damage causes engine to quit, however, it will not stop running the engine when your script is enabled as well for some reason it then gets ignored)

As far as the base resource goes I am using it under FXServer without any modifications.

I have a little payment script as well that need a little modification, but that’s a custom thing.

I got a car health script which works fine, with frfuel.

i got both car damage script which disables engine for 7 seconds

And totalled script which total vehicle if damaged.

System.NullReferenceException: Object reference not set to an instance of an object
at System.Threading.Tasks.TaskScheduler.TryExecuteTask (System.Threading.Tasks.Task task) [0x00000] in <d7e663f2f7cd4ab6929018ec5233f09d>:0 
at CitizenFX.Core.CitizenTaskScheduler.InvokeTryExecuteTask (System.Threading.Tasks.Task task) [0x00000] in /src/code/client/clrcore/CitizenTaskScheduler.cs:130 
at CitizenFX.Core.CitizenTaskScheduler.Tick () [0x00029] in /src/code/client/clrcore/CitizenTaskScheduler.cs:107 
at CitizenFX.Core.InternalManager.TriggerEvent (System.String eventName, System.Byte[] argsSerialized, System.String sourceString) [0x000ff] in /src/code/client/clrcore/InternalManager.cs:210 

pops up in server console after a while, when it pops up frfuel is dissapearing.

  • Running latest FXServer update v.290

If it pops up in a server console then it has nothing to do with this mod as it’s client-side only.

New __resource.lua? Once again: this mod is client-side only.

“Download zip archive from latest release2.4k and unzip it to your resources folder.
Add it to the AutoStartResources of your citmp-server.yml.”

Please explain how this is client side only…

[Release] FRFuel [v1.7.0] <<__resource.lua

And… Its been and is currently used as a resource in servers…

The mod itself operates only on client side. Of course it is being loaded from server. Do note that code you’ve linked is not “officially” supported by this mod and is not part of it as well.

If you want to discuss/share integration of FRFuel with other resources/mods/frameworks/anything, please, make a separate thread about it. Keep this thread about FRFuel itself.

Nothing anywhere on these forums are “Officially Supported”… So my next question… Why give short no help answers to people when YOU’RE LISTED AS A DEV!!! WHAT FUCKING HELP IS THAT???