Garage

For correct operation, follow the instructions indicated

If your vehicle is not inserted into the database according to your framework, either because it has been modified or is not compatible with your garage, check your database and modify this function for correct operation. If you do not know how to edit it, open a ticket and we will do it for you.

jc_coins/Editable/Server/SMain.lua:

function saveVIPVehicleToDB(xPlayer, plate, model, color)
    if Config.Framework == "esx" then
        local vehicleData = {
            model = GetHashKey(model),
            plate = plate,
            color1 = { r = color[1], g = color[2], b = color[3] },
            color2 = { r = color[1], g = color[2], b = color[3] }
        }

        exports.oxmysql:insert('INSERT INTO owned_vehicles (owner, plate, vehicle, type, stored) VALUES (?, ?, ?, ?, ?)', {
            xPlayer.identifier,
            plate,
            json.encode(vehicleData),
            'car',
            true
        }, function(id)
            if id then
                print(('[VIP-ESX] Vehículo guardado para %s: %s (ID: %s)'):format(xPlayer.getName(), plate, id))
            else
                print('[VIP-ESX] Error al guardar el vehículo.')
            end
        end)

    elseif Config.Framework == "qb" then
        local mods = {
            color1 = color[1],
            color2 = color[2],
            plate = plate,
            fuelLevel = 100.0,
        }

        exports.oxmysql:insert('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, garage, fuel, engine, body, state, garage_id, garage_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', {
            xPlayer.PlayerData.license,
            xPlayer.PlayerData.citizenid,
            model,
            tostring(GetHashKey(model)),
            json.encode(mods),
            plate,
            "pillboxgarage",
            100,
            1000.0,
            1000.0,
            1,
            "A",
            "car"
        }, function(id)
            if id then
                print(('[VIP-QB] Vehículo guardado para %s: %s (ID: %s)'):format(xPlayer.PlayerData.name, plate, id))
            else
                print('[VIP-QB] Error al guardar el vehículo.')
            end
        end)
    end
end

Last updated