The database is set up automatically; if you have any problems, open ticket in discord.
2
Configure your language
If your language isn't listed here, you can add it or even open a ticket and we'll add it for you!
--[[Configure your language using the following: 'es' -> Spanish 'en' -> English 'fr' -> French 'de' -> German 'it' -> Italian 'pt' -> Portuguese]]Config.Locale='en'
3
Add this to exclude vehicles according to your framework
Go to the next route es_extended/server/modules/commands.lua and find the following command to replace this one:
Go to the next route qb-core/client/events.lua and find the event and replace it with this:
Go to the next route qbx_core/server/commands.lua and find the following command to replace this one:
4
Add the items according to your framework
Add the images to your inventory jc_jc_vehiclekeys/[Assets/img_inventory
['lockpick'] = {name='lockpick',label='Lockpick',weight=100,type='item',image='lockpick.png',unique=false,useable=true,shouldClose=true,combinable=nil,description='Tool used to pick vehicle locks'},['hacking'] = {name='hacking',label='Hacking Device',weight=200,type='item',image='hacking.png',unique=false,useable=true,shouldClose=true,combinable=nil,description='Electronic device used to hack vehicle systems'},
5
Install the key exports in your vehicle shop or garage system if they are not directly compatible with the system
If the garage or vehicle shop uses qb-vehiclekey or qbx_vehiclekey and does not use our key system, you do not need to adapt this
Client Exports
How do I get the license plate if it's not predefined?
localplate=GetVehicleNumberPlateText(vehicle)
Add key to Player
exports['jc_vehiclekeys']:GiveKeys(plate)
Remove Key to Player
exports['jc_vehiclekeys']:RemoveKeys(plate)
If you don't know how to do it, you can open a ticket and we'll help you integrate it
ESX.RegisterCommand(
"car",
"admin",
function(xPlayer, args, showError)
if not xPlayer then
return showError("[^1ERROR^7] The xPlayer value is nil")
end
local playerPed = GetPlayerPed(xPlayer.source)
local playerCoords = GetEntityCoords(playerPed)
local playerHeading = GetEntityHeading(playerPed)
local playerVehicle = GetVehiclePedIsIn(playerPed, false)
if not args.car or type(args.car) ~= "string" then
args.car = "adder"
end
if playerVehicle then
DeleteEntity(playerVehicle)
end
if Config.AdminLogging then
ESX.DiscordLogFields("UserActions", "Spawn Car /car Triggered!", "pink", {
{ name = "Player", value = xPlayer and xPlayer.name or "Server Console", inline = true },
{ name = "ID", value = xPlayer and xPlayer.source or "Unknown ID", inline = true },
{ name = "Vehicle", value = args.car, inline = true },
})
end
local xRoutingBucket = GetPlayerRoutingBucket(xPlayer.source)
ESX.OneSync.SpawnVehicle(args.car, playerCoords, playerHeading, upgrades, function(networkId)
if networkId then
local vehicle = NetworkGetEntityFromNetworkId(networkId)
if xRoutingBucket ~= 0 then
SetEntityRoutingBucket(vehicle, xRoutingBucket)
end
exports['jc_vehiclekeys']:ExcludeVehicle(xPlayer.source, vehicle)
for _ = 1, 100 do
Wait(0)
SetPedIntoVehicle(playerPed, vehicle, -1)
if GetVehiclePedIsIn(playerPed, false) == vehicle then
break
end
end
if GetVehiclePedIsIn(playerPed, false) ~= vehicle then
showError("[^1ERROR^7] The player could not be seated in the vehicle")
end
end
end)
end,
false,
{
help = TranslateCap("command_car"),
validate = false,
arguments = {
{ name = "car", validate = false, help = TranslateCap("command_car_car"), type = "string" },
},
}
)
RegisterNetEvent('QBCore:Command:SpawnVehicle', function(vehName)
local ped = PlayerPedId()
local hash = joaat(vehName)
local veh = GetVehiclePedIsUsing(ped)
if not IsModelInCdimage(hash) then return end
RequestModel(hash)
while not HasModelLoaded(hash) do
Wait(0)
end
if IsPedInAnyVehicle(ped) then
SetEntityAsMissionEntity(veh, true, true)
DeleteVehicle(veh)
end
local vehicle = CreateVehicle(hash, GetEntityCoords(ped), GetEntityHeading(ped), true, false)
TaskWarpPedIntoVehicle(ped, vehicle, -1)
SetVehicleFuelLevel(vehicle, 100.0)
SetVehicleDirtLevel(vehicle, 0.0)
SetModelAsNoLongerNeeded(hash)
local plate = GetVehicleNumberPlateText(vehicle)
exports['jc_vehiclekeys']:ExcludeVehicle(plate)
TriggerEvent('vehiclekeys:client:SetOwner', QBCore.Functions.GetPlate(vehicle))
end)
lib.addCommand('car', {
help = locale('command.car.help'),
params = {
{ name = locale('command.car.params.model.name'), help = locale('command.car.params.model.help') },
{ name = locale('command.car.params.keepCurrentVehicle.name'), help = locale('command.car.params.keepCurrentVehicle.help'), optional = true },
},
restricted = 'group.admin'
}, function(source, args)
if not IsOptin(source) then Notify(source, locale('error.not_optin'), 'error') return end
if not args then return end
local ped, bucket = GetPlayerPed(source), GetPlayerRoutingBucket(source)
local keepCurrentVehicle = args[locale('command.car.params.keepCurrentVehicle.name')]
local currentVehicle = not keepCurrentVehicle and GetVehiclePedIsIn(ped, false)
if currentVehicle and currentVehicle ~= 0 then
DeleteVehicle(currentVehicle)
end
local _, vehicle = qbx.spawnVehicle({
model = args[locale('command.car.params.model.name')],
spawnSource = ped,
warp = true,
bucket = bucket
})
exports['jc_vehiclekeys']:ExcludeVehicle(source, vehicle)
local plate = qbx.getVehiclePlate(vehicle)
config.giveVehicleKeys(source, plate, vehicle)
end)