💻Installation

How to install the script

1. Run Database

  1. Open the file database.sql

  2. Open your database and run it

2. ⚠️ IMPORTANT (Garage and Spawn)

Custom Garage

Export to add for CUSTOM GARAGE (false in clConfig.GarageEnable)

WARNING: Upon the first run of the script, all vehicles will be placed in a garage. If you're using custom garages, remove all vehicles from various impound lots (putting them in a garage) and deactivate any impound functions present in your custom garage. Then, you'll need to use my impound. If you delete some vehicles from my database, the same logic will apply, returning them to the pre-set garage in your garage table.

Our Garage

(true in clConfig.GarageEnable): If you wish to utilize our garage system, all vehicles are initially placed in a random garage registered in the garagesConfig. This process only occurs the first time you use the script, or if you delete some vehicles from my database, in which case they will be reinserted into a random garage. Afterwards, you can freely move your vehicles, and everything will function smoothly.

No Garage

(false in clConfig.GarageEnable): If you're not using any garage system initially, we recommend starting with "true" to enable our garage. This allows users to remove their vehicles from the garage. Afterwards, you can disable the garage system to give vehicles a designated position to stay.

3. Configuration

You can modify many aspects of our script according to your framework and some scripts you use.

All in the folder /editable

Explentation /editable/Config.lua

svConfig = {
    Framework = "QBCORE", -- ESX/QBCORE/CUSTOM 
    Blip = { ---- GPS
        enabled = true,
        style = 227,
        display = 2,
        scale = 0.6,
        color = 0
    }
}

if svConfig.Framework == "ESX" then
    svConfig.ColumnPropName = 'vehicle'         -- the name of the column with the prop of the vehicle (vehicleshoptable)
    svConfig.ColumnOwnerName = 'owner'         -- the name of the column with the owner (vehicleshoptable)
    svConfig.ColumnPlateName = 'plate'         -- the name of the column with the plate (vehicleshoptable)
    svConfig.Tablename = 'owned_vehicles' -- the name of the table where you find plate and prop of the vehicle (vehicleshoptable)
elseif svConfig.Framework == "QBCORE" then
    svConfig.ColumnPropName = 'mods'         -- the name of the column with the prop of the vehicle (vehicleshoptable)
    svConfig.ColumnOwnerName = 'license'         -- the name of the column with the owner (vehicleshoptable)
    svConfig.ColumnPlateName = 'plate'         -- the name of the column with the plate (vehicleshoptable)
    svConfig.Tablename = 'player_vehicles' -- the name of the table where you find plate and prop of the vehicle (vehicleshoptable)
else
    svConfig.ColumnPropName = ''         -- the name of the column with the prop of the vehicle (vehicleshoptable)
    svConfig.ColumnOwnerName = ''         -- the name of the column with the owner (vehicleshoptable)
    svConfig.ColumnPlateName = ''         -- the name of the column with the plate (vehicleshoptable)
    svConfig.Tablename = '' -- the name of the table where you find plate and prop of the vehicle (vehicleshoptable)
end


clConfig = {
    vehiclespawnheading =229.14476013184,
    impoundcoords= vec3(409.874176, -1623.357788, 29.291956),
    impoundHeading = 0,
    impoundGarageCamera = {
        coords = vec3(405.473663, -1630.699585, 32.693623),
        rotation = vec3(0.000000, -0.000000, -159.408722)
    },
    vehiclespawncoords = vec3(408.299194, -1638.614502, 29.291956),
    impoundprice = 0,
    currency = "$",
    openmenukey = 51,
    blip = {
        enable = true,
        sprite = 50,
        color = 0,
        display = 2,
        size = 1.0,
    },
    Locale = {
        impound = "Impound",
        impoundm = "Impound Menu",
        wait = "Wait 5 second...",
        vehiclenotfound = "Vehicle not found!",
        emptyarea ="Area not empty!",
        press = "Press ~INPUT_PICKUP~ to open impound menu",
        noemptyvehicle = "Vehicle isn't empty!",
        loading = "Loading assets",
    },
    EnableDeformation = true, --- BETA
    GarageEnable = true, 
}


GarageLocale = {
    SettingChanged = "Settings Changed!",
    CarSpawned = "Car spawned!",
    NearEntity = "There's some vehicle near the spawn point",
    VehicleDespawned = "Vehicle Despawned!",
    NotYourVehicle = "This vehicle isn't yours",
    LeaveYourVehicle = "Press ~INPUT_PICKUP~ to park your vehicle in the garage",
    OpenMenu = "Press ~INPUT_PICKUP~ to open the garage menu",
}

