# Floor Restriction

A **floor-level restriction** limits access to specific floors of an elevator or elevators. If the restriction check returns `false`, the specified floors become inaccessible while others remain accessible.

{% hint style="info" %}
You can find all of the examples in `no-elevators/restrictions/examples` folder.
{% endhint %}

### Example

***

```lua
local API = exports["no-elevators"]

local function isAdmin(source)
    return IsPlayerAceAllowed(source, "elevators.admin")
end

--In this example:
-- admin, admin2, admin3, and admin4 are elevator IDs.
-- Each floor list (e.g., {1, 2, 3} or 1) defines the restricted floors by their index.
-- isAdmin determines whether the user has access.

---@param floors table<string, table<number> | number>
---@param controller fun -> boolean
API:AddFloorRestriction({
    admin = {1, 2, 3},
    admin2 = {1, 2, 3},
    admin3 = {1, 2, 3},
    admin4 = 1
}, isAdmin)

------------------------------------------------------------------------------------------------------------

--In this example:
-- "admin2" is the elevator ID.
-- 1 or {2, 3, 4} specifies the restricted floors by their index.
-- isAdmin determines whether the user has access.

---@param elevatorId string
---@param floors table<number> | number
---@param controller fun -> boolean
API:AddFloorRestriction("admin2", 1, isAdmin)
API:AddFloorRestriction("admin2", {2, 3, 4}, isAdmin)

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://none-fivem.gitbook.io/nonem/resources/no-elevators/restrictions/floor-restriction.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
