[Free] [QBCORE] OS-PoliceGarage

Police Garage for QBcore

Package Description

Police Garage for QBcore is a comprehensive script designed to enhance the functionality of police vehicle spawning in the QBcore framework. This script handles the spawning of police vehicles with specific modifications, extras, and liveries. It includes a rank/grade check system, which can be toggled on or off.

Installation

Installation is straightforward:

  1. Download the script files.

  2. Place them in your server’s resources folder.

  3. Modify the config.lua file to tailor the vehicle models, extras, and mods to your needs.

YouTube Preview

Configuration

Config.lua

-- ===================================================
--  POLICE DEPARTMENT VEHICLES CONFIGURATION FILE
-- ===================================================
-- This file is your one-stop setup for configuring police NPCs, vehicles, and spawn locations.
-- It is designed to be user-friendly, requiring no advanced programming knowledge.
-- Simply modify the values below to customize your police department setup.
-- The script automatically sets up interactions and menus based on your configurations.

Config = {}

-- ===================================================
-- | NPC CONFIGURATION                               |
-- ===================================================
-- Define the NPC locations for your police departments here.
-- For each NPC, specify their coordinates, model, and associated police department.
-- The script will automatically create interaction points (qb-target) at these locations.
-- If the ped is floatting apply -1 to the z axis; like so vector4(459.6, -986.6, 24.7, 90.88) would now be vector4(459.6, -986.6, 24.7-1, 90.88)
Config.PedLocations = {
    -- Example: NPCs at the police departments with coordinates and a specific model and the PD they are at.
    { coords = vector4(459.6, -986.6, 24.7, 90.88),        model = 'ig_trafficwarden', pd = "MRPD" },
    { coords = vector4(381.59, -1617.05, 29.29 - 1, 233.39), model = 'ig_trafficwarden', pd = "DAVIS" },
    { coords = vector4(376.57, 800.3, 187.62 - 1, 91.13),  model = 'ig_trafficwarden', pd = "RANGER" },

    -- Add your NPC locations here:
    -- Format: { coords = vector4(x, y, z, heading), model = 'model_name', pd = 'department_name' },
}

-- ===================================================
-- | POLICE JOBS CONFIGURATION                       |
-- ===================================================
-- Define which job codes are recognized as police jobs.
-- Players with these job codes can access the garage.
Config.PoliceJobs = {
    "police", -- Standard police job identifier
    "leo",    -- Law Enforcement Officer
    "lspd",   -- Los Santos Police Department
    "bcso",   -- Blaine County Sheriff's Office
    "ranger"  -- Park Rangers
    -- Add more job codes as needed
}

-- If you need to add more police job identifiers (for example, for different departments or ranks),
-- just add them to this list. Ensure that these identifiers match exactly with those defined in your server's job system.

-- ===================================================
-- | FUEL SYSTEM CONFIGURATION                       |
-- ===================================================
-- Specifies the fuel system script used by vehicles.
Config.FuelSystem = 'LegacyFuel'

-- ===================================================
-- | VEHICLE RESTRICTION CONFIGURATIONS              |
-- ===================================================

-- Enable or disable vehicle restriction based on job grade/rank.
-- ---------------------------------------------------
-- This feature checks the rank/grade of the player before allowing them to spawn a vehicle.
-- If the player's rank is lower than the required rank set in Config.DepartmentVehicles, the vehicle will not spawn.
-- The player will be notified that they do not hold the necessary rank to use the vehicle.
Config.RestrictVehiclesRank = true

-- Enable or disable vehicle restriction based on job.
-- ---------------------------------------------------
-- This setting verifies the job of the player before spawning a vehicle.
-- If the player's job does not match the job specified in Config.DepartmentVehicles, the vehicle will not spawn.
-- For example, to restrict LSPD vehicles to LSPD officers only, set the job under the vehicle configuration to 'lspd'.
-- If you want to remove this restriction, you can either set the job to nil or disable this feature.
Config.RestrictVehiclesJob = true