garagesConfig = {
    ['centralpark'] = {
        Title = "Garage Central",
        MarkerCoords = vec3(224.93, -791.1, 30.7),
        CameraCoords =  {
            coords = vec3(236.169662, -803.035767, 30.177063),
            rotation = vec3(0.000000, -0.000000, 111.114067)
        },
        SpawnCoords = {
            coords = vec3(229.404892, -807.967102, 30.497652),
            heading = 160.34858703613
        }
    },
    ['2-teatro'] = {
        Title = "Garage Teatro",
        MarkerCoords = vec3(643.849060, 619.011353, 128.911057),
        CameraCoords =  {
            coords = vec3(647.941833, 615.945557, 128.911057),
            rotation = vec3(-0.000000, -0.000000, -53.180214)
        },
        SpawnCoords = {
            coords = vec3(653.667664, 620.077576, 128.911057),
            heading = 333.35238647461
        }
    },
    ['police'] = {
        Title = "Garage Police Station",
        MarkerCoords = vec3(643.849060, 619.011353, 128.911057),
        CameraCoords =  {
            coords = vec3(647.941833, 615.945557, 128.911057),
            rotation = vec3(-0.000000, -0.000000, -53.180214)
        },
        SpawnCoords = {
            coords = vec3(653.667664, 620.077576, 128.911057),
            heading = 333.35238647461
        }
    },
    ['police'] = {
        Title = "Garage Police Station",
        MarkerCoords = vec3(428.119598, -1016.908508, 28.959061),
        CameraCoords =  {
            coords = vec3(435.770416, -1026.576782, 28.836340),
            rotation = vec3(0.000000, 0.000000, 58.624420)
        },
        SpawnCoords = {
            coords = vec3(430.405365, -1021.759033, 28.825375),
            heading = 88.94441986084
        }
    },
    ['paleto'] = {
        Title = "Garage Paleto",
        MarkerCoords = vec3(-445.828430, 6047.094727, 31.340557),
        CameraCoords =  {
            coords = vec3(-449.024414, 6045.612793, 31.340553),
            rotation = vec3(0.000000, -0.000000, -122.982864)
        },
        SpawnCoords = {
            coords = vec3(-439.675751, 6039.982422, 31.340557),
            heading = 285.19836425781
        }
    }
}

svConfig:

  • Framework: Specifies the framework being used (ESX, QBCORE, or CUSTOM).

  • Blip:

    • enabled: Indicates whether the GPS blip feature is enabled .

Depending on the framework specified, different configurations are set:

  • ColumnPropName: Name of the column storing vehicle properties.

  • ColumnOwnerName: Name of the column storing vehicle owner information.

  • ColumnPlateName: Name of the column storing vehicle plate information.

  • Tablename: Name of the table containing vehicle data.

clConfig:

  • vehiclespawnheading: Heading angle for vehicle spawning.

  • impoundcoords: Coordinates for impound location.

  • impoundHeading: Heading angle for impound location.

  • impoundGarageCamera: Coordinates and rotation for the impound garage camera.

  • vehiclespawncoords: Coordinates for vehicle spawn point.

  • impoundprice: Impound price.

  • currency: Currency symbol.

  • openmenukey: Key to open menu.

  • blip: Blip settings.

  • Locale: Localization strings for messages and notifications.

  • GarageEnable: Indicates whether the garage feature is (true/false) Check GARAGE section

  • EnableDeformation: If you want vehicle deformations to be saved, set it to true, but remember that this is a new beta setting. (Beta Version)

GarageLocale:

  • Localization strings for garage-related UI elements.

garagesConfig:

  • Configuration for our garages:

    • Title: Name of the garage.

    • MarkerCoords: Coordinates of the marker indicating the garage location.

    • CameraCoords: Coordinates and rotation for the garage camera.

    • SpawnCoords: Coordinates and heading for vehicle spawn point within the garage.

Explentation /editable/editclient.lua

function Round(value, numDecimalPlaces)
    if numDecimalPlaces then
        local power = 10 ^ numDecimalPlaces
        return math.floor((value * power) + 0.5) / (power)
    else
        return math.floor(value + 0.5)
    end
end

function Trim(value)
    if value then
        return (string.gsub(value, "^%s*(.-)%s*$", "%1"))
    else
        return nil
    end
end

