> For the complete documentation index, see [llms.txt](https://lscripts.gitbook.io/lscripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lscripts.gitbook.io/lscripts/scripts/l-deathtimeout/installation.md).

# Installation

A short combat block after death for ESX. Once a player is back on their feet, whether they respawned themselves or a medic revived them, they cannot pull a weapon, throw a punch or fire a shot for as long as you allow. A slim bar at the top or the bottom of the screen counts the block down.

The resource shows no notifications and writes nothing into the chat. The bar is the only feedback the player gets.

### Dependencies

* es\_extended (ESX Legacy), 1.13.x and 1.14.x
* oxmysql, always started before this resource. It is a hard dependency, but it is only queried while persistence is on.
* ox\_inventory, only when you set `Config.Inventory = "ox"`

{% hint style="info" %}
l-deathtimeout is free on Tebex. It is still delivered with Cfx.re asset escrow, so you claim it through Tebex to get it onto your Cfx.re account, see Asset escrow.
{% endhint %}

### Steps

1. Drop the `l-deathtimeout` folder into your `resources` directory.
2. Add it to your `server.cfg`, after es\_extended and oxmysql:

   ```
   ensure l-deathtimeout
   ```

   If the folder sits inside a bracket folder that is already ensured (for example `[lscripts]`), no extra line is needed.
3. Open `config.lua` and set `Config.Locale`, `Config.Duration` and `Config.Inventory`.
4. Import `sql/l_deathtimeout.sql` once, or set `Config.Persist.enabled = false`. See Persistence below.
5. Restart the server.

### Persistence

Persistence keeps a running block alive over a reconnect and a server restart, and it ships switched on (`Config.Persist.enabled = true`). It needs one table, the one in `sql/l_deathtimeout.sql`:

```sql
CREATE TABLE IF NOT EXISTS `l_deathtimeout_active` (
    `identifier` VARCHAR(64) NOT NULL,
    `ends_at` INT UNSIGNED NOT NULL DEFAULT 0,
    `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`identifier`),
    KEY `idx_ends_at` (`ends_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
```

If you do not want persistence, set `Config.Persist.enabled = false` and skip the import.

{% hint style="info" %}
With persistence off the resource sends no database queries at all, but oxmysql still has to be started, because the resource lists it as a dependency. If persistence is on and the table is missing, the resource prints a yellow hint on start and simply runs without persistence. Nothing else breaks.
{% endhint %}

### What the block does

While the timer runs the weapon wheel and the number keys are dead, aiming and firing are disabled, melee is disabled, drive by weapons are disabled, and anything that ends up in the hands is put away again. Each of those five is its own switch in `Config.Block`.

With `Config.Inventory = "ox"` the player statebag `canUseWeapons` is switched off on top of that, so ox\_inventory refuses to equip a weapon in the first place and puts the one in the hands away by itself. That is the tightest option and the one to use whenever you run ox\_inventory. `"esx"` uses the controls and the force unarm only, which works with any inventory.

### Which files you can edit

| File                               | What is in it                                                                                          |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------ |
| `config.lua`                       | Language, duration, job durations, items, inventory, persistence, what is blocked, the timer           |
| `server_config.lua`                | Bypass by ESX group, job or ACE permission, and Discord logging                                        |
| `locales/en.lua`, `locales/de.lua` | Every text                                                                                             |
| `sql/l_deathtimeout.sql`           | The persistence table                                                                                  |
| `shared/ambulance.lua`             | Which death system the resource listens to                                                             |
| `client/framework.lua`             | How weapons are put away                                                                               |
| `server/framework.lua`             | How player data is read and how a used item reaches the resource                                       |
| `html/`                            | The complete timer interface, every colour and the distance to the screen edge sit in `html/style.css` |

{% hint style="warning" %}
The folder has to keep the name `l-deathtimeout`. Under another name the resource does nothing and prints a red line in the server console every minute until the folder name is fixed.
{% endhint %}

### Update check

With `Config.VersionCheck = true` the resource checks for a newer version once on start. A green line in the server console means you run the latest version, a yellow line names the newer version and links to lscripts.cc. A red line means the check got no usable answer, for example because your server has no outgoing internet access. The resource keeps working either way. Set `Config.VersionCheck = false` to turn the check off.
