> 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-multijob/faction-lock.md).

# Faction Lock

Holding several jobs at once raises one question: what stops a character from being a police officer and a gang member at the same time. This is the answer.

Everything here lives in `ServerConfig.CategoryLock` in `server_config.lua` and works with the job categories from `config.lua`, see Icons and categories. Set `enabled = false` to turn the whole thing off.

```lua
ServerConfig.CategoryLock = {
    enabled = true,

    conflicts = {
        { 'state', 'crime' },
    },

    cooldown = {
        enabled    = true,
        categories = { 'state', 'crime' },
        duration   = { days = 3, hours = 0, minutes = 0 },
    },

    bypass = {
        enabled = true,
        groups  = { 'admin', 'superadmin' },
    },
}
```

### Conflicting categories

Categories listed together in one `conflicts` entry exclude each other. With the example above, a character who holds a `state` job can never take a `crime` job, and the other way round. Add more entries for more rules.

This is always scoped to the **single character** the job is handed to. Other characters of the same player are never looked at, so a player can still run a cop on one character and a gang member on another.

### The lock itself

When a character loses their last job of a category, they go under the faction lock. It is **one shared lock**, not one per category.

| Setting               | What it does                                  |
| --------------------- | --------------------------------------------- |
| `cooldown.enabled`    | Turns the automatic lock on leaving on or off |
| `cooldown.categories` | The list of categories the lock covers        |
| `cooldown.duration`   | How long it runs, set once for all of them    |

While the lock runs, **none** of the listed categories can be joined, including the one that was left. A category you do not list never starts a lock and can always be joined. Everything at `0` in `duration` turns the lock off while leaving the conflict rule intact.

### What counts as leaving

A character has left a category once their **last job of it is removed**. That happens through the trash button in the F4 menu, `/removemultijob`, the `RemoveMultijob` export (so a boss menu firing them) or the `NotifyJobLeft` export from your own script.

Simply switching the active job is **not** leaving. The job stays in the player's list, so a cop who clocks over to their mechanic job keeps the police job and gets no lock.

A lock that is already running is not extended by leaving a second faction, and players whose ESX group is in `bypass.groups` never get one. Set `bypass.enabled = false` to drop that exception and have the rules apply to everyone, the group list stays in the file for later.

### Where the rules apply

Every path that hands out a job asks the same check: the F4 menu, `/addmultijob`, the `AddMultijob` export (so any boss menu or job center going through it) and the ESX `/setjob` command once you apply the small patch from Exports.

### What the player sees

A locked character gets a red faction lock line above their job list in the F4 menu, with the remaining time on the right. Which factions are locked is deliberately not written on screen. Trying to take a blocked job gives a notification with the reason and the time left.

### Admin commands

All three use the same gating as `/addmultijob`, see Configuration.

| Command                                         | What it does                                                                                                                           |
| ----------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `/joblock [id\|identifier] [hours\|0] [reason]` | Puts a character under the lock by hand, overwriting a running one. Decimals work, so `0.5` is 30 minutes. `0` means until you lift it |
| `/jobunlock [id\|identifier]`                   | Lifts the lock again                                                                                                                   |
| `/joblocks [id\|identifier]`                    | Prints the categories that character holds and the running lock to the server console                                                  |

The lock belongs to one character. With a multicharacter script, an offline target has to be the character identifier (`char1:license:...`), not the plain license.

### Exports

`NotifyJobLeft`, `GetCategoryLocks`, `SetCategoryLock` and `ClearCategoryLock` are documented on the Exports page.