function GetVehicleProperties(vehicle)
   
    if not DoesEntityExist(vehicle) then
        return
    end

    local colorPrimary, colorSecondary = GetVehicleColours(vehicle)
    local pearlescentColor, wheelColor = GetVehicleExtraColours(vehicle)
    local hasCustomPrimaryColor = GetIsVehiclePrimaryColourCustom(vehicle)
    local dashboardColor = GetVehicleDashboardColor(vehicle)
    local interiorColor = GetVehicleInteriorColour(vehicle)
    local customPrimaryColor = nil
    if hasCustomPrimaryColor then
        customPrimaryColor = { GetVehicleCustomPrimaryColour(vehicle) }
    end

    local hasCustomXenonColor, customXenonColorR, customXenonColorG, customXenonColorB = GetVehicleXenonLightsCustomColor(
        vehicle)
    local customXenonColor = nil
    if hasCustomXenonColor then
        customXenonColor = { customXenonColorR, customXenonColorG, customXenonColorB }
    end

    local hasCustomSecondaryColor = GetIsVehicleSecondaryColourCustom(vehicle)
    local customSecondaryColor = nil
    if hasCustomSecondaryColor then
        customSecondaryColor = { GetVehicleCustomSecondaryColour(vehicle) }
    end

    local extras = {}
    for extraId = 0, 12 do
        if DoesExtraExist(vehicle, extraId) then
            extras[tostring(extraId)] = IsVehicleExtraTurnedOn(vehicle, extraId)
        end
    end

    local doorsBroken, windowsBroken, tyreBurst = {}, {}, {}
    local numWheels = tostring(GetVehicleNumberOfWheels(vehicle))

    local TyresIndex = {             -- Wheel index list according to the number of vehicle wheels.
        ['2'] = { 0, 4 },            -- Bike and cycle.
        ['3'] = { 0, 1, 4, 5 },      -- Vehicle with 3 wheels (get for wheels because some 3 wheels vehicles have 2 wheels on front and one rear or the reverse).
        ['4'] = { 0, 1, 4, 5 },      -- Vehicle with 4 wheels.
        ['6'] = { 0, 1, 2, 3, 4, 5 } -- Vehicle with 6 wheels.
    }

    if TyresIndex[numWheels] then
        for tyre, idx in pairs(TyresIndex[numWheels]) do
            tyreBurst[tostring(idx)] = IsVehicleTyreBurst(vehicle, idx, false)
        end
    end

    for windowId = 0, 7 do -- 13
        windowsBroken[tostring(windowId)] = not IsVehicleWindowIntact(vehicle, windowId)
    end

    local numDoors = GetNumberOfVehicleDoors(vehicle)
    if numDoors and numDoors > 0 then
        for doorsId = 0, numDoors do
            doorsBroken[tostring(doorsId)] = IsVehicleDoorDamaged(vehicle, doorsId)
        end
    end

    return {
        model = GetEntityModel(vehicle),
        doorsBroken = doorsBroken,
        windowsBroken = windowsBroken,
        tyreBurst = tyreBurst,
        plate = Trim(GetVehicleNumberPlateText(vehicle)),
        plateIndex = GetVehicleNumberPlateTextIndex(vehicle),

        bodyHealth = Round(GetVehicleBodyHealth(vehicle), 1),
        engineHealth = Round(GetVehicleEngineHealth(vehicle), 1),
        tankHealth = Round(GetVehiclePetrolTankHealth(vehicle), 1),

        fuelLevel = Round(GetVehicleFuelLevel(vehicle), 1),
        dirtLevel = Round(GetVehicleDirtLevel(vehicle), 1),
        color1 = colorPrimary,
        color2 = colorSecondary,
        customPrimaryColor = customPrimaryColor,
        customSecondaryColor = customSecondaryColor,

        pearlescentColor = pearlescentColor,
        wheelColor = wheelColor,

        dashboardColor = dashboardColor,
        interiorColor = interiorColor,

        wheels = GetVehicleWheelType(vehicle),
        windowTint = GetVehicleWindowTint(vehicle),
        xenonColor = GetVehicleXenonLightsColor(vehicle),
        customXenonColor = customXenonColor,

        neonEnabled = { IsVehicleNeonLightEnabled(vehicle, 0), IsVehicleNeonLightEnabled(vehicle, 1),
            IsVehicleNeonLightEnabled(vehicle, 2), IsVehicleNeonLightEnabled(vehicle, 3) },

        neonColor = table.pack(GetVehicleNeonLightsColour(vehicle)),
        extras = extras,
        tyreSmokeColor = table.pack(GetVehicleTyreSmokeColor(vehicle)),

        modSpoilers = GetVehicleMod(vehicle, 0),
        modFrontBumper = GetVehicleMod(vehicle, 1),
        modRearBumper = GetVehicleMod(vehicle, 2),
        modSideSkirt = GetVehicleMod(vehicle, 3),
        modExhaust = GetVehicleMod(vehicle, 4),
        modFrame = GetVehicleMod(vehicle, 5),
        modGrille = GetVehicleMod(vehicle, 6),
        modHood = GetVehicleMod(vehicle, 7),
        modFender = GetVehicleMod(vehicle, 8),
        modRightFender = GetVehicleMod(vehicle, 9),
        modRoof = GetVehicleMod(vehicle, 10),

        modEngine = GetVehicleMod(vehicle, 11),
        modBrakes = GetVehicleMod(vehicle, 12),
        modTransmission = GetVehicleMod(vehicle, 13),
        modHorns = GetVehicleMod(vehicle, 14),
        modSuspension = GetVehicleMod(vehicle, 15),
        modArmor = GetVehicleMod(vehicle, 16),

        modTurbo = IsToggleModOn(vehicle, 18),
        modSmokeEnabled = IsToggleModOn(vehicle, 20),
        modXenon = IsToggleModOn(vehicle, 22),

        modFrontWheels = GetVehicleMod(vehicle, 23),
        modBackWheels = GetVehicleMod(vehicle, 24),

        modPlateHolder = GetVehicleMod(vehicle, 25),
        modVanityPlate = GetVehicleMod(vehicle, 26),
        modTrimA = GetVehicleMod(vehicle, 27),
        modOrnaments = GetVehicleMod(vehicle, 28),
        modDashboard = GetVehicleMod(vehicle, 29),
        modDial = GetVehicleMod(vehicle, 30),
        modDoorSpeaker = GetVehicleMod(vehicle, 31),
        modSeats = GetVehicleMod(vehicle, 32),
        modSteeringWheel = GetVehicleMod(vehicle, 33),
        modShifterLeavers = GetVehicleMod(vehicle, 34),
        modAPlate = GetVehicleMod(vehicle, 35),
        modSpeakers = GetVehicleMod(vehicle, 36),
        modTrunk = GetVehicleMod(vehicle, 37),
        modHydrolic = GetVehicleMod(vehicle, 38),
        modEngineBlock = GetVehicleMod(vehicle, 39),
        modAirFilter = GetVehicleMod(vehicle, 40),
        modStruts = GetVehicleMod(vehicle, 41),
        modArchCover = GetVehicleMod(vehicle, 42),
        modAerials = GetVehicleMod(vehicle, 43),
        modTrimB = GetVehicleMod(vehicle, 44),
        modTank = GetVehicleMod(vehicle, 45),
        modDoorR = GetVehicleMod(vehicle, 47),
        modLivery = GetVehicleMod(vehicle, 48) == -1 and GetVehicleLivery(vehicle) or GetVehicleMod(vehicle, 48),
        modLightbar = GetVehicleMod(vehicle, 49)
    }
