UZ Scripts
Garage

Personal Garages

Database-driven personal garages with damage, modification, and fuel persistence.

Personal garages store and retrieve vehicles from the database (player_vehicles for QBCore/Qbox, owned_vehicles for ESX). Each vehicle is individually owned by a player.


How It Works

Open Garage

Player interacts with the NPC (via target or drawtext). A callback fetches all vehicles owned by the player from the database.

Browse & Preview

Vehicles are filtered by garage type (car/air/sea) and displayed in the UI. Clicking a vehicle opens the 3D orbit camera preview.

Spawn

Vehicle spawns at the first available VehSpawnPos. Database properties (mods, damage, fuel) are restored.

Store

Driving to VehPutPos and pressing E saves the vehicle state and removes it from the world.


Vehicle States

StateMeaningUI Category
1In GarageIn Garage
0Out (spawned)Out Garage
2ImpoundImpound

State 2 (Impound) is set externally by other scripts (e.g. police impound systems). This garage displays impounded vehicles but does not manage the impound process.


What Gets Saved

When AllDamageSave and ModificationSave are enabled:

Damage (AllDamageSave = true)

Prop

Type

Modifications (ModificationSave = true)

Vehicle properties (colors, mods, livery, plate, etc.) are saved using the framework's vehicle properties system:

  • QBCore: QBCore.Functions.GetVehicleProperties
  • Qbox: lib.getVehicleProperties
  • ESX: ESX.Game.GetVehicleProperties

Configuration

A personal garage is any garage without a Vehicles table. The Job field is optional — if set, only that job can access the garage (useful for job-specific personal vehicle storage).

{
    Pos = vec3(214.54, -806.95, 30.8),
    NpcHash = "s_m_y_valet_01",
    NpcHeading = 339.97,
    Blip = "Pillbox Hill Parking",
    BlipSprite = 357,
    BlipDisplay = 4,
    BlipScale = 0.5,
    BlipColour = 18,
    VehPutPos = vec3(211.92, -800.04, 30.89),
    VehSpawnPos = {
        [1] = vec4(209.64, -791.39, 30.5, 248.63),
        [2] = vec4(211.14, -788.75, 30.33, 249.13),
    },
    Camera = {
        vehSpawn = vec4(236.95, -783.71, 30.63, 179.64),
        fov = 50.0,
    },
    Type = 'car',
    -- No Job or Vehicles field = public personal garage
},

Security

All database operations are validated server-side:

  • Parameterized SQL — all queries use ? placeholders, no string concatenation
  • Ownership validationSetVehState, SetDamage, and ModificationSave verify the player owns the vehicle before updating
  • Spawn cooldown — prevents rapid spawn spam exploits

On this page