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

# WhitelistExports

The whitelist temporarily turns off **all** detections for one player. Use it when a script performs a legitimate action that would otherwise be flagged, such as a medical system or a custom ability.

If only one detection needs to be quiet for a few seconds, use `AllowDetection` instead. See [Trusted Resources](/sb-scripts/sb-anticheat/trusted-resources.md).

> ⚠️ While a whitelist is active, nothing is detected for that player. Use the shortest duration you can, and remove it as soon as the activity finishes.

### Server-side whitelisting

```lua
exports["sbanticheat"]:AddWhitelist(serverId, duration)
```

| Parameter  | Type     | Description                                                    |
| ---------- | -------- | -------------------------------------------------------------- |
| `serverId` | `number` | The player's server ID                                         |
| `duration` | `number` | Seconds. `-1` or `nil` means until `RemoveWhitelist` is called |

```lua
exports["sbanticheat"]:AddWhitelist(source, 300)   -- 5 minutes
exports["sbanticheat"]:AddWhitelist(source, -1)    -- until removed
```

Every add, change, removal and expiry is posted to the whitelist webhook (`SB.webhooks.whitelist`). Turn this off with `SB.logging.logWhitelist`. The embed shows which script asked, such as `qb-policejob (server)`. A client request with no script name is marked with a warning, because it usually means someone fired the event by hand.

### Removing a whitelist

```lua
exports["sbanticheat"]:RemoveWhitelist(source)
```

Detections come back on the next check. Remove the whitelist when the activity ends rather than waiting for the timer.

### Checking a whitelist

```lua
if exports["sbanticheat"]:IsWhitelisted(source) then
    print("Player is currently whitelisted")
end
```

### Example

```lua
RegisterNetEvent("myjob:server:startAbility", function()
    local src = source
    exports["sbanticheat"]:AddWhitelist(src, 300)
    -- Start your special ability here
end)

RegisterNetEvent("myjob:server:stopAbility", function()
    local src = source
    exports["sbanticheat"]:RemoveWhitelist(src)
    -- Stop your special ability here
end)
```

### Best practice

Do not turn a detection off globally for one script. Whitelist the player doing the legitimate action so everyone else stays protected.

```lua
-- Don't do this:
SB.clientChecks.superSpeed = false
```

## Client-side whitelist exports

Client scripts can request a whitelist for the local player. The client only sends a request. The server validates it and decides whether to apply it, so a client cannot switch the AntiCheat off on its own.

```lua
exports["sbanticheat"]:AddWhitelist(300)
...
exports["sbanticheat"]:RemoveWhitelist()
```

```lua
CreateThread(function()
    exports["sbanticheat"]:AddWhitelist(300)
    TaskPlayAnim(PlayerPedId(), "dead", "dead_a", 8.0, -8.0, -1, 1, 0, false, false, false)
end)
```

> 💡 For important gameplay systems, server-side control is recommended whenever possible.
