diff --git a/README.md b/README.md index ef56224..a673b41 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # qb-customs Vehicle Customization For QB-Core +Make sure to read the locations.lua settings VERY carefully. It has all the information needed to properly setup all your locations. Chances are if something is not working, your configuration for that location is wrong. Doublecheck before opening an issue. + +If you are still have having issues, enable the Config.Debug option at the top of config.lua. If you do open an issue, make sure to include all the debug information printed in the f8 menu, along with your Location configuration settings. + # License QBCore Framework diff --git a/client/cl_bennys.lua b/client/cl_bennys.lua index 531933c..7836d21 100644 --- a/client/cl_bennys.lua +++ b/client/cl_bennys.lua @@ -1,7 +1,7 @@ ----------------------- ---- Variables ---- ----------------------- -local QBCore = exports['qb-core']:GetCoreObject() +QBCore = exports['qb-core']:GetCoreObject() local PlayerData = QBCore.Functions.GetPlayerData() local CustomsData = {} @@ -65,6 +65,7 @@ local function AllowJob(restrictionData, job) else if restrictionData.job == "any" or restrictionData.job == job or not restrictionData.job then return true end end + if Config.Debug then print('Denied for not having allowed job. ('..job..')') end return false end @@ -76,6 +77,7 @@ local function AllowGang(restrictionData, gang) else if restrictionData.gang == "any" or restrictionData.gang == gang or not restrictionData.gang then return true end end + if Config.Debug then print('Denied for not having allowed gang. ('..gang..')') end return false end @@ -84,7 +86,10 @@ local function AllowVehicleClass(restrictionData, vehicle) if restrictionData.deniedClasses then for _,class in ipairs(restrictionData.deniedClasses) do - if vehicleClass == class then return false end + if vehicleClass == class then + if Config.Debug then print('Denied for having denied vehicle class. ('..vehicleClass..')') end + return false + end end end @@ -96,6 +101,7 @@ local function AllowVehicleClass(restrictionData, vehicle) if (restrictionData.allowedClasses and restrictionData.allowedClasses[1] == nil) or not restrictionData.allowedClasses or vehicleClass == 0 then return true end + if Config.Debug then print('Denied for not having allowed vehicle class. ('..vehicleClass..')') end return false end @@ -773,21 +779,38 @@ function EnterLocation(override) xenons = false, horn = false, turbo = false, + cosmetics = false, } local canEnter = false + local repairOnly = true if next(CustomsData) then for k,v in pairs(locationData.categories) do - if not canEnter and v then canEnter = true end + if not canEnter and v then + if k ~= "repair" then repairOnly = false end + canEnter = true + end categories[k] = v end elseif override then canEnter = true end + if Config.Debug then + print('***************************************************************************') + print(string.format('EnterLocation Debug Start | CanEnter: %s | Repair Only: %s | Override: %s', canEnter, repairOnly, json.encode(override))) + print('***************************************************************************') + if next(locationData) then for k,v in pairs(locationData) do print(k, json.encode(v)) end end + for k,v in pairs(categories) do print(k,v) end + print('***************************************************************************') + print('EnterLocation Debug End') + print('***************************************************************************') + end + if not canEnter then QBCore.Functions.Notify('You cant do anything here!') ExitBennys() return end + if Config.UseRadial then exports['qb-radialmenu']:RemoveOption(radialMenuItemId) radialMenuItemId = nil @@ -826,11 +849,11 @@ function EnterLocation(override) end) isPlyInBennys = true - DisableControls() + DisableControls(repairOnly) end -function DisableControls() +function DisableControls(repairOnly) CreateThread(function() while isPlyInBennys do DisableControlAction(1, 38, true) --Key: E @@ -855,7 +878,7 @@ function DisableControls() end if IsDisabledControlJustReleased(1, 176) then --Key: Enter - MenuManager(true) + MenuManager(true, repairOnly) PlaySoundFrontend(-1, "OK", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1) end @@ -903,11 +926,22 @@ function CheckRestrictions(location) local _location = Config.Locations[location] local restrictions = _location.restrictions + if Config.Debug then + print('***************************************************************************') + print('Restriction Debug') + print('***************************************************************************') + end + local isEnabled = _location.settings.enabled local vehicle = GetVehiclePedIsIn(PlayerPed, false) local allowedJob = AllowJob(restrictions, PlayerData.job.name) local allowedGang = AllowGang(restrictions, PlayerData.gang.name) local allowedClass = AllowVehicleClass(restrictions, GetVehiclePedIsIn(PlayerPed, false)) + + if Config.Debug then + print(string.format('Is Enabled: %s\nVehicle: %s\nallowedJob: %s\nallowedGang: %s\nallowedClass: %s', isEnabled, vehicle, allowedJob, allowedGang, allowedClass)) + print('***************************************************************************') + end return isEnabled and vehicle ~= 0 and allowedJob and allowedGang and allowedClass end diff --git a/client/cl_ui.lua b/client/cl_ui.lua index 34ec922..4740fe5 100644 --- a/client/cl_ui.lua +++ b/client/cl_ui.lua @@ -222,7 +222,7 @@ function InitiateMenus(isMotorcycle, vehicleHealth, categories, welcomeLabel) for _, v in ipairs(vehicleCustomisation) do local _, amountValidMods = CheckValidMods(v.category, v.id) - + if amountValidMods > 0 or v.id == 18 then if (v.id == 11 or v.id == 12 or v.id == 13 or v.id == 15) then if categories.mods and maxVehiclePerformanceUpgrades ~= -1 then @@ -245,7 +245,9 @@ function InitiateMenus(isMotorcycle, vehicleHealth, categories, welcomeLabel) populateMenu("mainMenu", v.id, v.category, "none") end else - populateMenu("mainMenu", v.id, v.category, "none") + if categories.cosmetics then + populateMenu("mainMenu", v.id, v.category, "none") + end end end end @@ -577,7 +579,7 @@ function DisplayMenu(state, menu) updateMenuSubheading(menu) end -function MenuManager(state) +function MenuManager(state, repairOnly) if state then if currentMenuItem2 ~= "Installed" then if isMenuActive("modMenu") then @@ -682,8 +684,13 @@ function MenuManager(state) RepairVehicle() - toggleMenu(false, "repairMenu") - toggleMenu(true, currentMenu) + if not repairOnly then + toggleMenu(false, "repairMenu") + toggleMenu(true, currentMenu) + else + ExitBennys() + QBCore.Functions.Notify('Your vehicle was repaired!') + end updateMenuHeading(currentMenu) updateMenuSubheading(currentMenu) playSoundEffect("wrench", 0.4) diff --git a/config.lua b/config.lua index 7fb0cdb..bc88da0 100644 --- a/config.lua +++ b/config.lua @@ -1,5 +1,6 @@ Config = Config or {} +Config.Debug = false -- Set to True to enable Debug Prints Config.MoneyType = 'bank' Config.RepairMoneyType = 'cash' Config.UseRadial = false -- Will use qb-radial menu for entering instead of press E diff --git a/shared/locations.lua b/shared/locations.lua index 6269c2d..c89433e 100644 --- a/shared/locations.lua +++ b/shared/locations.lua @@ -15,8 +15,8 @@ enabled = true, }, categories = { -- Only include the categories you want. A category not listed defaults to FALSE. + mods = true, -- Performance Mods repair = true, - mods = true, armor = true, respray = true, liveries = true, @@ -28,6 +28,7 @@ xenons = true, horn = true, turbo = true, + cosmetics = true, -- Cosmetic Mods }, drawtextui = { text = "Bennys Motorworks", @@ -70,6 +71,7 @@ Config.Locations = { enabled = true, }, categories = { + mods = true, repair = true, respray = true, liveries = true, @@ -80,6 +82,7 @@ Config.Locations = { neons = true, xenons = true, horn = true, + cosmetics = true, }, drawtextui = { text = "Bennys Motorworks" @@ -107,6 +110,7 @@ Config.Locations = { enabled = true, }, categories = { + mods = true, repair = true, respray = true, liveries = true, @@ -117,6 +121,7 @@ Config.Locations = { neons = true, xenons = true, horn = true, + cosmetics = true, }, drawtextui = { text = "Bennys Motorworks" @@ -144,6 +149,7 @@ Config.Locations = { enabled = true, }, categories = { + mods = true, repair = true, respray = true, liveries = true, @@ -154,6 +160,7 @@ Config.Locations = { neons = true, xenons = true, horn = true, + cosmetics = true, }, drawtextui = { text = "Customs Motorworks" @@ -181,6 +188,7 @@ Config.Locations = { enabled = true, }, categories = { + mods = true, repair = true, respray = true, liveries = true, @@ -191,6 +199,7 @@ Config.Locations = { neons = true, xenons = true, horn = true, + cosmetics = true, }, drawtextui = { text = "Harmony Motorworks" @@ -228,6 +237,7 @@ Config.Locations = { neons = true, xenons = true, horn = true, + cosmetics = true, }, drawtextui = { text = "Hayes Motorworks" @@ -255,6 +265,7 @@ Config.Locations = { enabled = true, }, categories = { + mods = true, repair = true, respray = true, liveries = true, @@ -265,6 +276,7 @@ Config.Locations = { neons = true, xenons = true, horn = true, + cosmetics = true, }, drawtextui = { text = "Billys Motorworks" @@ -292,6 +304,7 @@ Config.Locations = { enabled = true, }, categories = { + mods = true, repair = true, respray = true, liveries = true, @@ -302,6 +315,7 @@ Config.Locations = { neons = true, xenons = true, horn = true, + cosmetics = true, }, drawtextui = { text = "Tunershop", @@ -328,6 +342,7 @@ Config.Locations = { tint = true, extras = true, plate = true, + cosmetics = true, }, drawtextui = { text = "MRPD Motorworks", @@ -355,6 +370,7 @@ Config.Locations = { tint = true, extras = true, plate = true, + cosmetics = true, }, drawtextui = { text = "Pillbox Motorworks"