end

function SetVehicleProperties(vehicle, props)
  
    if not DoesEntityExist(vehicle) then
        return
    end
    local colorPrimary, colorSecondary = GetVehicleColours(vehicle)
    local pearlescentColor, wheelColor = GetVehicleExtraColours(vehicle)
    SetVehicleModKit(vehicle, 0)

    if props.plate ~= nil then
        SetVehicleNumberPlateText(vehicle, props.plate)
    end
    if props.plateIndex ~= nil then
        SetVehicleNumberPlateTextIndex(vehicle, props.plateIndex)
    end
    if props.bodyHealth ~= nil then
        SetVehicleBodyHealth(vehicle, props.bodyHealth + 0.0)
    end
    if props.engineHealth ~= nil then
        SetVehicleEngineHealth(vehicle, props.engineHealth + 0.0)
    end
    if props.tankHealth ~= nil then
        SetVehiclePetrolTankHealth(vehicle, props.tankHealth + 0.0)
    end
    if props.fuelLevel ~= nil then
        SetVehicleFuelLevel(vehicle, props.fuelLevel + 0.0)
    end
    if props.dirtLevel ~= nil then
        SetVehicleDirtLevel(vehicle, props.dirtLevel + 0.0)
    end
    if props.customPrimaryColor ~= nil then
        SetVehicleCustomPrimaryColour(vehicle, props.customPrimaryColor[1], props.customPrimaryColor[2],
            props.customPrimaryColor[3])
    end
    if props.customSecondaryColor ~= nil then
        SetVehicleCustomSecondaryColour(vehicle, props.customSecondaryColor[1], props.customSecondaryColor[2],
            props.customSecondaryColor[3])
    end
    if props.color1 ~= nil then
        SetVehicleColours(vehicle, props.color1, colorSecondary)
    end
    if props.color2 ~= nil then
        SetVehicleColours(vehicle, props.color1 or colorPrimary, props.color2)
    end
    if props.pearlescentColor ~= nil then
        SetVehicleExtraColours(vehicle, props.pearlescentColor, wheelColor)
    end

    if props.interiorColor ~= nil then
        SetVehicleInteriorColor(vehicle, props.interiorColor)
    end

    if props.dashboardColor ~= nil then
        SetVehicleDashboardColor(vehicle, props.dashboardColor)
    end

    if props.wheelColor ~= nil then
        SetVehicleExtraColours(vehicle, props.pearlescentColor or pearlescentColor, props.wheelColor)
    end
    if props.wheels ~= nil then
        SetVehicleWheelType(vehicle, props.wheels)
    end
    if props.windowTint ~= nil then
        SetVehicleWindowTint(vehicle, props.windowTint)
    end

    if props.neonEnabled ~= nil then
        SetVehicleNeonLightEnabled(vehicle, 0, props.neonEnabled[1])
        SetVehicleNeonLightEnabled(vehicle, 1, props.neonEnabled[2])
        SetVehicleNeonLightEnabled(vehicle, 2, props.neonEnabled[3])
        SetVehicleNeonLightEnabled(vehicle, 3, props.neonEnabled[4])
    end

    if props.extras ~= nil then
        for extraId, enabled in pairs(props.extras) do
            SetVehicleExtra(vehicle, tonumber(extraId), enabled and 0 or 1)
        end
    end

    if props.neonColor ~= nil then
        SetVehicleNeonLightsColour(vehicle, props.neonColor[1], props.neonColor[2], props.neonColor[3])
    end
    if props.xenonColor ~= nil then
        SetVehicleXenonLightsColor(vehicle, props.xenonColor)
    end
    if props.customXenonColor ~= nil then
        SetVehicleXenonLightsCustomColor(vehicle, props.customXenonColor[1], props.customXenonColor[2],
            props.customXenonColor[3])
    end
    if props.modSmokeEnabled ~= nil then
        ToggleVehicleMod(vehicle, 20, true)
    end
    if props.tyreSmokeColor ~= nil then
        SetVehicleTyreSmokeColor(vehicle, props.tyreSmokeColor[1], props.tyreSmokeColor[2], props.tyreSmokeColor[3])
    end
    if props.modSpoilers ~= nil then
        SetVehicleMod(vehicle, 0, props.modSpoilers, false)
    end
    if props.modFrontBumper ~= nil then
        SetVehicleMod(vehicle, 1, props.modFrontBumper, false)
    end
    if props.modRearBumper ~= nil then
        SetVehicleMod(vehicle, 2, props.modRearBumper, false)
    end
    if props.modSideSkirt ~= nil then
        SetVehicleMod(vehicle, 3, props.modSideSkirt, false)
    end
    if props.modExhaust ~= nil then
        SetVehicleMod(vehicle, 4, props.modExhaust, false)
    end
    if props.modFrame ~= nil then
        SetVehicleMod(vehicle, 5, props.modFrame, false)
    end
    if props.modGrille ~= nil then
        SetVehicleMod(vehicle, 6, props.modGrille, false)
    end
    if props.modHood ~= nil then
        SetVehicleMod(vehicle, 7, props.modHood, false)
    end
    if props.modFender ~= nil then
        SetVehicleMod(vehicle, 8, props.modFender, false)
    end
    if props.modRightFender ~= nil then
        SetVehicleMod(vehicle, 9, props.modRightFender, false)
    end
    if props.modRoof ~= nil then
        SetVehicleMod(vehicle, 10, props.modRoof, false)
    end
    if props.modEngine ~= nil then
        SetVehicleMod(vehicle, 11, props.modEngine, false)
    end
    if props.modBrakes ~= nil then
        SetVehicleMod(vehicle, 12, props.modBrakes, false)
    end
    if props.modTransmission ~= nil then
        SetVehicleMod(vehicle, 13, props.modTransmission, false)
    end
    if props.modHorns ~= nil then
        SetVehicleMod(vehicle, 14, props.modHorns, false)
    end
    if props.modSuspension ~= nil then
        SetVehicleMod(vehicle, 15, props.modSuspension, false)
    end
    if props.modArmor ~= nil then
        SetVehicleMod(vehicle, 16, props.modArmor, false)
    end
    if props.modTurbo ~= nil then
        ToggleVehicleMod(vehicle, 18, props.modTurbo)
    end
    if props.modXenon ~= nil then
        ToggleVehicleMod(vehicle, 22, props.modXenon)
    end
    if props.modFrontWheels ~= nil then
        SetVehicleMod(vehicle, 23, props.modFrontWheels, false)
    end
    if props.modBackWheels ~= nil then
        SetVehicleMod(vehicle, 24, props.modBackWheels, false)
    end
    if props.modPlateHolder ~= nil then
        SetVehicleMod(vehicle, 25, props.modPlateHolder, false)
    end
    if props.modVanityPlate ~= nil then
        SetVehicleMod(vehicle, 26, props.modVanityPlate, false)
    end
    if props.modTrimA ~= nil then
        SetVehicleMod(vehicle, 27, props.modTrimA, false)
    end
    if props.modOrnaments ~= nil then
        SetVehicleMod(vehicle, 28, props.modOrnaments, false)
    end
    if props.modDashboard ~= nil then
        SetVehicleMod(vehicle, 29, props.modDashboard, false)
    end
    if props.modDial ~= nil then
        SetVehicleMod(vehicle, 30, props.modDial, false)
    end
    if props.modDoorSpeaker ~= nil then
        SetVehicleMod(vehicle, 31, props.modDoorSpeaker, false)
    end
    if props.modSeats ~= nil then
        SetVehicleMod(vehicle, 32, props.modSeats, false)
    end
    if props.modSteeringWheel ~= nil then
        SetVehicleMod(vehicle, 33, props.modSteeringWheel, false)
    end
    if props.modShifterLeavers ~= nil then
        SetVehicleMod(vehicle, 34, props.modShifterLeavers, false)
    end
    if props.modAPlate ~= nil then
        SetVehicleMod(vehicle, 35, props.modAPlate, false)
    end
    if props.modSpeakers ~= nil then
        SetVehicleMod(vehicle, 36, props.modSpeakers, false)
    end
    if props.modTrunk ~= nil then
        SetVehicleMod(vehicle, 37, props.modTrunk, false)
    end
    if props.modHydrolic ~= nil then
        SetVehicleMod(vehicle, 38, props.modHydrolic, false)
    end
    if props.modEngineBlock ~= nil then
        SetVehicleMod(vehicle, 39, props.modEngineBlock, false)
    end
    if props.modAirFilter ~= nil then
        SetVehicleMod(vehicle, 40, props.modAirFilter, false)
    end
    if props.modStruts ~= nil then
        SetVehicleMod(vehicle, 41, props.modStruts, false)
    end
    if props.modArchCover ~= nil then
        SetVehicleMod(vehicle, 42, props.modArchCover, false)
    end
    if props.modAerials ~= nil then
        SetVehicleMod(vehicle, 43, props.modAerials, false)
    end
    if props.modTrimB ~= nil then
        SetVehicleMod(vehicle, 44, props.modTrimB, false)
    end
    if props.modTank ~= nil then
        SetVehicleMod(vehicle, 45, props.modTank, false)
    end
    if props.modWindows ~= nil then
        SetVehicleMod(vehicle, 46, props.modWindows, false)
    end

    if props.modLivery ~= nil then
        SetVehicleMod(vehicle, 48, props.modLivery, false)
        SetVehicleLivery(vehicle, props.modLivery)
    end

    if props.windowsBroken ~= nil then
        for k, v in pairs(props.windowsBroken) do
            if v then
                SmashVehicleWindow(vehicle, tonumber(k))
            end
        end
    end

    if props.doorsBroken ~= nil then
        for k, v in pairs(props.doorsBroken) do
            if v then
                SetVehicleDoorBroken(vehicle, tonumber(k), true)
            end
        end
    end

    if props.tyreBurst ~= nil then
        for k, v in pairs(props.tyreBurst) do
            if v then
                SetVehicleTyreBurst(vehicle, tonumber(k), true, 1000.0)
            end
        end
    end
