githubEdit

License Check

circle-check
circle-info

Firstly you will need to add the following to the config.lua

-- License Requirements
-- Configure license requirements for dealerships
-- Note: In V2, dealership locations are stored in the database
-- Use the dealership ID (UUID) from the dealership_locations to configure license requirements
Config.DealershipLicenses = {
   ["b4dbbcca-a7ba-462a-b772-3c3e6434612c"] = { -- Replace with your dealership ID
     enabled = true,
     licenseType = "driver" -- The license type required (e.g., "boat", "pilot", "driver")
   },
}
circle-info

You will need to replace the following function in config-cl.lua function ShowroomPreCheck(dealershipId)

---@param dealershipId string
---@return boolean allowed
function ShowroomPreCheck(dealershipId)
  local licenseConfig = lib.callback.await("jg-dealerships:server:get-dealership-license-config", false, dealershipId)
  
  if not licenseConfig then
    return true
  end

  if not licenseConfig.enabled then
    return true
  end

  local Player = Framework.Client.GetPlayerData()
  local hasLicense = Player.metadata and Player.metadata['licences'] and Player.metadata['licences'][licenseConfig.licenseType]

  if not hasLicense then
    local msg = "You require a " .. licenseConfig.licenseType .. " license to access this showroom."
    Framework.Client.Notify(msg, "error", 5000)
    return false
  end

  return true
end
circle-info

You will need to add the code below inside the config-sv.lua for this integration to work

Last updated

Was this helpful?