Config = {}-- Options: "QBCore", "ESX"Config.Framework ="QBCore"-- Core object name, if you use ESX ignore thisConfig.Core ="qb-core"-- Options: "ox_lib", "lation_ui"Config.Display ="lation_ui"-- This setting limits how many vehicles can be exposed at the same timeConfig.MaxExposedVehicles =5-- If true, when you create a new car shop, it will check if the job exists in the jobs.lua file-- If not found, it will create a missing_jobs.txt file with the missing jobsConfig.CheckJobs =true-- Enable debug printsConfig.Debug =true-- Distance for qb-target/ox_target interactionsConfig.TargetDistance =2.5-- Freeze exposed vehicles to avoid them from being movedConfig.FreezeExposedVehicles =true-- Lock exposed vehicles' doorsConfig.LockExposedVehicles =true-- If true, when a player buys a vehicle, it will be spawned automatically (On spot garage settings of the used car shop)Config.BuyAndSpawn =true-- If true, the script will create the database tables automatically if they don't existConfig.AutoDatabase =true-- Language "en" or "pt"Config.Language ="en"-- CommandConfig.Command ="usedcarsales_creator"Config.CommandDesc ="Open the Used Car Shop Creator menu"
if Config.Framework == "QBCore" then
QBCore = exports[Config.Core]:GetCoreObject()
elseif Config.Framework == "ESX" then
ESX = exports.es_extended:getSharedObject()
end
function Notify(msg, type, time)
if Config.Display == "ox_lib" then
lib.notify({ title = "Used Cars", description = msg, type = type, time = time })
elseif Config.Display == "lation_ui" then
exports.lation_ui:notify({ title = "Used Cars", description = msg, type = type, time = time })
end
end
function RegisterContextMenu(id, title, options)
if Config.Display == "ox_lib" then
lib.registerContext({ id = id, title = title, options = options })
lib.showContext(id)
elseif Config.Display == "lation_ui" then
exports.lation_ui:registerMenu({ id = id, title = title, options = options })
exports.lation_ui:showMenu(id)
end
end
function ShowContextMenu(id)
if Config.Display == "ox_lib" then
lib.showContext(id)
elseif Config.Display == "lation_ui" then
exports.lation_ui:showMenu(id)
end
end
function HideContextMenu()
if Config.Display == "ox_lib" then
lib.hideContext()
elseif Config.Display == "lation_ui" then
exports.lation_ui:hideMenu()
end
end
function GetUserInput(title, fields)
if Config.Display == "ox_lib" then
return lib.inputDialog(title, fields)
elseif Config.Display == "lation_ui" then
return exports.lation_ui:input({
title = title or "",
options = fields
})
end
end
function ShowAlertDialog(header, content, labels)
labels = labels or { confirm = "Confirm", cancel = "Cancel" }
if Config.Display == "ox_lib" then
return lib.alertDialog({
header = header,
content = content,
centered = true,
cancel = true,
labels = labels
})
elseif Config.Display == "lation_ui" then
local result = exports.lation_ui:alert({
title = header,
content = content,
confirmText = labels.confirm,
cancelText = labels.cancel
})
return result == true and "confirm" or "cancel"
end
end
function ShowTextUI(text)
if Config.Display == "ox_lib" then
lib.showTextUI(text)
elseif Config.Display == "lation_ui" then
exports.lation_ui:showText({ description = text })
end
end
function HideTextUI()
if Config.Display == "ox_lib" then
lib.hideTextUI()
elseif Config.Display == "lation_ui" then
exports.lation_ui:hideText()
end
end
function StartProgressbar(label, duration)
if Config.Display == "ox_lib" then
return lib.progressCircle({
duration = duration,
label = label,
position = 'bottom',
useWhileDead = false,
canCancel = true,
disable = { car = true },
})
elseif Config.Display == "lation_ui" then
return exports.lation_ui:progressBar({
label = label,
duration = duration,
icon = 'fas fa-hamburger',
iconColor = '#10B981',
color = '#10B981',
useWhileDead = false,
disable = { car = true, move = true, combat = true },
})
end
end
function GetVehiclePlate(vehicle)
local plate = GetVehicleNumberPlateText(vehicle)
return plate
end
function GetVehicleModel(vehicle)
local model = GetEntityModel(vehicle)
local modelName = GetLabelText(GetDisplayNameFromVehicleModel(model))
return modelName
end
function GetVehicleProperties(vehicle)
local props = lib.getVehicleProperties(vehicle)
return props
end
function GetPlayerJob()
if Config.Framework == "QBCore" then
local playerData = QBCore.Functions.GetPlayerData()
return playerData.job
elseif Config.Framework == "ESX" then
local playerData = ESX.GetPlayerData()
return playerData.job.name
end
end
function IsPlayerBoss()
if Config.Framework == "QBCore" then
local playerData = QBCore.Functions.GetPlayerData()
if playerData.job.isboss then
return true
end
elseif Config.Framework == "ESX" then
local playerData = ESX.GetPlayerData()
if playerData.job.grade_name == 'boss' then
return true
end
end
return false
end
function CreateTargetZone(name, pos, icon, label, job, action)
if GetResourceState("qb-target") == "started" then
exports["qb-target"]:AddBoxZone(name, vector3(pos.x, pos.y, pos.z), 1.5, 1.5,
{
name = name,
heading = pos.heading or 0,
minZ = pos.z - 1,
maxZ = pos.z + 1
},
{
options = {
{ icon = icon, label = label, job = job, action = action }
},
distance = Config.TargetDistance
}
)
return name
elseif GetResourceState("ox_target") == "started" then
local id = exports.ox_target:addBoxZone({
coords = vec3(pos.x, pos.y, pos.z),
size = vec3(1.5, 1.5, 1.5),
rotation = pos.heading or 0,
debug = false,
name = name,
options = {
{
icon = icon,
label = label,
groups = { job },
onSelect = action
}
},
distance = Config.TargetDistance
})
return id
else
print("[m-UsedCarSales]: No target resource found (qb-target or ox_target).")
end
end
function OpenBossMenu(jobName)
if GetResourceState("qb-management") == "started" then
TriggerEvent("qb-bossmenu:client:OpenMenu", jobName)
elseif GetResourceState("qbx_management") == "started" then
TriggerEvent("qb-bossmenu:client:OpenMenu", jobName)
elseif GetResourceState("Ricky-BossMenu") == "started" then
exports['Ricky-BossMenu']:OpenBossMenu(jobName)
else
print("[m-UsedCarSales Creator]: No boss menu resource found.")
end
end
function SetFuel(vehicle)
if GetResourceState("LegacyFuel") == "started" then
exports['LegacyFuel']:SetFuel(vehicle, 100.0)
elseif GetResourceState("ox_fuel") == "started" then
SetVehicleFuelLevel(vehicle, 100.0)
elseif GetResourceState("qb-fuel") == "started" then
exports['qb-fuel']:SetFuel(vehicle, 100.0)
elseif GetResourceState("ti_fuel") == "started" then
exports["ti_fuel"]:setFuel(vehicle, 100.0, "RON91")
else
print("[m-UsedCarSales Creator]: No fuel resource found.")
end
end
function GiveKeys(plate)
if GetResourceState("qb-vehiclekeys") == "started" or GetResourceState("qbx_vehiclekeys") == "started" then
TriggerEvent("vehiclekeys:client:SetOwner", plate)
elseif GetResourceState("Renewed-Vehiclekeys") == "started" then
exports['Renewed-Vehiclekeys']:addKey(plate)
end
end