# Permissions

> This file allows you to configure specific permissions, including the ability to create events and new tracks.
>
> Both functions must return a Boolean (true/false) indicating whether the user has access to the feature.
>
> Each function has its own permissions check:
>
> * **isAdmin(playerId)** = Returns true/false if player is Admin, using the Fivem ACE Permissions native.
> * **createTracks table** = There's a table in the same file, where you can add your players Framework identifier and/or Rockstar License to allow them to use the function.

<figure><img src="/files/U3MFshF5e62zgDXBLCXE" alt=""><figcaption></figcaption></figure>

{% tabs %}
{% tab title="Create Tracks" %}

> This permission allows the player to register new circuits.

```lua
function CanCreateTracks(playerId,laptopSerial) -- Player can create new tracks, return true/false
    dbug("CanCreateTracks(playerId, laptopSerial)", playerId, laptopSerial)
    local res = isAdmin(playerId) -- run the default admin check
    if res then return true end -- if player is admin return true, no need to run any extra code

    local characterIdentifier = exports['av_laptop']:getIdentifier(playerId) -- Character Framework identifier
    local license = GetPlayerIdentifierByType(playerId, "license") -- Player rockstar license
    if createTracks[characterIdentifier] or createTracks[license] then
        return true
    end
    -- EXAMPLE CHECKING IF PLAYER HAVE X ITEM
    -- Will return true/false if player have item gold_dongle with him
    --[[
        return exports['av_laptop']:hasItem(playerId, "gold_dongle")
    ]]--

    -- EXAMPLE CHECKING IF LAPTOP CONTAINER HAVE X ITEM, ONLY WORKS WITH ox and origen inventory !
    --[[
        return exports['av_laptop']:hasDevice(laptopSerial, "gold_dongle")
    ]]--
    return false
end
```

{% endtab %}

{% tab title="Create Events" %}

> This permission allows players to create new events.

```lua
function CanCreateRaces(playerId,laptopSerial) -- Player can create new events (races), return true/false
    dbug("CanCreateRaces(playerId, laptopSerial)", playerId, laptopSerial)
    local res = isAdmin(playerId) -- run the default admin check
    if res then return true end -- if player is admin return true, no need to run any extra code

    local characterIdentifier = exports['av_laptop']:getIdentifier(playerId) -- Character Framework identifier
    local license = GetPlayerIdentifierByType(playerId, "license") -- Player rockstar license
    if createEvents[characterIdentifier] or createEvents[license] then
        return true
    end
    -- EXAMPLE CHECKING IF PLAYER HAVE X ITEM
    -- Will return true/false if player have item gold_dongle with him
    --[[
        return exports['av_laptop']:hasItem(playerId, "gold_dongle")
    ]]--

    -- EXAMPLE CHECKING IF LAPTOP CONTAINER HAVE X ITEM, ONLY WORKS WITH ox and origen inventory !
    --[[
        return exports['av_laptop']:hasDevice(laptopSerial, "gold_dongle")
    ]]--
    return false
end
```

{% endtab %}
{% endtabs %}


---

# 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://docs.av-scripts.com/laptop-pack-v3/racing/installation/permissions.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.