end

Here you can modify the GetVehicleProperties and SetVehicleProperties functions according to the tuning script you use. Many scripts have custom functions for saving vehicle skins.

Explentation /editable/editserver.Lua

function GetIdentifier(source) ---- To compare Owner of the car and players in game (this function need if you use CHAR1/CHAR2 etc) and blip
    if svConfig.Framework == "ESX" then
        ESX = exports['es_extended']:getSharedObject()
        local xPlayer = ESX.GetPlayerFromId(source)

        if xPlayer ~= nil then
            return xPlayer.identifier
        else
            return nil
        end
    elseif svConfig.Framework == "QBCORE" then
        return GetPlayerIdentifier(source, 0)
    else
        
        return GetPlayerIdentifier(source, 0):gsub("license:", "")
    end
end



RegisterServerEvent("df_impound:restoreVehicle", function(source, plate, prop)
    if svConfig.Framework == "ESX" then
        ESX = exports['es_extended']:getSharedObject()
        local xPlayer = ESX.GetPlayerFromId(source)

        if xPlayer.getMoney() >= 1000 then
            local cr = clConfig.impoundcoords
            local crh = clConfig.impoundHeading
            local crd = {
                coords = {
                    x = cr.x,
                    y = cr.y,
                    z = cr.z
                },
                h = crh
            }
            
            Spawnvehicleforgarage(prop.model, clConfig.impoundcoords, clConfig.impoundHeading, json.encode(prop), source)
            TriggerClientEvent("df:ShowNotification", source, "Car restored!")
            xPlayer.removeMoney(1000)
        else
            TriggerClientEvent("df:ShowNotification", source, "No money!")
        end 
    elseif svConfig.Framework == "QBCORE" then
        local QBCore = exports['qb-core']:GetCoreObject()
        local xPlayer = QBCore.Functions.GetPlayer(source)

        if xPlayer.PlayerData.money.cash >= 1000 then
            local cr = clConfig.vehiclespawncoords
            local crh = clConfig.vehiclespawnheading
            local crd = {
                coords = {
                    x = cr.x,
                    y = cr.y,
                    z = cr.z
                },
                h = crh
            }

            Spawnvehicleforgarage(prop.model, clConfig.impoundcoords, clConfig.impoundHeading, json.encode(prop), source)
            TriggerClientEvent("df:ShowNotification", source, "Car restored!")
            xPlayer.Functions.RemoveMoney("cash", 1000)
        else
            TriggerClientEvent("df:ShowNotification", source, "No money!")
        end
    else
        print("Setup for your framework")
    end
end)

