đŸ”Ŧ
RX Scripts
STOREDISCORD
  • 👋Overview
  • Find us
    • 🔗Store
    • 🔗Discord
    • 🔗Youtube
  • 🌐Scripts
    • Garages
      • đŸ› ī¸Installation
      • 📝Configurables
      • â†Ēī¸Exports
      • â†Šī¸Events
    • Reports PRO
      • đŸ› ī¸Installation
      • 📝Configurables
      • â†Ēī¸Exports
      • â†Šī¸Events
    • Mining
      • đŸ› ī¸Installation
      • 📝Configurables
      • â†Ēī¸Exports
      • â†Šī¸Events
    • Fishing
      • đŸ› ī¸Installation
      • 📝Configurables
      • â†Ēī¸Exports
      • â†Šī¸Events
    • Player Stores
      • đŸ› ī¸Installation
      • 🚚Jobs DLC
      • 📝Configurables
      • â†Ēī¸Exports
      • â†Šī¸Events
    • Drug Labs
      • đŸ› ī¸Installation
      • âœˆī¸Operation DLC
      • 📝Configurables
      • â†Ēī¸Exports
      • â†Šī¸Events
    • Hunting
      • đŸ› ī¸Installation
      • 📝Configurables
      • â†Ēī¸Exports
      • â†Šī¸Events
    • Plantation
      • đŸ› ī¸Installation
      • 📝Configurables
      • â†Ēī¸Exports
      • â†Šī¸Events
    • Gang Wars
      • đŸ› ī¸Installation
      • 📝Configurables
      • â†Šī¸Events
    • Housing
      • đŸ› ī¸Installation
      • 📝Configurables
      • â†Šī¸Events
    • Chopshop
      • đŸ› ī¸Installation
      • 📝Configurables
    • Death System
      • đŸ› ī¸Installation
      • 📝Configurables
      • â†Šī¸Events
    • Recyclers
      • đŸ› ī¸Installation
      • 📝Configurables
      • â†Ēī¸Exports
      • â†Šī¸Events
    • Smelters
      • đŸ› ī¸Installation
      • 📝Configurables
      • â†Ēī¸Exports
      • â†Šī¸Events
    • Crates & Storages
      • đŸ› ī¸Installation
      • 📝Configurables
      • â†Šī¸Exports
      • â†Šī¸Events
    • Black Markets
      • đŸ› ī¸Installation
      • 📝Configurables
    • Hazard Zones
      • đŸ› ī¸Installation
      • 📝Configurables
      • â†Ēī¸Exports
      • â†Šī¸Events
    • Report System
      • đŸ› ī¸Installation
      • 📝Configurables
      • â†Ēī¸Exports
      • â†Šī¸Events
    • Billing System
      • đŸ› ī¸Installation
      • â†Ēī¸Exports
      • â†Šī¸Events
Powered by GitBook
On this page
  • Config files
  • Opensource files
  1. Scripts
  2. Garages

Configurables

In this page, you can see everything that can be configured/changed within this script.

Config files

--[[
BY RX Scripts Š rxscripts.xyz
--]]

Config = {}

Config.Locale = 'en'
Config.RestrictVehiclesToLocations = true -- Restrict taking out vehicles to their saved locations (if false, the vehicles can be taken out no matter of the location)
Config.LocationMarkers = false -- Shows markers at locations (recommended to disable when using LocationNPCS/Target)
Config.LocationNPCS = true    -- Shows NPCs at locations (cannot be disabled if using target, will be applied to npc)
Config.ShowOverview = true -- Show overview page at garages
Config.NameCharactersLimit = 15 -- Limit the amount of characters in the vehicle name

Config.TransferVehicles = {
    toGarages = { -- Automatically disables when Config.RestrictVehiclesToLocations is set to false
        enabled = true,
        cost = 5000, -- Set to 0 to disable the transfer price
        moneyType = 'bank',
    },
    toPlayers = {
        enabled = true,
        showSteamName = true, -- Set to false if you want to hide the steam name, and only show the Player ID
        cost = 5000, -- Set to 0 to disable the transfer price
        moneyType = 'bank',
    }
}