-- ===================================================
-- Note: These settings are part of a larger system. Ensure that the corresponding 
-- configurations in Config.DepartmentVehicles are set correctly to use these features.
-- ===================================================

-- ===================================================
-- | VEHICLE SPAWN LOCATIONS                         |
-- ===================================================
-- Define the vehicle spawn locations for each police department.
-- These locations are used for parking and spawning police vehicles.
-- pd needs to be the exact same as the pd set at Config.PedLocations
Config.VehSpawnLocations = {
    -- Example: Several spawn points for the MRPD
    { coords = vector4(450.07, -975.77, 25.37, 90.07),   pd = 'MRPD' },
    { coords = vector4(435.0, -975.85, 25.37, 90.34),    pd = 'MRPD' },
    { coords = vector4(445.97, -986.17, 25.36, 271.1),   pd = 'MRPD' },
    { coords = vector4(445.71, -988.8, 25.36, 270.33),   pd = 'MRPD' },
    { coords = vector4(445.5, -991.53, 25.36, 268.99),   pd = 'MRPD' },
    { coords = vector4(445.78, -994.24, 25.36, 269.81),  pd = 'MRPD' },
    { coords = vector4(446.04, -996.93, 25.36, 269.92),  pd = 'MRPD' },
    { coords = vector4(437.3, -986.19, 25.36, 89.25),    pd = 'MRPD' },
    { coords = vector4(437.19, -988.9, 25.36, 89.31),    pd = 'MRPD' },
    { coords = vector4(437.29, -991.52, 25.36, 90.81),   pd = 'MRPD' },
    { coords = vector4(437.31, -994.34, 25.36, 90.32),   pd = 'MRPD' },
    { coords = vector4(437.35, -996.88, 25.36, 91.3),    pd = 'MRPD' },
    { coords = vector4(425.58, -997.12, 25.36, 271.6),   pd = 'MRPD' },
    { coords = vector4(425.92, -994.32, 25.36, 270.71),  pd = 'MRPD' },
    { coords = vector4(425.58, -991.66, 25.36, 270.16),  pd = 'MRPD' },
    { coords = vector4(425.88, -989.02, 25.36, 270.64),  pd = 'MRPD' },
    { coords = vector4(425.76, -984.25, 25.36, 271.54),  pd = 'MRPD' },
    { coords = vector4(425.83, -981.54, 25.36, 270.15),  pd = 'MRPD' },
    { coords = vector4(425.69, -978.88, 25.36, 270.17),  pd = 'MRPD' },
    { coords = vector4(425.75, -976.12, 25.36, 269.31),  pd = 'MRPD' },
    -- More MRPD locations...

    -- Davis PD locations
    { coords = vector4(386.9, -1615.3, 28.98, 230.55),   pd = 'DAVIS' },
    { coords = vector4(388.84, -1612.83, 28.98, 230.68), pd = 'DAVIS' },
    { coords = vector4(391.08, -1610.59, 28.98, 229.64), pd = 'DAVIS' },
    { coords = vector4(392.9, -1608.15, 28.98, 229.69),  pd = 'DAVIS' },
    { coords = vector4(403.01, -1616.51, 28.98, 49.41),  pd = 'DAVIS' },
    { coords = vector4(401.23, -1619.12, 28.98, 50.44),  pd = 'DAVIS' },
    { coords = vector4(399.29, -1621.46, 28.98, 50.21),  pd = 'DAVIS' },
    { coords = vector4(396.8, -1623.69, 28.98, 50.13),   pd = 'DAVIS' },
    { coords = vector4(395.01, -1626.08, 28.98, 50.33),  pd = 'DAVIS' },
    { coords = vector4(393.36, -1628.89, 28.98, 51.07),  pd = 'DAVIS' },
    { coords = vector4(387.4, -1636.67, 28.98, 319.07),  pd = 'DAVIS' },
    { coords = vector4(385.09, -1634.46, 28.98, 320.15), pd = 'DAVIS' },
    -- More Davis PD locations...


    -- Ranger Station locations
    { coords = vector4(374.41, 795.4, 187.03, 179.71),   pd = 'RANGER' },
    -- More Ranger Station locations...

    -- Additional Police Department spawn locations
    -- Add more locations as needed for different departments
    -- Format: { coords = vector4(x, y, z, h), pd = 'department_name' },
}