Here you can modify the GetIdentifier (xPlayer.identifier(), GetPlayerIdentifier(source, 0)) functions according to your framework, and the function that deducts money (xPlayer.getMoney(),PlayerData.money.cash) from the player.

Explentation /editable/notification.Lua


RegisterNetEvent("df:ShowNotification")
AddEventHandler("df:ShowNotification", function(msg)
    SetTextFont(fontId)
	SetNotificationTextEntry('STRING')
	AddTextComponentSubstringPlayerName(msg)
	DrawNotification(false, true)
end)
RegisterNetEvent("df:ShowHelpNotification")
AddEventHandler("df:ShowHelpNotification", function(msg, thisFrame, beep, duration)
    AddTextEntry('helpnotification', msg)

    if thisFrame then
        DisplayHelpTextThisFrame('helpnotification', false)
    else
        if beep == nil then
            beep = true
        end
        BeginTextCommandDisplayHelp('helpnotification')
        EndTextCommandDisplayHelp(0, false, beep, duration or -1)
    end
end)

Here you can set your custom notifications. (ShowHelpNotification,ShowNotification)

4. Exports

CarLocking

To trigger the opening or closing of car doors within your car locking system, utilize the CarLocking export provided by this script. This export allows for seamless integration of car door operations into your existing vehicle management logic.

Usage:

exports['df_nocardespawn']:CarLocking(plate, bool)
  • plate: The license plate of the targeted vehicle.

  • bool: A boolean value indicating the desired action:

    • 2: Locks the car doors.

    • 1: Unlocks the car doors.

Integration Guide:

  1. Server-Side Implementation:

    • Ensure the export is placed within a Lua file executed on the server side of your FiveM resource or framework.

  2. Location in Car Locking Script:

    • Integrate the CarLocking export within the section of your car locking script responsible for managing vehicle interactions.

  3. Usage:

    • Call the CarLocking export whenever locking or unlocking car doors is required within your car locking script.

Example Usage:

-- Example usage within your car locking script
-- Ensure execution on the server side

-- Locking a car with the plate "ABC123"
exports['df_nocardespawn']:CarLocking("ABC123", 2)

-- Unlocking a car with the plate "XYZ789"
exports['df_nocardespawn']:CarLocking("XYZ789", 1)

By following these guidelines, you can seamlessly integrate the CarLocking export into your car locking script, enabling precise control over car door operations.


Gps

To toggle the visibility of the GPS on your vehicle, use the following export:

exports['df_nocardespawn']:GpsState(plate, bool)
  • plate: The license plate of the targeted vehicle.

  • bool: A boolean value indicating the desired GPS state:

    • 0: GPS enabled.

    • 1: GPS disabled.

Integration Guide:

  1. Server-Side Implementation:

    • Ensure this export is placed within a Lua file executed on the server side of your FiveM resource or framework.

  2. Location in Script:

    • Integrate the GpsState export within your script's logic for managing vehicle features or GPS systems.

  3. Usage:

    • Call the GpsState export whenever you need to add or remove the GPS from a vehicle.

Example Usage:

-- Example usage within your Lua script
-- Ensure execution on the server side

