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 function in config-cl.lua function ShowroomPreCheck(dealershipId)

function ShowroomPreCheck(dealershipId)
  local Player = Framework.Client.GetPlayerData()
  local licenseCheck = Config.DealershipLocations[dealershipId].licenseCheck
  local license = Player.metadata['licences'][Config.DealershipLocations[dealershipId].license]

  if licenseCheck then
    if not license then
      allowed = false

    elseif license  then
      print(license)
      allowed = true
    end
  else
    allowed = true
  end

  if not allowed then
    local msg = "You require a ".. Config.DealershipLocations[dealershipId].license
    Framework.Client.Notify(msg, "error", 1000 )
    return false
  end

  return true

end

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

function ShowroomPreCheck(dealershipId)
  if dealershipId ~= "boat" then
      return true
  end

  local allowed = true
  local Player = Framework.Client.GetPlayerData()
  local licenseType = Config.DealershipLocations[dealershipId].license
  local licenseCheck = Config.DealershipLocations[dealershipId].licenseCheck
  local hasLicense = Player.metadata['licences'] and Player.metadata['licences'][licenseType]

  if licenseCheck then
      if not hasLicense then
          allowed = false
      end
  end

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

  return true
end

Last updated

Was this helpful?