> For the complete documentation index, see [llms.txt](https://zloma-scripts.gitbook.io/zloma-scripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zloma-scripts.gitbook.io/zloma-scripts/zloma_garages-paid/api-reference/server-exports.md).

# Server Exports

## Vehicle Management

### CheckAndPreventDuplicate

Anti-duplicate spawn check. Call before spawning a vehicle to ensure it isn't already in the world.

```lua
local result = exports['zloma_garages']:CheckAndPreventDuplicate(plate, skipStoredCheck)
-- result.allowed = true/false
-- result.reason = string (if not allowed)
```

| Param           | Type    | Description                              |
| --------------- | ------- | ---------------------------------------- |
| plate           | string  | Vehicle plate                            |
| skipStoredCheck | boolean | Skip the stored-state database check     |
| **Returns**     | table   | `{allowed = bool, reason = string\|nil}` |

***

### SaveVehicleProperties

Saves vehicle properties JSON to the database.

```lua
exports['zloma_garages']:SaveVehicleProperties(plate, properties)
```

| Param       | Type    | Description              |
| ----------- | ------- | ------------------------ |
| plate       | string  | Vehicle plate            |
| properties  | table   | Vehicle properties table |
| **Returns** | boolean | Success                  |

***

### SetVehicleImpounded

Marks a vehicle as impounded (stored = 2) in the database.

```lua
exports['zloma_garages']:SetVehicleImpounded(plate)
```

***

### AddVehicleToGarage

External API export for adding a vehicle directly to a player's garage entry from another resource.

```lua
local ok, result = exports['zloma_garages']:AddVehicleToGarage(source, {
	model = 'adder',
	plate = 'ABC1234',
	props = {},
	vehicleType = 'car', -- car | air | boat
	stored = 1           -- 0=out, 1=garage, 2=impound, 3=police, 4=on_sale
})

-- ok = true/false
-- result = normalizedPlate on success, or error string on failure
```

| Param            | Type            | Description                                       |
| ---------------- | --------------- | ------------------------------------------------- |
| source           | number          | Target player's server ID                         |
| data.model       | string\|number  | Vehicle model/spawn name (stored in props)        |
| data.plate       | string          | Plate value (normalized to uppercase 8 chars)     |
| data.props       | table           | Vehicle properties table (optional)               |
| data.vehicleType | string          | `car`, `air`, or `boat` (optional, default `car`) |
| data.stored      | number          | Stored state (optional, default `0`)              |
| **Returns**      | boolean, string | `true, plate` on success or `false, error`        |

Notes:

* Inserts vehicle into the framework vehicle table using `GetDB()` adapter columns.
* Uses first available public garage ID when present; otherwise keeps `garage_id` as `NULL`.
* Validates required fields and rejects duplicate plates.

***

### GiveVehicleKeys

Gives vehicle keys to a player via zloma\_core.

```lua
exports['zloma_garages']:GiveVehicleKeys(source, plate)
```

***

## Garage Management

### GetGarages

Returns all garages from the database.

```lua
local garages = exports['zloma_garages']:GetGarages()
```

\| **Returns** | table | Array of garage objects |

***

### GetGarageById

Returns a specific garage by ID.

```lua
local garage = exports['zloma_garages']:GetGarageById(id)
```

| Param       | Type       | Description        |
| ----------- | ---------- | ------------------ |
| id          | number     | Garage database ID |
| **Returns** | table\|nil | Garage data or nil |

***

### ReloadGarages

Reloads all garages from the database and updates client-side caches.

```lua
exports['zloma_garages']:ReloadGarages()
```

***

## Impound Management

### GetImpounds

Returns all impounds from the database.

```lua
local impounds = exports['zloma_garages']:GetImpounds()
```

***

### GetImpoundById

Returns a specific impound by ID.

```lua
local impound = exports['zloma_garages']:GetImpoundById(id)
```

***

### ReloadImpounds

Reloads all impounds from the database.

```lua
exports['zloma_garages']:ReloadImpounds()
```

***

## Organization Vehicles

### AddOrgVehicle

Adds a vehicle to an organization.

```lua
exports['zloma_garages']:AddOrgVehicle(plate, job, jobGrade)
```

| Param    | Type   | Description             |
| -------- | ------ | ----------------------- |
| plate    | string | Vehicle plate           |
| job      | string | Organization name       |
| jobGrade | number | Minimum grade to access |

***

### RemoveOrgVehicle

Removes a vehicle from an organization.

```lua
exports['zloma_garages']:RemoveOrgVehicle(plate)
```

***

### GetOrgVehicles

Gets all vehicles belonging to an organization.

```lua
local vehicles = exports['zloma_garages']:GetOrgVehicles(job)
```

***

### TransferVehicleToOrg / TransferVehicleToPlayer

Transfer a vehicle between personal ownership and organization fleet.

```lua
exports['zloma_garages']:TransferVehicleToOrg(params)
exports['zloma_garages']:TransferVehicleToPlayer(params)
```

***

## Access Validation

### CheckVehicleAccess

Returns the player's access level to a vehicle.

```lua
local level = exports['zloma_garages']:CheckVehicleAccess(source, plate)
```

**Access Levels:**

| Value | Constant       | Description                         |
| ----- | -------------- | ----------------------------------- |
| 0     | `NONE`         | No access                           |
| 1     | `SHARED`       | Shared access (read-only)           |
| 2     | `SHARED_STORE` | Shared access with store permission |
| 3     | `ORG_MEMBER`   | Organization member                 |
| 4     | `ORG_BOSS`     | Organization boss                   |
| 5     | `OWNER`        | Vehicle owner                       |
| 6     | `ADMIN`        | Server admin                        |

***

### CanSpawnVehicle / CanStoreVehicle / CanImpoundVehicle

Validates whether a player can perform a specific action.

```lua
local allowed, reason = exports['zloma_garages']:CanSpawnVehicle(source, plate, garageName)
local allowed, reason = exports['zloma_garages']:CanStoreVehicle(source, plate, garageName)
local allowed, reason = exports['zloma_garages']:CanImpoundVehicle(source, plate)
```

\| **Returns** | boolean, string|nil | Allowed status and reason if denied |

***

### CanPoliceImpound

Checks if a player has police impound rights.

```lua
local canImpound = exports['zloma_garages']:CanPoliceImpound(source)
```

***

### IsPlayerAdmin

Checks if a player is in an admin group.

```lua
local isAdmin = exports['zloma_garages']:IsPlayerAdmin(source)
```

***

## Persistent Vehicles

{% hint style="info" %}
These exports are no-op stubs when `Config.PersistentVehicles.enabled = false`.
{% endhint %}

### RegisterTrackedVehicle / UnregisterTrackedVehicle

```lua
exports['zloma_garages']:RegisterTrackedVehicle(plate, data)
exports['zloma_garages']:UnregisterTrackedVehicle(plate)
```

### NotifyVehicleDelete

Tell the persistent system a vehicle was deleted externally (prevents respawn).

```lua
exports['zloma_garages']:NotifyVehicleDelete(entityOrNetId)
```

If the external resource performs owned-vehicle deletion and `Config.PersistentVehicles.enabled = true`, that resource should also include `@zloma_garages/zlDeleteHelper.lua` in its `shared_scripts` section so deletion handling stays consistent across resources.

### IsVehicleTracked / GetTrackedVehicles

```lua
local tracked = exports['zloma_garages']:IsVehicleTracked(plate)
local all = exports['zloma_garages']:GetTrackedVehicles()
```

***

## Fake Plates

### cleanupFakePlates

Removes fake plates and syncs inventory/fuel before store or impound.

```lua
exports['zloma_garages']:cleanupFakePlates(vehicle)
```

### removeFakePlateByPlate

Admin function — removes fake plates by plate string.

```lua
exports['zloma_garages']:removeFakePlateByPlate(plate)
```

***

## Database

### GetDB / GetDBAdapter

Returns the database adapter for direct queries.

```lua
local db = exports['zloma_garages']:GetDB()
local table = db.GetTable()   -- 'owned_vehicles' or 'player_vehicles'
local col = db.GetColumn()    -- 'owner' or 'citizenid'
```

***

## Infinitive Garages

### GetSpawnCounts

Gets current spawn counts for an infinitive garage.

```lua
local counts = exports['zloma_garages']:GetSpawnCounts(garageId)
```

### GetPlayerSpawns

Gets a player's active infinitive vehicle spawns.

```lua
local spawns = exports['zloma_garages']:GetPlayerSpawns(identifier)
```

***

## Discord Logging

### SendTransferToOrgLog

```lua
exports['zloma_garages']:SendTransferToOrgLog(playerName, playerIdentifier, vehicleLabel, plate, orgName, garageName)
```

### SendGiveVehicleLog

```lua
exports['zloma_garages']:SendGiveVehicleLog(giverName, giverIdentifier, giverGrade, receiverName, receiverIdentifier, vehicleLabel, plate, orgName)
```

### SendPoliceImpoundLog

```lua
exports['zloma_garages']:SendPoliceImpoundLog(data)
-- data = { officer, vehicle, plate, owner, duration, reason, baseFee, earlyFee, impoundCount }
```

***

## Society Payments

### DistributeImpoundFee

Distributes an impound fee to the configured society accounts.

```lua
exports['zloma_garages']:DistributeImpoundFee(impoundType, amount)
-- impoundType: 'police_impound', 'personal_impound', or 'org_impound'
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://zloma-scripts.gitbook.io/zloma-scripts/zloma_garages-paid/api-reference/server-exports.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