-- Removing GPS from a car with the plate "ABC123"
exports['df_nocardespawn']:GpsState("ABC123", 0)

-- Adding GPS to a car with the plate "XYZ789"
exports['df_nocardespawn']:GpsState("XYZ789", 1)

By following these guidelines, you can seamlessly manage the visibility of GPS on your vehicles, enhancing the realism of your gameplay experience.


Impound

To trigger an impound from the client side of your police job or impound function, you can utilize the following export:

exports['df_nocardespawn']:ImpoundCar()

This export will trigger the impound action client-side.

Make sure to call this export from the appropriate location within your client-side script where you want the impound action to be triggered. This could be within a police job script or any other script responsible for impounding vehicles.

Example usage:

RegisterCommand("PoliceImpound",function()
    exports['df_nocardespawn']:ImpoundCar()
end)

Vehicle Name

To change the name of vehicles displayed in garages and on the GPS, you can use the server-side export :

exports['df_nocardespawn']:ChangeVehicleGpsName(plate, name)

Here's how to do it:

-- Example usage to change the vehicle name in garages and on the GPS
function ChangeVehicleNameInGarage(plate, name)
    -- Call the export to change the vehicle name
    exports['df_nocardespawn']:ChangeVehicleGpsName(plate, name)
end

You can call this function wherever necessary in your server-side Lua script to update the name of a vehicle in the garage and on the GPS. Make sure to provide the license plate (plate) and the new name (name) as arguments to the function.


Despawn Vehicle for Garage

To despawn vehicle in your custome garage use

exports['df_nocardespawn']:Despawnvehicleforgarage(plate)

You can call this function when you deposit the vehicle in your server-side Lua Garage Custom script, this function don't delete the vehicle only disable the auto respawn logic. Make sure to provide the license plate (plate)

Example in qb-garages MODIFIED:


QBCore.Functions.CreateCallback('qb-garages:server:canDeposit', function(source, cb, plate, type, garage, state)
    local Player = QBCore.Functions.GetPlayer(source)
    local isOwned = MySQL.scalar.await('SELECT citizenid FROM player_vehicles WHERE plate = ? LIMIT 1', { plate })
    if isOwned ~= Player.PlayerData.citizenid then
        cb(false)
        return
    end
    if type == 'house' and not exports['qb-houses']:hasKey(Player.PlayerData.license, Player.PlayerData.citizenid, Config.Garages[garage].houseName) then
        cb(false)
        return
    end
    if state == 1 then
        MySQL.update('UPDATE player_vehicles SET state = ?, garage = ? WHERE plate = ?', { state, garage, plate })
        exports['df_nocardespawn']:Despawnvehicleforgarage(plate)
        cb(true)
    else
        cb(false)
    end
end)

Example in qb-garages ORIGINAL:

QBCore.Functions.CreateCallback('qb-garages:server:canDeposit', function(source, cb, plate, type, garage, state)
    local Player = QBCore.Functions.GetPlayer(source)
    local isOwned = MySQL.scalar.await('SELECT citizenid FROM player_vehicles WHERE plate = ? LIMIT 1', { plate })
    if isOwned ~= Player.PlayerData.citizenid then
        cb(false)
        return
    end
    if type == 'house' and not exports['qb-houses']:hasKey(Player.PlayerData.license, Player.PlayerData.citizenid, Config.Garages[garage].houseName) then
        cb(false)
        return
    end
    if state == 1 then
        MySQL.update('UPDATE player_vehicles SET state = ?, garage = ? WHERE plate = ?', { state, garage, plate })
        cb(true)
    else
        cb(false)
    end
end)

Example in esx_garage MODIFIED:

RegisterServerEvent('esx_garage:updateOwnedVehicle')
AddEventHandler('esx_garage:updateOwnedVehicle', function(stored, parking, Impound, data, spawn)
	local source = source
	local xPlayer  = ESX.GetPlayerFromId(source)
		MySQL.update('UPDATE owned_vehicles SET `stored` = @stored, `parking` = @parking, `pound` = @Impound, `vehicle` = @vehicle WHERE `plate` = @plate AND `owner` = @identifier',
		{
			['@identifier'] = xPlayer.identifier,
			['@vehicle'] 	= json.encode(data.vehicleProps),
			['@plate'] 		= data.vehicleProps.plate,
			['@stored']     = stored,
			['@parking']    = parking,
			['@Impound']    	= Impound
		})

		if stored then
			exports['df_nocardespawn']:Despawnvehicleforgarage(data.vehicleProps.plate)
			xPlayer.showNotification(TranslateCap('veh_stored'))
		else 		
			exports['df_nocardespawn']:Spawnvehicleforgarage(data.vehicleProps.model,spawn,data.spawnPoint.heading,data.vehicleProps,source)

		end
end)

Example in esx_garage ORIGINAL