-- ===================================================
-- PERFORMANCE MODS CONFIGURATION
-- ===================================================
-- Enable or disable maximum performance mods for police vehicles.
Config.Maxmods = true -- If true, vehicles will have max performance upgrades.

Config.Turbo = true   -- Enable or disable turbo mod for vehicles.

-- ===================================================
-- | DEPARTMENT VEHICLES CONFIGURATION               |
-- ===================================================
-- Define the vehicles available for each police department.
-- Vehicles are automatically listed in the qb-menu based on these settings.
Config.DepartmentVehicles = {
    LSPD = {                -- Los Santos Police Department (LSPD)
        Charger = {
            model = "char", -- Actual Charger model name
            label = "LSPD Charger",
            primarycolor = 111,
            secondarycolor = 0,
            livery = 2,
            rank = 2,
            job = "lspd",
            mods = {
                { id = 0, modenabled = -1 }, -- id 0 represents the Spoiler modification. The 'modenabled' field uses -1 for level 0, 0 for level 1, and so on.
            },
            extras = {
                { id = 1, enabled = 0 }, -- For vehicle extras, '0' indicates enabled, and '1' indicates disabled.
                { id = 2, enabled = 0 },
                { id = 3, enabled = 0 },
                { id = 4, enabled = 0 },
                { id = 5, enabled = 0 },
                { id = 6, enabled = 0 },
                { id = 7, enabled = 0 },
                { id = 8, enabled = 0 }
            }
        },
        CVPI = {
            model = "pd1", -- Actual CVPI model name
            label = "LSPD CVPI",
            primarycolor = 0,
            secondarycolor = 111,
            livery = 0,
            rank = 0,
            mods = {
                { id = 0, modenabled = -1 }, -- id 0 represents the Spoiler modification. The 'modenabled' field uses -1 for level 0, 0 for level 1, and so on.
            },
            extras = {
                { id = 1, enabled = 0 }, -- For vehicle extras, '0' indicates enabled, and '1' indicates disabled.
                { id = 2, enabled = 0 },
                { id = 3, enabled = 0 },
                { id = 4, enabled = 0 },
                { id = 5, enabled = 0 },
                { id = 6, enabled = 0 },
                { id = 7, enabled = 0 },
                { id = 8, enabled = 0 }
            }
        },
        Explorer = {
            model = "Explorer", -- Actual Explorer model name
            label = "LSPD Explorer",
            primarycolor = 0,
            secondarycolor = 111,
            livery = 1,
            rank = 1,
            mods = {
                { id = 0, modenabled = -1 }, -- id 0 represents the Spoiler modification. The 'modenabled' field uses -1 for level 0, 0 for level 1, and so on.
            },
            extras = {
                { id = 1, enabled = 0 }, -- For vehicle extras, '0' indicates enabled, and '1' indicates disabled.
                { id = 2, enabled = 0 },
                { id = 3, enabled = 0 },
                { id = 4, enabled = 0 },
                { id = 5, enabled = 0 },
                { id = 6, enabled = 0 },
                { id = 7, enabled = 0 },
                { id = 8, enabled = 0 }
            }
        },
        -- Additional LSPD vehicles...
    },
    BCSO = {                -- Blaine County Sheriff's Office (BCSO)
        Charger = {
            model = "char", -- Actual Charger model name
            label = "BCSO Charger",
            primarycolor = 111,
            secondarycolor = 49,
            livery = 0,
            rank = 2,
            mods = {
                { id = 0, modenabled = -1 }, -- id 0 represents the Spoiler modification. The 'modenabled' field uses -1 for level 0, 0 for level 1, and so on.
            },
            extras = {
                { id = 1, enabled = 0 }, -- For vehicle extras, '0' indicates enabled, and '1' indicates disabled.
                { id = 2, enabled = 0 },
                { id = 3, enabled = 0 },
                { id = 4, enabled = 0 },
                { id = 5, enabled = 0 },
                { id = 6, enabled = 0 },
                { id = 7, enabled = 0 },
                { id = 8, enabled = 0 }
            }
        },
        CVPI = {
            model = "pd1", -- Actual model name
            label = "BCSO CVPI",
            primarycolor = 111,
            secondarycolor = 49,
            livery = 3,
            rank = 0,
            mods = {
                { id = 0, modenabled = -1 }, -- id 0 represents the Spoiler modification. The 'modenabled' field uses -1 for level 0, 0 for level 1, and so on.
            },
            extras = {
                { id = 1, enabled = 0 }, -- For vehicle extras, '0' indicates enabled, and '1' indicates disabled.
                { id = 2, enabled = 0 },
                { id = 3, enabled = 0 },
                { id = 4, enabled = 0 },
                { id = 5, enabled = 0 },
                { id = 6, enabled = 0 },
                { id = 7, enabled = 0 },
                { id = 8, enabled = 0 }
            }
        },
        Explorer = {
            model = "explorer", -- Actual Explorer model name
            label = "BCSO Explorer",
            primarycolor = 49,
            secondarycolor = 111,
            livery = 2,
            rank = 1,
            mods = {
                { id = 0, modenabled = -1 }, -- id 0 represents the Spoiler modification. The 'modenabled' field uses -1 for level 0, 0 for level 1, and so on.
            },
            extras = {
                { id = 1, enabled = 0 }, -- For vehicle extras, '0' indicates enabled, and '1' indicates disabled.
                { id = 2, enabled = 0 },
                { id = 3, enabled = 0 },
                { id = 4, enabled = 0 },
                { id = 5, enabled = 0 },
                { id = 6, enabled = 0 },
                { id = 7, enabled = 0 },
                { id = 8, enabled = 0 }
            }
        },
        -- Additional BCSO vehicles...
    },
    SAST = {                -- San Andreas State Troopers (SAST)
        Charger = {
            model = "char", -- Actual Charger model name
            label = "SAST Charger",
            primarycolor = 4,
            secondarycolor = 4,
            livery = 3,
            rank = 2,
            mods = {
                { id = 0, modenabled = -1 }, -- id 0 represents the Spoiler modification. The 'modenabled' field uses -1 for level 0, 0 for level 1, and so on.
            },
            extras = {
                { id = 1, enabled = 0 }, -- For vehicle extras, '0' indicates enabled, and '1' indicates disabled.
                { id = 2, enabled = 0 },
                { id = 3, enabled = 0 },
                { id = 4, enabled = 0 },
                { id = 5, enabled = 0 },
                { id = 6, enabled = 0 },
                { id = 7, enabled = 0 },
                { id = 8, enabled = 0 }
            }
        },
        CVPI = {
            model = "pd1", -- Actual CVPI model name
            label = "SAST CVPI",
            primarycolor = 4,
            secondarycolor = 4,
            livery = 2,
            rank = 0,
            mods = {
                { id = 0, modenabled = -1 }, -- id 0 represents the Spoiler modification. The 'modenabled' field uses -1 for level 0, 0 for level 1, and so on.
            },
            extras = {
                { id = 1, enabled = 0 }, -- For vehicle extras, '0' indicates enabled, and '1' indicates disabled.
                { id = 2, enabled = 0 },
                { id = 3, enabled = 0 },
                { id = 4, enabled = 0 },
                { id = 5, enabled = 0 },
                { id = 6, enabled = 0 },
                { id = 7, enabled = 0 },
                { id = 8, enabled = 0 }
            }
        },
        Explorer = {
            model = "Explorer", -- Actual Explorer model name
            label = "SAST Explorer",
            primarycolor = 4,
            secondarycolor = 4,
            livery = 4,
            rank = 1,
            mods = {
                { id = 0, modenabled = -1 }, -- id 0 represents the Spoiler modification. The 'modenabled' field uses -1 for level 0, 0 for level 1, and so on.
            },
            extras = {
                { id = 1, enabled = 0 }, -- For vehicle extras, '0' indicates enabled, and '1' indicates disabled.
                { id = 2, enabled = 0 },
                { id = 3, enabled = 0 },
                { id = 4, enabled = 0 },
                { id = 5, enabled = 0 },
                { id = 6, enabled = 0 },
                { id = 7, enabled = 0 },
                { id = 8, enabled = 0 }
            }
        },
        -- Additional SAST vehicles...
    },
    INIT = {                   -- Interceptors (INIT)
        Mustang = {
            model = "mach1rb", -- Actual Mustang model name
            label = "Interceptor Mustang",
            primarycolor = 49,
            secondarycolor = 111,
            livery = 2,
            rank = 3,
            mods = {
                { id = 0, modenabled = -1 }, -- id 0 represents the Spoiler modification. The 'modenabled' field uses -1 for level 0, 0 for level 1, and so on.
            },
            extras = {
                { id = 1, enabled = 0 }, -- For vehicle extras, '0' indicates enabled, and '1' indicates disabled.
                { id = 2, enabled = 0 },
                { id = 3, enabled = 0 },
                { id = 4, enabled = 0 },
                { id = 5, enabled = 0 },
                { id = 6, enabled = 0 },
                { id = 7, enabled = 0 },
                { id = 8, enabled = 0 }
            }
        },
        Corvette = {
            model = "zr1RB", -- Actual Corvette model name
            label = "Interceptor Corvette",
            primarycolor = 49,
            secondarycolor = 111,
            livery = 2,
            rank = 3,
            mods = {
                { id = 0, modenabled = -1 }, -- id 0 represents the Spoiler modification. The 'modenabled' field uses -1 for level 0, 0 for level 1, and so on.
            },
            extras = {
                { id = 1, enabled = 0 }, -- For vehicle extras, '0' indicates enabled, and '1' indicates disabled.
                { id = 2, enabled = 0 },
                { id = 3, enabled = 0 },
                { id = 4, enabled = 0 },
                { id = 5, enabled = 0 },
                { id = 6, enabled = 0 },
                { id = 7, enabled = 0 },
                { id = 8, enabled = 0 }
            }
        },
        Challenger = {
            model = "poldemonrb", -- Actual Challanger model name
            label = "Interceptor Challanger",
            primarycolor = 49,
            secondarycolor = 111,
            livery = 2,
            rank = 3,
            mods = {
                { id = 0, modenabled = -1 }, -- id 0 represents the Spoiler modification. The 'modenabled' field uses -1 for level 0, 0 for level 1, and so on.
            },
            extras = {
                { id = 1, enabled = 0 }, -- For vehicle extras, '0' indicates enabled, and '1' indicates disabled.
                { id = 2, enabled = 0 },
                { id = 3, enabled = 0 },
                { id = 4, enabled = 0 },
                { id = 5, enabled = 0 },
                { id = 6, enabled = 0 },
                { id = 7, enabled = 0 },
                { id = 8, enabled = 0 }
            }
        },
        -- Additional INIT vehicles...
    },
    RANG = {                   -- Interceptors (INIT)
        F150 = {
            model = "sotruck", -- Actual Mustang model name
            label = "Ranger F150",
            primarycolor = 49,
            secondarycolor = 111,
            livery = 2,
            rank = 3,
            mods = {
                { id = 0, modenabled = -1 }, -- id 0 represents the Spoiler modification. The 'modenabled' field uses -1 for level 0, 0 for level 1, and so on.
            },
            extras = {
                { id = 1, enabled = 0 }, -- For vehicle extras, '0' indicates enabled, and '1' indicates disabled.
                { id = 2, enabled = 0 },
                { id = 3, enabled = 0 },
                { id = 4, enabled = 0 },
                { id = 5, enabled = 0 },
                { id = 6, enabled = 0 },
                { id = 7, enabled = 0 },
                { id = 8, enabled = 0 }
            }
        },

        -- Additional Ranger vehicles...
    },
    -- Additional departments if needed...
}

