Qb-Garages ve2 Nopixel Inspired 4.0

that’s qb-garages v2 script, i just change the ui and modify circle zones with polyzones and i use karma-interaction not qb-core textui you can fin it here.
and i make some changes in code to load vehicle performance correctly
Happy to share !

Download : GitHub - TN-DEVV/qb-garages
Dependenciy: GitHub - TN-DEVV/karma-interaction: NoPixel 4.0 Interaction System Inspired

Code is accessible Yes
Support Yes
13 Likes

hey i installed the script and when i go to open a garage i get this error

1 Like

– table.sort(logs, function(a, b) return a.time > b.time end) comment this out on client/main it works fine

but if i do that it dont work :frowning_face: only menu :frowning:

if u wanna use the log just add this sql ALTER TABLE player_vehicles ADD logs LONGTEXT DEFAULT ‘’;

i do had some minor problem, first how can i add my addon car picture to the ui, second even i change true or false it still not working ‘Config.VisuallyDamageCars = true,’ , the car still spawn in full health with no visual damage.


if ur check f8 u can see this, how to fix this

1 Like

i tried everything i was only able to fix it thats all sadly :frowning: idk how to fix :slightly_frowning_face:

sorry dudes ! i add sql file, just delete ur player_vehicle table from database and import the new one i added to the script

Im not sure what am missing, but I cant depot the car I lost.

If I DV or just leave out, I cant Depot car from the last garage.

hello bro, it looks like you have to add protection to this script to prevent duplicate vehicles from occurring when stored or taken out of the garage.

yes same for me bro in depot no vehicle store

the workaround i did was make it not cost money

I did change in the config
Config.AutoRespawn = false

and in line 85 of server.lua
vehicles = MySQL.rawExecute.await(‘SELECT * FROM player_vehicles WHERE citizenid = ?’, { citizenId })

I also remove the lines that notify on the phone.

It wont charge you for depot, but w/e it works

2 Likes

anyone figure this out? i cant find out how

I made some changes and it works for me, adding the table that Menteri_Keriau mentioned.

client/main.lua:25

local function OpenGarageMenu(data)
    QBCore.Functions.TriggerCallback('qb-garages:server:GetGarageVehicles', function(result)
        if result == nil then return QBCore.Functions.Notify(Lang:t('error.no_vehicles'), 'error', 5000) end
        local formattedVehicles = {}
        for _, v in pairs(result) do
            local enginePercent = round(v.engine, 0)
            local bodyPercent = round(v.body, 0)
            local vname = nil
            pcall(function()
                vname = QBCore.Shared.Vehicles[v.vehicle].name
            end)
            local logs = json.decode(v.logs)
            if type(logs) ~= "table" then
                logs = {}
            end
            table.sort(logs, function(a, b) return a.time > b.time end)
            formattedVehicles[#formattedVehicles + 1] = {
                vehicle = v.vehicle,
                vehicleLabel = vname or v.vehicle,
                plate = v.plate,
                state = v.state,
                fuel = v.fuel,
                engine = enginePercent,
                body = bodyPercent,
                distance = v.drivingdistance or 0,
                garage = Config.Garages[data.indexgarage],
                type = data.type,
                index = data.indexgarage,
                depotPrice = v.depotprice or 0,
                balance = v.balance or 0,
                logs = logs
            }
        end
        SetNuiFocus(true, true)
        SendNUIMessage({
            action = 'VehicleList',
            garageLabel = Config.Garages[data.indexgarage].label,
            vehicles = formattedVehicles,
            vehNum = #formattedVehicles,
            resourceName = GetCurrentResourceName(),
            garageType = data.type,
            useCarImg = true
        })
    end, data.indexgarage, data.type, data.category)
end

server/main.lua:304

RegisterNetEvent('qb-garages:addGarageLog:server', function(data)
    local src = source
    local plate = data.plate
    local garage = data.garage
    local logType = data.type

    local result = MySQL.Sync.fetchAll('SELECT logs FROM player_vehicles WHERE plate = @plate', {
        ['@plate'] = plate
    })

    if result[1] then
        local logs = json.decode(result[1].logs) 
        if type(logs) ~= "table" then
            logs = {}
        end

        table.insert(logs, {
            time = os.date('%Y-%m-%d-%H:%M'),
            type = logType,
            garage = garage
        })

        MySQL.Sync.execute('UPDATE player_vehicles SET logs = @logs WHERE plate = @plate', {
            ['@logs'] = json.encode(logs),
            ['@plate'] = plate
        })
    else
        TriggerClientEvent('qb-garages:notify', src, 'Vehicle not found.')
    end
end)

I also recommend not using it as it has many errors. I would wait for someone who knows how to fix it completely

1 Like

Damages are also not working. When a vehicle is stored it does not save the damage.

Ill fix this and post an update soon

4 Likes

you can pull request sir from github.

hi, did you fix it ?

i have a issue with the vehicle mods not being saved and everything would be gone after a player takes the vehicle out ( color . mods and etc. )
also the job garages don’t work as well and there is no way to define a deference between sea, air, garage depots what should we do about it ?

nice release

Keep Up The Great Work :grin: