Skip to content

Commit

Permalink
Merge pull request #81 from ItsANoBrainer/dev3-ImGoingCrazy
Browse files Browse the repository at this point in the history
[Updates] README Update, Debug Prints, Repair Only, Cosmetics Option
  • Loading branch information
GhzGarage authored Mar 28, 2022
2 parents 82ce133 + 555e5ca commit 389fe87
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 12 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
46 changes: 40 additions & 6 deletions client/cl_bennys.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-----------------------
---- Variables ----
-----------------------
local QBCore = exports['qb-core']:GetCoreObject()
QBCore = exports['qb-core']:GetCoreObject()
local PlayerData = QBCore.Functions.GetPlayerData()
local CustomsData = {}

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down
17 changes: 12 additions & 5 deletions client/cl_ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions config.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 17 additions & 1 deletion shared/locations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -28,6 +28,7 @@
xenons = true,
horn = true,
turbo = true,
cosmetics = true, -- Cosmetic Mods
},
drawtextui = {
text = "Bennys Motorworks",
Expand Down Expand Up @@ -70,6 +71,7 @@ Config.Locations = {
enabled = true,
},
categories = {
mods = true,
repair = true,
respray = true,
liveries = true,
Expand All @@ -80,6 +82,7 @@ Config.Locations = {
neons = true,
xenons = true,
horn = true,
cosmetics = true,
},
drawtextui = {
text = "Bennys Motorworks"
Expand Down Expand Up @@ -107,6 +110,7 @@ Config.Locations = {
enabled = true,
},
categories = {
mods = true,
repair = true,
respray = true,
liveries = true,
Expand All @@ -117,6 +121,7 @@ Config.Locations = {
neons = true,
xenons = true,
horn = true,
cosmetics = true,
},
drawtextui = {
text = "Bennys Motorworks"
Expand Down Expand Up @@ -144,6 +149,7 @@ Config.Locations = {
enabled = true,
},
categories = {
mods = true,
repair = true,
respray = true,
liveries = true,
Expand All @@ -154,6 +160,7 @@ Config.Locations = {
neons = true,
xenons = true,
horn = true,
cosmetics = true,
},
drawtextui = {
text = "Customs Motorworks"
Expand Down Expand Up @@ -181,6 +188,7 @@ Config.Locations = {
enabled = true,
},
categories = {
mods = true,
repair = true,
respray = true,
liveries = true,
Expand All @@ -191,6 +199,7 @@ Config.Locations = {
neons = true,
xenons = true,
horn = true,
cosmetics = true,
},
drawtextui = {
text = "Harmony Motorworks"
Expand Down Expand Up @@ -228,6 +237,7 @@ Config.Locations = {
neons = true,
xenons = true,
horn = true,
cosmetics = true,
},
drawtextui = {
text = "Hayes Motorworks"
Expand Down Expand Up @@ -255,6 +265,7 @@ Config.Locations = {
enabled = true,
},
categories = {
mods = true,
repair = true,
respray = true,
liveries = true,
Expand All @@ -265,6 +276,7 @@ Config.Locations = {
neons = true,
xenons = true,
horn = true,
cosmetics = true,
},
drawtextui = {
text = "Billys Motorworks"
Expand Down Expand Up @@ -292,6 +304,7 @@ Config.Locations = {
enabled = true,
},
categories = {
mods = true,
repair = true,
respray = true,
liveries = true,
Expand All @@ -302,6 +315,7 @@ Config.Locations = {
neons = true,
xenons = true,
horn = true,
cosmetics = true,
},
drawtextui = {
text = "Tunershop",
Expand All @@ -328,6 +342,7 @@ Config.Locations = {
tint = true,
extras = true,
plate = true,
cosmetics = true,
},
drawtextui = {
text = "MRPD Motorworks",
Expand Down Expand Up @@ -355,6 +370,7 @@ Config.Locations = {
tint = true,
extras = true,
plate = true,
cosmetics = true,
},
drawtextui = {
text = "Pillbox Motorworks"
Expand Down

0 comments on commit 389fe87

Please sign in to comment.