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 vehicleprint(fuel)
JS
functionGetFuel(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 vehicleconsole.log(fuel);}// Call the GetFuel function with a vehicle entityvar 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 100exports['vt-fuel']:SetFuel(vehicle, 100)
JS
functionSetFuel(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 100SetFuel(vehicle,100);