Config.Settings = {
    garage = {
        car = {
            npcModel = 'csb_vagspeak',
            blip = {
                enabled = true,
                label = 'Garage',
                sprite = 524,
                color = 3,
                display = 2,
                scale = 0.7,
                shortrange = true,
            },
        },
        boat = {
            npcModel = 'cs_taostranslator',
            blip = {
                enabled = true,
                label = 'Garage',
                sprite = 410,
                color = 3,
                display = 2,
                scale = 0.7,
                shortrange = true,
            }
        },
        air = {
            npcModel = 'csb_agatha',
            blip = {
                enabled = true,
                label = 'Garage',
                sprite = 43,
                color = 3,
                display = 2,
                scale = 0.7,
                shortrange = true,
            }
        },
    },
    impound = {
        car = {
            npcModel = 'a_m_m_hillbilly_01',
            blip = {
                enabled = true,
                label = 'Impound',
                sprite = 524,
                color = 5,
                display = 2,
                scale = 0.7,
                shortrange = true,
            }
        },
        boat = {
            npcModel = 'a_m_m_hillbilly_01',
            blip = {
                enabled = true,
                label = 'Impound',
                sprite = 410,
                color = 5,
                display = 2,
                scale = 0.7,
                shortrange = true,
            }
        },
        air = {
            npcModel = 'a_m_m_hillbilly_01',
            blip = {
                enabled = true,
                label = 'Impound',
                sprite = 43,
                color = 5,
                display = 2,
                scale = 0.7,
                shortrange = true,
            }
        },
    },
    spawner = {
        car = {
            npcModel = 'csb_vagspeak',
            blip = {
                enabled = true,
                label = 'Job Garage',
                sprite = 524,
                color = 3,
                display = 2,
                scale = 0.7,
                shortrange = true,
            },
        },
        boat = {
            npcModel = 'cs_taostranslator',
            blip = {
                enabled = true,
                label = 'Job Garage',
                sprite = 410,
                color = 3,
                display = 2,
                scale = 0.7,
                shortrange = true,
            }
        },
        air = {
            npcModel = 'csb_agatha',
            blip = {
                enabled = true,
                label = 'Job Garage',
                sprite = 43,
                color = 3,
                display = 2,
                scale = 0.7,
                shortrange = true,
            }
        },
    }
}

Config.Impound = {
    releaseMoneyType = 'bank', -- Account from framework, to check/take money from on releasing a vehicle from the impound
    allowedJobs = {
        { job = 'police', minGrade = 0 },
    }
}

Config.VehicleWipe = {
    enabled = true,
    sendTo = 'garage', -- 'garage' or 'impound'
    wipeInterval = 30, -- Wipe interval in minutes
    inactiveTime = 5, -- Minutes a vehicle has to be inactive to be wiped
    notify = true, -- Send a notification before the wipe - inactivetime as reminder, and when the wipe has been done
}

Config.Commands = {
    openAdminPanel = 'garages:admin', -- /garages:admin | Open the admin garages panel
    openImpoundMenu = 'impound', -- /impound | Open the impound menu
}

--[[
    YOU CAN USE ACE PERMISSIONS TO ALLOW CERTAIN PLAYERS/GROUPS TO ACCESS THE ADMIN GARAGES PANEL
    EXAMPLE:
        add_ace group.admin garages allow
        add_ace identifier.fivem:1432744 garages allow #Rejox

    OR YOU CAN USE THE STAFF GROUPS BELOW
--]]
Config.StaffGroups = {
    'superadmin',
    'admin',
    'god',
}

--[[
    ONLY CHANGE THIS PART IF YOU HAVE RENAMED SCRIPTS SUCH AS FRAMEWORK, TARGET, INVENTORY ETC
    RENAME THE SCRIPT NAME TO THE NEW NAME
--]]
---@type table Only change these if you have changed the name of a resource
Resources = {
    FM = { name = 'fmLib', export = 'new' },
    OXTarget = { name = 'ox_target', export = 'all' },
    QBTarget = { name = 'qb-target', export = 'all' },
}
IgnoreScriptFoundLogs = false

Opensource files

--[[
BY RX Scripts Š rxscripts.xyz
--]]

---@param type 'open_car_garage' | 'open_boat_garage' | 'open_air_garage' | 'park_vehicle'
function ShowMarker(type, coords)
    if type == 'open_car_garage' then
        DrawMarker(36, coords, 0, 0, 0, 0, 0, 0, 1.0, 1.0, 1.0, 128, 2, 49, 100, false, false, 2, true, false, false,
            false)
    elseif type == 'open_boat_garage' then
        DrawMarker(35, coords, 0, 0, 0, 0, 0, 0, 1.0, 1.0, 1.0, 128, 2, 49, 100, false, false, 2, true, false, false,
            false)
    elseif type == 'open_air_garage' then
        DrawMarker(33, coords, 0, 0, 0, 0, 0, 0, 1.0, 1.0, 1.0, 128, 2, 49, 100, false, false, 2, true, false, false,
            false)
    elseif type == 'park_vehicle' then
        DrawMarker(1, coords, 0, 0, 0, 0, 0, 0, 3.0, 3.0, 0.5, 128, 2, 49, 100, false, false, 2, false, false, false, false)
    end
