🟠Exports

This page is for developers who want to utilize some of ours functions and exports within their scripts

This page is for developers who want to utilize some of ours functions and exports within their scripts

GetFuel

This export will return the amount of fuel the given vehicle has. Look below for an example

Lua

GetFuel(Vehicle: entity)
  -- Get the closest vehicle using QBCore.Functions.GetClosestVehicle()
  local vehicle = QBCore.Functions.GetClosestVehicle()
  -- Get the fuel amount of the closest vehicle using exports['vt-fuel']:GetFuel(vehicle)
  local fuel = exports['vt-fuel']:GetFuel(vehicle)
  -- Print the fuel amount of the closest vehicle
  print(fuel)

JS

function GetFuel(vehicle) {
  // Get the closest vehicle using QBCore.Functions.GetClosestVehicle()
  var closestVehicle = QBCore.Functions.GetClosestVehicle();
  // Get the fuel amount of the closest vehicle using exports['vt-fuel'].GetFuel(vehicle)
  var fuel = exports['vt-fuel'].GetFuel(closestVehicle);
  // Print the fuel amount of the closest vehicle
  console.log(fuel);
}

// Call the GetFuel function with a vehicle entity
var myVehicle = /* Your vehicle */;
GetFuel(myVehicle);

SetFuel (CLIENT AND SERVER EXPORT)

This export is used for setting the fuel in vehicles, please use the below example to implement it into your scripts!

Lua

-- SetFuel function sets the fuel of a vehicle to a specified value
-- Vehicle parameter represents the entity of the vehicle
-- Fuel parameter is the desired fuel value (number)
SetFuel(Vehicle: entity, Fuel: number)

-- Get the closest vehicle using QBCore.Functions.GetClosestVehicle()
local vehicle = QBCore.Functions.GetClosestVehicle()
-- Set the fuel of the closest vehicle to 100
exports['vt-fuel']:SetFuel(vehicle, 100)

JS

function SetFuel(vehicle, fuel) {
  // Set the fuel of the vehicle using exports['vt-fuel'].SetFuel(vehicle, fuel)
  exports['vt-fuel'].SetFuel(vehicle, fuel);
}

// Get the closest vehicle using QBCore.Functions.GetClosestVehicle()
var vehicle = QBCore.Functions.GetClosestVehicle();

// Set the fuel of the closest vehicle to 100
SetFuel(vehicle, 100);

Last updated