-- ===================================================
--  END OF CONFIGURATION
-- ===================================================

modenabled values range from Stock (-1) to various upgrade levels.

Usage

  • Configure the config.lua file as per your preferences.

  • Ensure proper integration with your server resources.

  • Utilize the garage system to spawn customized police vehicles.

Key Features

  • Tailored Vehicle Spawning: Spawn police vehicles with specific mods, extras, and liveries.

  • Rank/Grade Checks: Optional feature to restrict vehicle access based on police hierarchy.

  • Extensive Customization: Detailed customization options for most aspect of police vehicles.

  • User-Friendly Configuration: Easy-to-edit config.lua file.

Download

Requirements

  • QBCORE Framework
  • QB-Target
  • QB-Menu
  • Gabz MRPD (This can be easily changed on the config.
Code is accessible Yes
Subscription-based No
Lines (approximately) 500+
Requirements ^^
Support No
6 Likes

I’m getting an error… Not really sure why, but here it is.

[ c-scripting-core] Creating script environments for saspgaragenorth
[script:saspgaragenor] Error parsing script @saspgaragenorth/config.lua in resource saspgaragenorth: @saspgaragenorth/config.lua:94: ‘}’ expected (to close ‘{’ at line 51) near ‘Explorer’
[ c-scripting-core] Failed to load script config.lua.

I have checked the code via Visual Studio and it says no errors and it looks fine by me.

Reverted back to the original config, modified fuel type and the npc spawn location only. No errors, but no NPC to spawn either.

Is it possible to add in mods “Max car mods” for that car? (Like in the admin menu)

Can you send me your config and ill take a look?

I overlooked the loop that creates and fades the PED when it was first released, so the location of the PED remained at MRPD, even if the location was changed. This issue was fixed 2 days ago. If you downloaded the script before this fix, it might potentially be the cause of the NPCs not spawning correctly. If so, just replace the relevant section with the updated code.

Replace StartGarageLoop function in main.lua line 39 - 68

function StartGarageLoop()
    if not garageLoopActive then
        garageLoopActive = true
        Citizen.CreateThread(function()
            while garageLoopActive do
                local playerPed = PlayerPedId()
                local pos = GetEntityCoords(playerPed)
                local npcLocation = vector3(Config.NPClocation.x, Config.NPClocation.y, Config.NPClocation.z)
                local dist = #(npcLocation - pos)
                if dist < 30 and not myPed then
                    myPed = CreateMyPed()
                    if myPed then
                        for alpha = 0, 255, 51 do
                            SetEntityAlpha(myPed, alpha, false)
                            Citizen.Wait(50)
                        end
                    end
                elseif dist >= 30 and myPed then
                    for alpha = 255, 0, -51 do
                        SetEntityAlpha(myPed, alpha, false)
                        Citizen.Wait(50)
                    end
                    DeleteEntity(myPed)
                    myPed = nil
                end
                Citizen.Wait(2500)
            end
        end)
    end
end 

Yeah, ill add a toggle in the config for max performance mods.


Update 2.1.0

This release includes several enhancements and new features:

  • Improvements:

    • Addressed various things that were previously overlooked.
  • New Features:

    • Toggle for Max Mods: Introduced a new toggle option in the configuration to enable or disable maximum performance modifications easily.
    • Turbo Mod Toggle: Added a toggle feature for enabling or disabling turbo mods, providing more customization control.

Future Updates

  • In upcoming versions, there will be a focus on simplifying the addition of multiple locations/garages. This enhancement will be configured entirely through the Config, streamlining the process and improving user experience.

But i have problem the npc doesnt show.

Did you change anything?

I just change the position of the ped. And there is not also the ped when its default.

Are you using Gabz MRPD?

No thats why i change cords of the ped

when did you download the script?

2 hours ago

So your StartGarageLoop looks like this?

Yes it is like that

Can you send the new location you set

vector4(388.60, -1018.10, 29.42, 272.04)
I change this in config for ped and also change the interaction.

Just doesnt work for me the spawner of the ped


Using your cords that’s a on a fresh version download from the GitHub less than 5 mins ago


Just 3 hour ago

I mean I downlead that version 5 mins before the screenshot to ensure nothing was different from your version.