> For the complete documentation index, see [llms.txt](https://rtx-dev.gitbook.io/rtxdev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rtx-dev.gitbook.io/rtxdev/hottub.md). Agents can also search and read this documentation through its [MCP server](https://rtx-dev.gitbook.io/rtxdev/~gitbook/mcp).

# HOTTUB

Documentation for RTX Hottub, the FiveM Hot Tub Script for ESX, QBCore and QBox: installation, configuration, commands, exports and FAQ.

{% embed url="<https://www.youtube.com/watch?v=iY670j9P7fI>" %}

## Purchase

[Purchase this resource](https://rtx.tebex.io/package/5178017)

**RTX Hottub** brings a real hottub to your FiveM server. Walk up, press `E` and the cover folds open over the side of the tub. Sit down in one of eight seats, open the control panel and turn on the massage jets, light the water with underwater LEDs in ten colours or raise the pop-up TV from the back of the tub. Players set up their own hottubs from an item with a gizmo and pack them up again, admins place them anywhere with the in-game creator - and every player around sees exactly the same hottub.

## Requirements

| Resource                              | Required                                                                                             |
| ------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| `rtx_hottub_object`                   | Yes - the hottub models, the covers, the water and the lights                                        |
| `rtx_hottub`                          | Yes - the whole script                                                                               |
| Database                              | No - everything is saved in `data/hottubs.json` by default                                           |
| `oxmysql`                             | No - only if you want placed hottubs in the database, or to copy them over from the previous version |
| `ox_inventory`                        | No - picked up on its own when it is running                                                         |
| `ox_target` / `qb-target` / `qtarget` | No - only if you want target instead of the key prompts                                              |

## Installation

### Add the resources

{% stepper %}
{% step %}

## Rename the packs

Rename `rtx_hottub_object.pack` to `rtx_hottub_object` and `rtx_hottub.pack` to `rtx_hottub` (if they have the `.pack` ending).
{% endstep %}

{% step %}

## Place both folders

Put both folders into your `resources` folder.
{% endstep %}

{% step %}

## Add them to server.cfg

The object resource first, after your framework and your inventory:

```
ensure rtx_hottub_object
ensure rtx_hottub
```

{% endstep %}
{% endstepper %}

{% hint style="warning" %}
Keep the `data` folder inside `rtx_hottub`. Hottubs placed with the creator - and placed hottubs when `Config.Storage = "json"` - are saved in `data/hottubs.json`.
{% endhint %}

### Framework

Open `config.lua`, section 1:

```lua
Config.Framework = "esx" -- "esx", "qbcore" or "standalone"

Config.Inventory = "auto" -- "auto", "framework" or "ox_inventory"
```

| Framework          | Value          |
| ------------------ | -------------- |
| ESX                | `"esx"`        |
| QBCore / QBox      | `"qbcore"`     |
| Standalone / other | `"standalone"` |

`Config.Inventory = "auto"` uses ox\_inventory when it is running, and the ESX / QBCore inventory otherwise.

{% hint style="info" %}
Standalone works without any framework: hottubs from housing, from the creator and from `Config.HotTubs` work fully. Items in standalone need ox\_inventory, or your own item functions in `server/other.lua`.
{% endhint %}

### Items

Only needed if players should set up hottubs themselves. Everything is ready in the `items` folder - copy what fits your server:

| File                     | Where it goes                                                                                                                                                        |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `items/ox_inventory.lua` | `ox_inventory/data/items.lua` - ESX / QBCore / QBox: the first block. Standalone: the second block, it has the export that makes the item usable without a framework |
| `items/qbcore.lua`       | `qb-core/shared/items.lua` - qb-inventory, ps-inventory, lj-inventory                                                                                                |
| `items/esx.sql`          | Your database, for the default ESX inventory                                                                                                                         |

The default item names:

```
hottub1, hottub2, hottub3, hottub1stairs, hottub2stairs, hottub3stairs
```

Item images go into the images folder of your inventory, named like the item (`hottub1.png` ...).

### Admins

The creator and the remove commands belong to whoever your `server.cfg` gives `hottub.admin` to:

```
add_ace group.admin hottub.admin allow
```

ESX groups, QBCore permissions and single players by identifier can be allowed too, see [Permissions](#permissions).

## Using a Hottub

| Where                              | Key | Action                                             |
| ---------------------------------- | --- | -------------------------------------------------- |
| Next to a closed hottub            | `E` | Open the cover - it folds over the side of the tub |
| Next to an open hottub             | `E` | Sit down in the nearest free seat                  |
| At the cover handle (front corner) | `E` | Close the cover                                    |
| Next to an open hottub             | `G` | The control panel                                  |
| In the hottub                      | `E` | Stand up                                           |
| In the hottub                      | `G` | The control panel                                  |

The control panel opens only when the cover is open. The cover can not be closed while somebody is sitting in the hottub.

{% hint style="info" %}
`E` and `G` are key mappings. Every player can rebind them in **Settings > Key Bindings > FiveM**.
{% endhint %}

```lua
Config.Keys = {
	interact = "E", -- Open the cover, sit down, close the cover at the handle, stand up
	menu = "G" -- The control panel
}
```

## Control Panel

While the panel is open, the camera looks down on the hottub from above - also while you sit in it. The panel shows the hottub, whether it is yours and how many seats are taken, and has three tabs:

| Tab        | What is in it                                             |
| ---------- | --------------------------------------------------------- |
| **Water**  | Massage jets on and off, jet power                        |
| **Lights** | Underwater LED on and off, colour, mode and speed         |
| **Extras** | Pop-up TV, private mode for the owner, pack the hottub up |

```lua
Config.Menu = {
	camera = true, -- true = the camera looks down on the hottub from above while the panel is open
	camerafov = 70.0,
	closedistance = 4.0 -- The panel closes when the player walks further than this from the hottub
}
```

## Cover

```lua
Config.Cover = {
	duration = 6000, -- Milliseconds the cover takes to fold open or closed
	cooldown = 3, -- Seconds after a move before the cover can be moved again
	startclosed = true -- true = hottubs start closed after a restart
}
```

## Water & Massage Jets

With the jets on, the water bubbles and water shoots out of the eight jets around the tub. The power steps are what the player picks in the panel.

```lua
Config.Water = {
	jets = {
		particles = true, -- false keeps only the bubbling water
		powers = {0.18, 0.24, 0.3}, -- Size of the jets for every power step. Add or remove steps freely
		defaultpower = 2
	},
	wetclothes = true -- true = clothes get wet in an open hottub
}
```

{% hint style="info" %}
Above `0.3` the water starts to shoot over the edge of the hottub.
{% endhint %}

## Underwater LED Lights

| Mode       | What it does                                |
| ---------- | ------------------------------------------- |
| **Static** | One colour                                  |
| **Cycle**  | Goes through every colour one after another |
| **Party**  | Jumps to a random colour every step         |

|     | Colour     |      | Colour |
| --- | ---------- | ---- | ------ |
| `1` | Dark blue  | `6`  | Orange |
| `2` | Green      | `7`  | Pink   |
| `3` | Light blue | `8`  | Purple |
| `4` | Lime       | `9`  | Red    |
| `5` | White      | `10` | Yellow |

```lua
Config.Lights = {
	defaultcolor = 7,
	modes = {
		static = true,
		cycle = true,
		party = true
	},
	speeds = { -- Milliseconds one colour stays on
		{label = "1", time = 4500},
		{label = "2", time = 1500},
		{label = "3", time = 500}
	},
	defaultspeed = 2
}
```

## Pop-Up TV

The TV rises from the back of the hottub. It is a real object, so any TV script can play on it - `rtx_hottub:client:tv` hands you the entity, see [Exports & Events](#exports-and-events).

```lua
Config.Tv = {
	enabled = true, -- false hides the TV from the panel
	duration = 2500, -- Milliseconds the TV takes to rise or go down
	cooldown = 3
}
```

## Seats & Relax

Eight seats in every hottub. Press `E` next to an open hottub and the player sits down in the nearest free seat. He stays seated until he presses `E` again, dies, goes ragdoll or gets in a vehicle.

```lua
Config.Seats = {
	notify = true, -- A notification with the keys when the player sits down
	pedoffsets = { -- Height correction for custom ped models that sit too high or too low
		{pedmodel = "player_one", offset = vector3(0.0, 0.0, 0.05)}
	}
}

Config.Relax = {
	enabled = true,
	interval = 10, -- Every this many seconds
	health = 2, -- Health given back every interval
	stress = 2, -- Stress taken away every interval
	jetsonly = false -- true = only while the jets are on
}
```

How stress is removed is in `OnRelaxRTX` in `client/other.lua` - `esx_status` and the QBCore HUD are ready there, put your own stress system in there.

## Where Hottubs Come From

There are four ways a hottub gets into the game, and they all work the same:

| Source           | How                                                                                 |
| ---------------- | ----------------------------------------------------------------------------------- |
| **Items**        | Players set them up from their inventory, see [Placing a Hottub](#placing-a-hottub) |
| **Housing**      | Found on their own, see [Housing](#housing)                                         |
| **The creator**  | `/hottubcreator`, see [Hottub Creator](#hottub-creator)                             |
| **`config.lua`** | `Config.HotTubs`, for those who like to write them by hand                          |

| Type | Model  |
| ---- | ------ |
| `1`  | Modern |
| `2`  | Light  |
| `3`  | Dark   |

Every type comes with or without stairs.

```lua
Config.HotTubs = {
	{
		label = "Del Perro Beach", -- Name shown in the control panel
		type = 1, -- 1 Modern, 2 Light, 3 Dark
		stairs = true,
		coords = vector3(-1826.69, -754.6, 8.2),
		heading = 50.0
	}
}
```

## Placing a Hottub

Using a hottub item opens the placer: the hottub stands in front of the player with a gizmo on it.

| Key               | Action                                             |
| ----------------- | -------------------------------------------------- |
| `LMB`             | Drag the arrows to move it, or the ring to turn it |
| `RMB`             | Hold to look around and fly                        |
| `W` `A` `S` `D`   | Fly                                                |
| `SPACE` / `SHIFT` | Up / down                                          |
| **Move / Rotate** | Switch what the gizmo does                         |
| **World / Local** | The axis of the gizmo                              |
| **On the ground** | Puts the hottub back on the ground under it        |
| **Place**         | Sets the hottub up                                 |
| `ESC` / **X**     | Cancel                                             |

Fly speed, look speed and move and rotation snapping are sliders right in the panel. Red text tells you when the hottub is too far away or too close to another one.

After placing, the player works on setting the hottub up for a few seconds. **The item is taken only once the hottub is really set up**, and the owner gets it back when he packs it up - from the **Extras** tab of the panel, or with `/hottubpickup`.

```lua
Config.Placement = {
	duration = 8, -- Seconds the player works on setting the hottub up
	pickupduration = 8, -- Seconds the player works on packing it up
	maxdistance = 8.0, -- How far from the player a hottub can be placed
	cameradistance = 12.0, -- How far the free camera can fly away from the player
	spacing = 4.0, -- Smallest distance between two hottubs
	maxperplayer = 3, -- How many hottubs one player can have placed at the same time. 0 = no limit
	pickup = true -- true lets the owner pack his hottub up and get the item back
}
```

```lua
Config.Items = {
	["hottub1"] = {type = 1, stairs = false},
	["hottub2"] = {type = 2, stairs = false},
	["hottub3"] = {type = 3, stairs = false},
	["hottub1stairs"] = {type = 1, stairs = true},
	["hottub2stairs"] = {type = 2, stairs = true},
	["hottub3stairs"] = {type = 3, stairs = true}
}
```

## Housing

Every RTX hottub model that another resource spawns is found on its own - **rtx\_housing** furniture, any other housing or furniture script. It gets the cover, the water, the jets, the lights, the TV and the seats like any other hottub. Nothing to set up.

Houses in their own instance (routing bucket) each have their own hottub, even when the interiors share the same coordinates.

```lua
Config.WorldHotTubs = {
	enabled = true, -- false = only hottubs from items, the creator and Config.HotTubs
	startclosed = true, -- A hottub from housing starts with the cover closed
	scaninterval = 2500, -- Milliseconds between two looks for new hottubs around the player
	stable = true, -- A hottub has to stand still for one scan before it is used, so furniture being moved is not picked up
	forget = 15 -- Minutes a hottub from housing is kept after the last player walked away
}
```

## Hottub Creator

```
/hottubcreator
```

Opens the list of every hottub placed with the creator, nearest first. From there you can place a new hottub, move one, teleport to it or delete it.

The creator uses the same placer with a gizmo, plus **model arrows** to pick one of the 6 models - Modern, Light or Dark, with or without stairs. Give it a name and save it - **it appears for every player straight away, no restart**.

{% hint style="info" %}
Hottubs placed with the creator are saved in `data/hottubs.json`. Keep that file when you update the resource.
{% endhint %}

## Saving

```lua
Config.Storage = "json" -- "json" = data/hottubs.json, "oxmysql" = the `hottubs` table in your database

Config.ImportOldHotTubs = true -- With "json": copies hottubs from the old `hottubs` table once, on the first start

Config.SaveState = true -- Cover, lights, jets and TV are remembered after a restart

Config.SaveInterval = 30 -- Seconds between two saves. Changes are collected and written together
```

With `"oxmysql"` the `hottubs` table is created on its own. Hottubs from housing always start fresh.

## Private Mode & Access

By default everybody can sit in any hottub and use its panel. The owner of a placed hottub can make it **private** in the **Extras** tab - then only he can use the panel.

```lua
Config.Access = {
	private = true, -- The owner of a placed hottub can make it private
	privateseats = false, -- true = only the owner can sit in a private hottub too
	menuwhilesitting = true -- The panel can be opened while sitting in the hottub
}
```

Every action is checked on the server. Your own rules - house keys, jobs, anything - go into `CanUseHotTubRTX` in `server/other.lua`.

## Interface & Interaction

```lua
Config.Language = "English"
Config.InterfaceColor = "#ff66ff" -- Accent colour of the whole interface
Config.InteractionSystem = 1
Config.PromptPosition = "right" -- "right", "center" or "left"
Config.Notifications = "rtx"
```

| `InteractionSystem` | Prompt                                         |
| ------------------- | ---------------------------------------------- |
| `1`                 | RTX prompt, matching the rest of the interface |
| `2`                 | 3D text                                        |
| `3`                 | GTA Online style help                          |
| `4`                 | Floating help text above the hottub            |

`Config.Notifications = "rtx"` uses the built-in notifications. Anything else calls `Notify()` in `client/other.lua`, where your own notification system goes.

### Target

```lua
Config.Target = true
Config.Targettype = "oxtarget" -- "oxtarget", "qbtarget" or "qtarget"
Config.TargetDistance = 2.5
```

The hottub gets target options for the panel, sitting down and the cover instead of the `E` / `G` prompts - on every hottub, the ones from housing included. The registering is in `client/other.lua`, open source.

## Synchronization

The server owns every hottub. The cover, the water, the lights, the TV and the seats are kept on the server, checked there and sent only to the players close to that hottub. Every one of them sees the same cover move and the same lights at the same moment.

Nothing is a networked entity - the cover, the water, the lights and the TV are created on each player's screen, so the script runs on servers with `sv_entityLockdown "strict"` without any extra setup.

## Player Checks

Nobody can use a hottub while dead or down, cuffed, in a vehicle, swimming, falling, ragdolled or in the pause menu. A player who dies in the hottub stands up and his seat is freed.

How death and cuffs are detected is in `IsPlayerDeadRTX()` and `AllowedInteraction()` in `client/other.lua`, open for your own ambulance and police scripts. Your ambulance script can also trigger `rtx_hottub:client:playerDied` to stand a dead player up right away.

## Commands

| Command                  | Who                    | What it does                                                 |
| ------------------------ | ---------------------- | ------------------------------------------------------------ |
| `/hottubpickup`          | Players                | Packs up the nearest hottub they placed, the item comes back |
| `/hottubcreator`         | Admins                 | The hottub creator                                           |
| `/hottubremovenearby 10` | Admins                 | Removes every hottub placed by players within 10 metres      |
| `/hottubremoveall`       | Admins, server console | Removes every hottub placed by players                       |

```lua
Config.Commands = {
	pickup = "hottubpickup",
	creator = "hottubcreator",
	removenearby = "hottubremovenearby",
	removeall = "hottubremoveall"
}
```

Rename any of them, or set it to `""` and it is never registered.

## Permissions

```lua
Config.AdminAce = "hottub.admin"

Config.Admins = {
	groups = {"admin", "superadmin", "god"},
	identifiers = {}
}
```

A player can use the creator and the remove commands if **any** of these is true:

* he has the ACE `hottub.admin`
* his ESX group / QBCore permission is in `groups`
* one of his identifiers is in `identifiers`

Identifiers can be the ESX identifier, the QBCore citizenid, `license:`, `steam:`, `discord:` - or just the part after the colon.

## Language

Every line of text - notifications and the whole interface - is in the `language` folder, open source. 18 languages are included:

English, German, Spanish, French, Czech, Polish, Portuguese, Italian, Russian, Turkish, Korean, Dutch, Chinese, Romanian, Hungarian, Thai, Japanese, Arabic

```lua
Config.Language = "German"
```

Anything missing in a language falls back to English.

## Open-Source Files

This product is protected by the Escrow System. You can still configure almost everything:

| File                | What is in it                                                                                |
| ------------------- | -------------------------------------------------------------------------------------------- |
| `config.lua`        | Everything configurable, fully commented                                                     |
| `language/*.lua`    | Every text, in 18 languages                                                                  |
| `client/other.lua`  | Notifications, prompts, target, death check, relax effect, hooks                             |
| `server/other.lua`  | Framework, items, inventories, admin checks, access rules, player names, Discord logs, hooks |
| `html`              | The interface                                                                                |
| `items`             | Ready item lines for ox\_inventory, QBCore and ESX                                           |
| `data/hottubs.json` | Hottubs from the creator, and placed hottubs with `Config.Storage = "json"`                  |

### Your own access rules

`CanUseHotTubRTX` in `server/other.lua` is called before every action. Return `false` there to block it for your own reasons - house keys, jobs, anything.

### Discord logs

Switched on in `server/other.lua`, in `LogsRTX` - placed, packed up and removed hottubs. The webhook lives there too - never put it in `config.lua`, that file is sent to every player.

## Exports & Events

### Client exports

```lua
exports.rtx_hottub:IsInHotTub() -- true while the player sits in a hottub
exports.rtx_hottub:GetHotTubSeat() -- id of the hottub and the seat number, or nil
```

### Server exports

```lua
exports.rtx_hottub:IsPlayerInHotTub(source)
exports.rtx_hottub:GetPlayerHotTub(source) -- id of the hottub and the seat number, or nil
```

### Client events

```lua
AddEventHandler("rtx_hottub:client:sat", function(hottubid, seat) end)
AddEventHandler("rtx_hottub:client:stood", function(hottubid) end)
AddEventHandler("rtx_hottub:client:relax", function(jetson) end)
AddEventHandler("rtx_hottub:client:tv", function(hottubid, tventity, raised) end)
TriggerEvent("rtx_hottub:client:playerDied") -- from your ambulance script
```

### Server events

```lua
AddEventHandler("rtx_hottub:server:placed", function(source, hottubid, item, coords) end)
AddEventHandler("rtx_hottub:server:pickedup", function(source, hottubid, item) end)
AddEventHandler("rtx_hottub:server:removed", function(source, hottubid, reason) end)
```

## Updating from the Old Version

{% stepper %}
{% step %}

## Replace the resource

Remove the old `rtx_hottub` folder (ESX / QB / Standalone) and put the new one in its place - `rtx_hottub_object` stays the same.
{% endstep %}

{% step %}

## Keep placed hottubs

Your placed hottubs are kept:

* `Config.Storage = "oxmysql"` keeps using your `hottubs` table, the new columns are added on their own
* `Config.Storage = "json"` copies every hottub from the `hottubs` table into `data/hottubs.json` on the first start - nothing is deleted from the database
  {% endstep %}

{% step %}

## Keep ownership

Owners stay the owners - ESX identifiers and the QBCore licence of the old version are both recognised.
{% endstep %}

{% step %}

## Update `Config.HotTubs`

`Config.HotTubs` is shorter now: `label`, `type`, `stairs`, `coords`, `heading`.
{% endstep %}
{% endstepper %}

## Troubleshooting

<details>

<summary>The hottubs do not show up</summary>

`rtx_hottub_object` is not started, or is started after `rtx_hottub`. Put `ensure rtx_hottub_object` above `ensure rtx_hottub` and restart the server - streamed models are only picked up by players who connect after the restart.

</details>

<details>

<summary>The item does nothing</summary>

The item is missing in your inventory, or is not usable. Copy the lines from the `items` folder. On standalone with ox\_inventory, use the second block in `items/ox_inventory.lua` - it has the export that makes the item usable.

</details>

<details>

<summary>I can not place the hottub</summary>

Red text in the placer tells you why: it is too far from you, or too close to another hottub. A player can also have only `Config.Placement.maxperplayer` hottubs placed at the same time.

</details>

<details>

<summary>The control panel does not open</summary>

The cover has to be open first. If the hottub is private, only its owner can use the panel.

</details>

<details>

<summary>A hottub from my housing has no cover</summary>

Check that `Config.WorldHotTubs.enabled = true` and that the house spawns an RTX hottub model from `rtx_hottub_object`. With `stable = true` the hottub is picked up once it stands still for one scan.

</details>

<details>

<summary>The creator says I am not allowed</summary>

Check the ACE in `server.cfg`, `Config.Admins.groups` and `Config.Admins.identifiers`. Any one of them is enough.

</details>

<details>

<summary>Target does not work</summary>

`Config.Target = true` needs the target resource running. If it is not, the F8 console says so.

</details>

<details>

<summary>A dead player stays in the hottub</summary>

Your ambulance script uses a death state the script does not know yet. Add it to `IsPlayerDeadRTX()` in `client/other.lua`, or trigger `rtx_hottub:client:playerDied`.

</details>
