License Check

Firstly you will need to add the following to each dealership in the config.lua

licenseCheck = false, -- false = no license required to open dealership
license = 'driver', -- this is the license name required 

You will need to replace the following callback in config-sv.lua "jg-dealerships:server:showroom-pre-check"

lib.callback.register("jg-dealerships:server:showroom-pre-check", function(src, dealershipId)
  local allowed = false

  -- QBCORE LICENSE CHECKS
  local Player = QBCore.Functions.GetPlayer(src)
  local licenseCheck = Config.DealershipLocations[dealershipId].licenseCheck
  local license = Player.PlayerData.metadata['licences'][Config.DealershipLocations[dealershipId].license]
  if licenseCheck then
    if not license then
      allowed = false

    elseif license  then
      allowed = true
    end
  else
    allowed = true
  end

  -- Write some server-sided code here. Again, update the "allowed" variable

  if not allowed then
    Framework.Server.Notify(src, "You require a ".. Config.DealershipLocations[dealershipId].license.. " license", "error")
    return false
  end

  return true
end)

Do you only want license check for individual dealerships? Then replace the config-sv callback with the following

lib.callback.register("jg-dealerships:server:showroom-pre-check", function(src, dealershipId)
  local allowed = false

  -- QBCORE License Check
  -- dealershipId is the name of your dealership in the config.lua
  if dealershipId == "boat" then
    local Player = QBCore.Functions.GetPlayer(src)
    local license = Player.PlayerData.metadata['licences'][Config.DealershipLocations[dealershipId].license]
    if not license then
      allowed = false
    end
  end

  -- Write some server-sided code here. Again, update the "allowed" variable

  if not allowed then
    Framework.Server.Notify(src, "You require a ".. Config.DealershipLocations[dealershipId].license.. " license", "error")
    return false
  end

  return true
end)

Last updated