end

function AddOpenGarageTarget(garageId)
    local garage = Garages[garageId]

    if OXTarget then
        OXTarget:addLocalEntity(garage.ped, {
            {
                label = 'Open ' .. garage.name,
                name = 'openGarageNPC',
                icon = 'fas fa-trowel',
                distance = 2.5,
                onSelect = function(data)
                    OpenGarage(garage.name, garage.garageType, garage.vehicleType)
                end,
            }
        })
    elseif QBTarget then
        QBTarget:AddTargetEntity(garage.ped, {
            options = {
                {
                    label = 'Open ' .. garage.name,
                    icon = 'fas fa-trowel',
                    targeticon = 'fas fa-trowel',
                    action = function(entity)
                        OpenGarage(garage.name, garage.garageType, garage.vehicleType)
                    end,
                }
            },
            distance = 2.5,
        })
    end
end
--[[
BY RX Scripts Š rxscripts.xyz
--]]

Config.DiscordWebhook = ''

local function getSpawnerVehiclesFromDB(garageName)
    local garage = GetGarageByName(garageName)
    if not garage then return {} end

    return MySQL.query.await('SELECT * FROM `rx_spawner_vehicles` WHERE `garageId` = @garageId', {
        ['@garageId'] = garage.id
    }) or {}
end

