A simple script for QBCore, QBox & ESX to show your vehicle's mileage in-game. When driving a vehicle that is owned (stored in the database), you will see an odometer in the bottom right of your screen. You can configure it to use miles or kilometers.
- Download the zip, and move into your resources folder
- Ensure the script in your server.cfg, by adding
ensure jg-vehiclemileage
. Make sure the script is ensured after yourqb-core
,qbx_core
ores_extended
resource - Run either the QBCore/QBox or ESX line of SQL in
run.sql
within your database
Using a custom framework is fairly straightforward. All your framework needs to have is some sort of owned vehicles database table, and that table needs to have a plate
column in it. Then all you need to do is:
- Go to
main.lua
- Add another conditional for your framework, and point to the name of your vehicles table
- In
config.lua
, setConfig.Framework = [your framework name]
Example:
if Config.Framework == "QBCore" then
Framework.VehiclesTable = "player_vehicles"
elseif Config.Framework == "ESX" then
Framework.VehiclesTable = "owned_vehicles"
elseif Config.Framework == "MyFrameworkName" then
Framework.VehiclesTable = "vehicles_table_name"
else
error("You haven't set a valid framework. Valid options can be found in main.lua!")
end
Use GetMileage(plate)
to get the mileage of a vehicle. Returns
local distance, unit = exports["jg-vehiclemileage"]:GetMileage("PLATE")
Returns:
- distance: number
- unit: enum
"miles", "kilometers"
Will return false
if the plate does not exist in the database
Want to see your vehicle's mileage in your garage with no setup? Try our Advanced Garages script: https://jgscripts.com/scripts/advanced-garages