# Database

KOJA HUD does not create its own tables. The only thing it stores is the nitro amount of each vehicle, in a column it adds to your existing vehicles table. Nothing else — settings, stress, key binds — is saved on the server.

## The nitro column

When `KOJA.Nitro.Enabled` is `true`, the server runs this once `oxmysql` is ready:

```sql
ALTER TABLE <GaragesTable> ADD COLUMN IF NOT EXISTS nitro INT DEFAULT 0
```

`<GaragesTable>` is `KOJA.Nitro.Tables.GaragesTable`. Set it to the table your server uses for owned vehicles:

| Framework | Table |
| --- | --- |
| ESX | `owned_vehicles` |
| QBCore | `player_vehicles` |
| Ox | `ox_vehicles` |

The table must have a `plate` column and an owner column named in `KOJA.Nitro.Tables.OwnerColumn` (`owner` by default).

If the table does not exist, the query fails. Check `KOJA.Nitro.Tables.GaragesTable` when you see an SQL error in the console at start-up.

With `KOJA.Nitro.Enabled = false`, nothing is created or read.

## How nitro is stored

| Moment | What happens |
| --- | --- |
| Driver enters a vehicle | The server looks up the nitro amount by plate and owner. Only the owner gets a value. |
| Driver leaves the vehicle | The remaining amount is written back by plate, if it is above 0. |
| Nitro runs out | The amount is set to 0. |
| Nitro is installed | The amount is set to 100 and the nitro item is removed, when `KOJA.Nitro.Item` is set. |

Vehicles that are not in the table (for example admin-spawned ones) cannot hold nitro.

## Server events

These events are used internally between the HUD's client and server scripts. You normally do not call them.

| Event | Purpose |
| --- | --- |
| `koja_hud:setVehicleNitro` | Saves a nitro amount for a plate. |
| `koja_hud:removeNitroItem` | Removes one nitro item from the calling player. |

The server callback `koja_hud:getVehicleNitro` returns the nitro amount for a plate owned by the caller.

## Related pages

- [Installation](/new/hud/installation) — Read the entire installation process to ensure the resource is fully usable.
- [Configuration](/new/hud/configuration) — Changing Language, Debug Prints, Settings Command, Hide Minimap, Notifications, Nitro, Engine, Seatbelt and Cruisemode.
- [Guides](/new/hud/guides) — Creating/Editing Locales, Progress Bar, Text UI and Stress.
- [Features](/new/hud/features)
- [Exports & Commands](/new/hud/exports-and-commands)
- [HUD](/new/hud) — back to the section overview