local function filterVehiclesByVehicleType(vehicles, vehicleType)
    local correctVehicles = {}

    for _, v in pairs(vehicles) do
        local type = GetVehicleTypeByModel(v.vehicle)

        if type == vehicleType then
            v.type = type
            correctVehicles[#correctVehicles+1] = v
        end
    end

    return correctVehicles
end

function GetDBVehiclesTable()
    return GetResourceState('es_extended') == 'started' and 'owned_vehicles' or 'player_vehicles'
end

---@param identifier? string
function GetVehicleFromDB(identifier, plate)
    if GetResourceState('es_extended') == 'started' then
        if identifier then
            return MySQL.query.await('SELECT * FROM `owned_vehicles` WHERE `owner` = @identifier AND `plate` = @plate', {
                ['@identifier'] = identifier,
                ['@plate'] = plate
            })[1]
        else
            return MySQL.query.await('SELECT * FROM `owned_vehicles` WHERE `plate` = @plate', {
                ['@plate'] = plate
            })[1]
        end
    elseif GetResourceState('qb-core') == 'started' then
        if identifier then
            return MySQL.query.await('SELECT * FROM player_vehicles WHERE `citizenid` = @identifier AND `plate` = @plate', {
                ['@identifier'] = identifier,
                ['@plate'] = plate
            })[1]
        else
            return MySQL.query.await('SELECT * FROM player_vehicles WHERE `plate` = @plate', {
                ['@plate'] = plate
            })[1]
        end
    end

    return nil
end

function GetVehiclesByImpoundFromDB(garageName, vehicleType)
    if GetResourceState('es_extended') == 'started' then
        return MySQL.query.await('SELECT * FROM `owned_vehicles` WHERE `parked_at` = @parked_at AND `type` = @type AND `location` = @location', {
            ['@parked_at'] = 'impound',
            ['@type'] = vehicleType,
            ['@location'] = garageName
        }) or {}
    elseif GetResourceState('qb-core') == 'started' then
        local vehicles = MySQL.query.await('SELECT * FROM player_vehicles WHERE `parked_at` = @parked_at AND `location` = @location', {
            ['@parked_at'] = 'impound',
            ['@location'] = garageName
        })

        return vehicles and filterVehiclesByVehicleType(vehicles, vehicleType) or {}
    end
end

function GetVehiclesFromDB(identifier, garageName, garageType, vehicleType)
    if garageType == 'spawner' then
        return getSpawnerVehiclesFromDB(garageName)
    end

    if GetResourceState('es_extended') == 'started' then
        if garageType == 'garage' then
            return MySQL.query.await('SELECT * FROM `owned_vehicles` WHERE `owner` = @identifier AND `type` = @type', {
                ['@identifier'] = identifier,
                ['@type'] = vehicleType
            }) or {}
        elseif garageType == 'impound' then
            return MySQL.query.await('SELECT * FROM `owned_vehicles` WHERE `owner` = @identifier AND `parked_at` = @parked_at AND `type` = @type', {
                ['@identifier'] = identifier,
                ['@parked_at'] = garageType,
                ['@type'] = vehicleType
            }) or {}
        end
    elseif GetResourceState('qb-core') == 'started' then
        if garageType == 'garage' then
            local vehicles = MySQL.query.await('SELECT * FROM player_vehicles WHERE `citizenid` = @identifier', {
                ['@identifier'] = identifier,
            })

            return vehicles and filterVehiclesByVehicleType(vehicles, vehicleType) or {}
        elseif garageType == 'impound' then
            local vehicles = MySQL.query.await('SELECT * FROM player_vehicles WHERE `citizenid` = @identifier AND `parked_at` = @parked_at', {
                ['@identifier'] = identifier,
                ['@parked_at'] = garageType,
            })

            return vehicles and filterVehiclesByVehicleType(vehicles, vehicleType) or {}
        end
    end

    return {}
end

function StoreOutsideVehicles()
    MySQL.update.await('UPDATE `' .. GetDBVehiclesTable() ..'` SET `parked_at` = "garage" WHERE `parked_at` = "outside"')
end

function UpdateVehicleInDB(plate, kvTable)
    local setClauses = {}
    local parameters = {["@plate"] = plate}
    local dbTable = GetResourceState('es_extended') == 'started' and 'owned_vehicles' or 'player_vehicles'

    for k, v in pairs(kvTable) do
        local paramName = k
        if k == "plate" then
            paramName = "new_" .. k
        end

        if v == 'null' then
            table.insert(setClauses, k .. " = NULL")
        elseif k == 'mods' then
            local column = GetResourceState('es_extended') == 'started' and 'vehicle' or 'mods'
            table.insert(setClauses, column .. " = @" .. column)
            parameters["@" .. column] = json.encode(v)
        else
            table.insert(setClauses, k .. " = @" .. paramName)
            parameters["@" .. paramName] = (type(v) == 'table' or type(v) == 'vector4' or type(v) == 'vector3') and json.encode(v) or v
        end
    end

    local setQuery = table.concat(setClauses, ", ")
    local query = "UPDATE " .. dbTable .. " SET " .. setQuery .. " WHERE plate = @plate"

    return MySQL.update.await(query, parameters)
end

---@param plate? string
function CanImpoundVehicle(src, plate)
    plate = Trim(plate)
    local p = FM.player.get(src)
    local job = p.getJob()

    if job then
        for _, allowedJob in pairs(Config.Impound.allowedJobs) do
            if job.name == allowedJob.job and job.grade >= allowedJob.minGrade then
                return true
            end
        end
    end

    return false
end

function AddOutsideVehicleToDB(identifier, plate, mods, vehicleType, displayName, model)
    local isESX = GetResourceState('es_extended') == 'started'
    local modsColumn = isESX and 'vehicle' or 'mods'
    local ownerColumn = isESX and 'owner' or 'citizenid'
    local type = VehicleTypes[vehicleType]

    local columns = {ownerColumn, 'plate', 'parked_at', modsColumn}
    local values = {'@owner', '@plate', '@parked_at', '@mods'}
    local parameters = {
        ['@owner'] = identifier,
        ['@plate'] = plate,
        ['@mods'] = json.encode(mods),
        ['@parked_at'] = 'outside',
    }

    if isESX then
        table.insert(columns, 'type')
        table.insert(values, '@type')
        parameters['@type'] = type
    else
        table.insert(columns, 'vehicle')
        table.insert(values, '@vehicle')
        parameters['@vehicle'] = displayName and string.lower(displayName) or nil

        table.insert(columns, 'hash')
        table.insert(values, '@hash')
        parameters['@hash'] = model

        table.insert(columns, 'license')
        table.insert(values, '@license')

        if GetResourceState('qb-core') == 'started' then
            if not QBCore then QBCore = exports['qb-core']:GetCoreObject() end
        end

        parameters['@license'] = QBCore.Functions.GetPlayerByCitizenId(identifier).PlayerData.license
    end

    local columnsStr = '`' .. table.concat(columns, '`, `') .. '`'
    local valuesStr = table.concat(values, ', ')

    local query = 'INSERT INTO `' .. GetDBVehiclesTable() .. '` (' .. columnsStr .. ') VALUES (' .. valuesStr .. ')'

    return MySQL.insert.await(query, parameters)
end
PreviousInstallationNextExports

Last updated 2 months ago

🌐
📝