JG Scripts Docs
DiscordSupportStore
  • Welcome!
  • Claim Purchase
  • FiveM Escrow Errors
  • Permissions Troubleshooting
  • Translations
  • 🛠️Mechanic
    • Introduction
    • Installation & Configuration
      • ox_inventory
      • qb-inventory
      • esx_inventory
      • Setup New Mechanic Location
    • Job Setup
      • ESX Framework Jobs
    • Inventory Items
    • Props
    • Tuning
    • Manual Transmissions & Smooth First Gear
    • Integrations
    • Commands, Events & Exports
      • Commands
      • Events
      • Exports
    • Changelog
      • v1.3.0
      • v1.2.0
      • v1.1.3
      • v1.1.2
      • v1.1.1
      • v1.1
      • v1.0.12
      • v1.0.11
      • v1.0.10
      • v1.0.9
      • v1.0.8
      • v1.0.7
      • v1.0.6
      • v1.0.5 - hotfix
      • v1.0.5
      • v1.0.4
      • v1.0.3
      • v1.0.2
      • v1.0.1
  • 🚘Dealerships
    • Introduction
    • Installation & Configuration
    • Advanced Configuration
    • Job Dealership Setup
    • License Check
    • Importing Vehicles
    • Dealership Locations
    • Employees
    • Custom Payment Options
    • Plate Format
    • Vehicle Images
    • Languages
    • Commands, Events & Exports
      • Commands
      • Events
    • Integrations
      • Quasar Garages
      • Pickle Mods Documents
      • okokContract
      • qb-vehiclesales
    • Changelog
      • v1.4.0
      • v1.3.1
      • v1.3.0
      • v1.2.6
      • v1.2.5
      • v1.2.4
      • v1.2.3
      • v1.2.2
      • v1.2.1
      • v1.2
      • v1.1.9
      • v1.1.8
      • v1.1.7
      • v1.1.6
      • v1.1.5
      • v1.1.4
      • v1.1.3
      • v1.1.2
      • v1.1.1
      • v1.1
      • v1.0.3
      • v1.0.2
      • v1.0.1
  • 🚗Advanced Garages v3
    • Introduction
    • Installation & Configuration
    • Migration from v1
    • Public, Private & Impound Garages
    • Job & Gang Garages
    • Transferring Vehicles
    • Vehicle Duplication Prevention
    • Vehicle Images
    • Languages
    • Commands, Events & Exports
      • Commands
      • Events
      • Exports
    • Misc
      • Spawn Vehicles with ServerSetter
      • Why are you not using CreateVehicleServerSetter by default?
    • Troubleshooting
      • Execution of native... SetDriftTyresEnabled error
      • ucrtbase.dll!strcmp crash
      • SQL error: foreign key constraint fails
    • Integrations
      • qb-phone
      • npwd
      • RoadPhone
      • Quasar Smartphone
      • Quasar Housing
      • okokDeleteVehicles
      • ps-housing
      • nolag_properties
      • Brazzers-FakePlate
      • Custom Fuel System
      • Custom Key System
    • Guides
      • ESX Guides
        • Vehicle Labels
      • QBCore Guides
        • Why isn't /admincar working?!
        • Liveries not saving
    • Changelog
      • v3.2.1
      • v3.2.0
      • v3.1.6
      • v3.1.5
      • v3.1.4
      • v3.1.3
      • v3.1.2
      • v3.1.1
      • v3.1.0
      • v3.0.8
      • v3.0.7
      • v3.0.6
      • v3.0.5
      • v3.0.4
      • v3.0.3
      • v3.0.2
      • v3.0.1
      • v3
      • v2.2.9
      • v2.2.8
      • v2.2.7
      • v2.2.6
      • v2.2.5
      • v2.2.4
      • v2.2.3
      • v.2.2.2
      • v2.2.1
      • v2.2.0
      • v2.1.2
      • v2.1.1
      • v2.1
      • v2.0.7
      • v2.0.6
      • v2.0.5
      • v2.0.4
      • v2.0.3
      • v2.0.2
      • v2.0.1
  • 📊Handling
    • Introduction
    • Installation
    • Exports
  • 🎮Pro Scoreboard
    • Introduction
    • Installation
    • Config & Customisation
  • Advanced Garages v1
    • QB Installation & Config
    • ESX Installation & Config
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Advanced Garages v3
  2. Integrations

Custom Key System

If we don't support your key system out of the box, it's super easy to add your own!

  1. Go to the framework folder, and open cl-functions.lua

  2. Find the VehicleGiveKeys and VehicleRemoveKeys functions, which should look something like this:

function Framework.Client.VehicleGiveKeys(plate, vehicleEntity)
  if not DoesEntityExist(vehicleEntity) then return false end

  if Config.VehicleKeys == "qb-vehiclekeys" then
    TriggerEvent("vehiclekeys:client:SetOwner", plate)
  elseif Config.VehicleKeys == "jaksam-vehicles-keys" then
    TriggerServerEvent("vehicles_keys:selfGiveVehicleKeys", plate)
  elseif Config.VehicleKeys == "mk_vehiclekeys" then
    exports["mk_vehiclekeys"]:AddKey(vehicleEntity)
  elseif Config.VehicleKeys == "qs-vehiclekeys" then
    local model = GetDisplayNameFromVehicleModel(GetEntityModel(vehicleEntity))
    exports['qs-vehiclekeys']:GiveKeys(plate, model)
  elseif Config.VehicleKeys == "wasabi_carlock" then
    exports.wasabi_carlock:GiveKey(plate)
  elseif Config.VehicleKeys == "cd_garage" then
    TriggerEvent('cd_garage:AddKeys', plate)
  elseif Config.VehicleKeys == "okokGarage" then
    TriggerServerEvent("okokGarage:GiveKeys", plate)
  elseif Config.VehicleKeys == "t1ger_keys" then
    TriggerServerEvent('t1ger_keys:updateOwnedKeys', plate, true)
  else
    -- Setup custom key system here...
  end
end

function Framework.Client.VehicleRemoveKeys(plate, vehicleEntity)
  if not DoesEntityExist(vehicleEntity) then return false end
  
  if Config.VehicleKeys == "qs-vehiclekeys" then
    local model = GetDisplayNameFromVehicleModel(GetEntityModel(vehicleEntity))
    exports['qs-vehiclekeys']:RemoveKeys(plate, model)
  elseif Config.VehicleKeys == "wasabi_carlock" then
    exports.wasabi_carlock:RemoveKey(plate)
  elseif Config.VehicleKeys == "t1ger_keys" then
    TriggerServerEvent('t1ger_keys:updateOwnedKeys', plate, false)
  else
    -- Setup custom key system here...
  end
end
  1. Inside the VehicleGiveKeys function, within the else block where it says return 65 -- Setup custom key system here... replacing it with your custom give keys export. Also make sure you are providing the correct variables to the export based on the ones available: plate - Vehicle plate vehicleEntity - Physical vehicle entity If you need to get the vehicle model/spawn code, you can use: local model = GetDisplayNameFromVehicleModel(GetEntityModel(vehicleEntity))

  2. If your key script has the ability to remove keys, you can do the same inside the VehicleRemoveKeys function replacing the line that says -- Setup custom key system here... with the remove keys export of your key script. Again, ensure you are using variables from the ones available, plate and vehicleEntity

  3. Make sure that in the Configurator or config.lua you have set the VehicleKeys to none.

Last updated 1 year ago

Was this helpful?

🚗