RegisterServerEvent('esx_garage:updateOwnedVehicle')
AddEventHandler('esx_garage:updateOwnedVehicle', function(stored, parking, Impound, data, spawn)
	local source = source
	local xPlayer  = ESX.GetPlayerFromId(source)
		MySQL.update('UPDATE owned_vehicles SET `stored` = @stored, `parking` = @parking, `pound` = @Impound, `vehicle` = @vehicle WHERE `plate` = @plate AND `owner` = @identifier',
		{
			['@identifier'] = xPlayer.identifier,
			['@vehicle'] 	= json.encode(data.vehicleProps),
			['@plate'] 		= data.vehicleProps.plate,
			['@stored']     = stored,
			['@parking']    = parking,
			['@Impound']    	= Impound
		})

		if stored then
			xPlayer.showNotification(TranslateCap('veh_stored'))
		else 
			ESX.OneSync.SpawnVehicle(data.vehicleProps.model, spawn, data.spawnPoint.heading,data.vehicleProps, function(vehicle)
				local vehicle = NetworkGetEntityFromNetworkId(vehicle)
				Wait(300)
				TaskWarpPedIntoVehicle(GetPlayerPed(source), vehicle, -1)
			end)
		end
end)

Spawn Vehicle for Garage

To spawn vehicle in your custome garage use

exports['df_nocardespawn']:Spawnvehicleforgarage(model,coord,heading,prop,taskwrap)

You can call this function when you retrieve the vehicle in your server-side Lua script for custom garages. This function spawns the vehicle without using different spawn logic. Ensure to provide the license plate (plate), coordinates (coord) as a Vector3, heading for spawn (heading), vehicle modifications (prop), and a task wrap (taskwrap) if you pass the player's source, which will automatically seat the player inside the vehicle.

Example in esx_garage MODIFIED:

RegisterServerEvent('esx_garage:updateOwnedVehicle')
AddEventHandler('esx_garage:updateOwnedVehicle', function(stored, parking, Impound, data, spawn)
	local source = source
	local xPlayer  = ESX.GetPlayerFromId(source)
		MySQL.update('UPDATE owned_vehicles SET `stored` = @stored, `parking` = @parking, `pound` = @Impound, `vehicle` = @vehicle WHERE `plate` = @plate AND `owner` = @identifier',
		{
			['@identifier'] = xPlayer.identifier,
			['@vehicle'] 	= json.encode(data.vehicleProps),
			['@plate'] 		= data.vehicleProps.plate,
			['@stored']     = stored,
			['@parking']    = parking,
			['@Impound']    	= Impound
		})

		if stored then
			exports['df_nocardespawn']:Despawnvehicleforgarage(data.vehicleProps.plate)
			xPlayer.showNotification(TranslateCap('veh_stored'))
		else 		
			exports['df_nocardespawn']:Spawnvehicleforgarage(data.vehicleProps.model,spawn,data.spawnPoint.heading,data.vehicleProps,source)

		end
end)

Example in esx_garage ORIGINAL

RegisterServerEvent('esx_garage:updateOwnedVehicle')
AddEventHandler('esx_garage:updateOwnedVehicle', function(stored, parking, Impound, data, spawn)
	local source = source
	local xPlayer  = ESX.GetPlayerFromId(source)
		MySQL.update('UPDATE owned_vehicles SET `stored` = @stored, `parking` = @parking, `pound` = @Impound, `vehicle` = @vehicle WHERE `plate` = @plate AND `owner` = @identifier',
		{
			['@identifier'] = xPlayer.identifier,
			['@vehicle'] 	= json.encode(data.vehicleProps),
			['@plate'] 		= data.vehicleProps.plate,
			['@stored']     = stored,
			['@parking']    = parking,
			['@Impound']    	= Impound
		})

		if stored then
			xPlayer.showNotification(TranslateCap('veh_stored'))
		else 
			ESX.OneSync.SpawnVehicle(data.vehicleProps.model, spawn, data.spawnPoint.heading,data.vehicleProps, function(vehicle)
				local vehicle = NetworkGetEntityFromNetworkId(vehicle)
				Wait(300)
				TaskWarpPedIntoVehicle(GetPlayerPed(source), vehicle, -1)
			end)
		end
end)

Example in qb-garages MODIFIED:


QBCore.Functions.CreateCallback('qb-garages:server:spawnvehicle', function(source, cb, plate, vehicle, coords)
    local vehProps = {}

    local COORDS = vec3(coords.x, coords.y, coords.z)

    local result = nil
    while result == nil do
        result = MySQL.rawExecute.await('SELECT mods FROM player_vehicles WHERE plate = ?', { plate })
        Wait(100)
    end
    if result and result[1] then vehProps = json.decode(result[1].mods) end

    exports['df_nocardespawn']:Spawnvehicleforgarage(GetHashKey(vehicle),COORDS,coords.w,vehProps,source)

    OutsideVehicles[plate] = { netID = netId, entity = veh }
    cb(netId, vehProps, plate)
end)

Example in qb-garages ORIGINAL:

QBCore.Functions.CreateCallback('qb-garages:server:spawnvehicle', function(source, cb, plate, vehicle, coords)
    local vehType = QBCore.Shared.Vehicles[vehicle] and QBCore.Shared.Vehicles[vehicle].type or GetVehicleTypeByModel(vehicle)
    local veh = CreateVehicleServerSetter(GetHashKey(vehicle), vehType, coords.x, coords.y, coords.z, coords.w)
    local netId = NetworkGetNetworkIdFromEntity(veh)
    SetVehicleNumberPlateText(veh, plate)
    local vehProps = {}
    local result = MySQL.rawExecute.await('SELECT mods FROM player_vehicles WHERE plate = ?', { plate })
    if result and result[1] then vehProps = json.decode(result[1].mods) end
    OutsideVehicles[plate] = { netID = netId, entity = veh }
    cb(netId, vehProps, plate)
end)

Last updated