> For the complete documentation index, see [llms.txt](https://docs.brutalscripts.com/site/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.brutalscripts.com/site/scripts/keys/exports-triggers.md).

# exports / triggers

## Client Exports

<table><thead><tr><th width="386" align="center">Export</th><th align="center">Result</th></tr></thead><tbody><tr><td align="center">exports.brutal_keys:addKey(keyID, label)</td><td align="center">Give key to the player. Create a key for anything. The label can be anything. (Won't work with vehicles)</td></tr><tr><td align="center">exports.brutal_keys:removeKey(keyID, deleteAll)</td><td align="center">Remove key from the player. <br>deleteAll: true/false - if true then it will delete all the keys with this keyID from the player</td></tr><tr><td align="center">exports.brutal_keys:removeKey(plate, deleteAll)</td><td align="center">Remove vehicle key from the player. <br>deleteAll: true/false - if true then it will delete all the keys with this keyID from the player</td></tr><tr><td align="center">exports.brutal_keys:addVehicleKey(plate, label)</td><td align="center">Give vehicle key to the player.  The label can be anything.</td></tr><tr><td align="center">exports.brutal_keys:addVehicleTemporaryKey(seconds, plate, label)</td><td align="center">Give a temporary key to the plaer to the vehicle. After the given seconds it will be removed. The label can be anything.</td></tr><tr><td align="center">exports.brutal_keys:getPlayerKey(keyID)</td><td align="center"><p>Return two values</p><p>hasKey: true/false - Wether the player has the key or not.<br>quantity: number - if has the key then the quantity.</p></td></tr></tbody></table>

## Server Triggers

<table><thead><tr><th width="452" align="center">Export</th><th align="center">Result</th></tr></thead><tbody><tr><td align="center">TriggerEvent('brutal_keys:server:addKey', PlayerID, keyID, label)</td><td align="center">Give key to the player. Create a key for anything. (Won't work with vehicles)</td></tr><tr><td align="center">TriggerEvent('brutal_keys:server:removeKey', PlayerID, keyID, deleteAll)</td><td align="center">Remove key from the player.<br>deleteAll: true/false - if true then it will felete all the keys with this keyID from the player</td></tr><tr><td align="center">TriggerEvent('brutal_keys:server:addVehicleKey', PlayerID, plate, label)</td><td align="center">Give vehicle key to the player</td></tr><tr><td align="center">TriggerEvent('brutal_keys:server:addVehicleTemporaryKey', PlayerID, seconds, plate, label)</td><td align="center">Give a temporary key to the player to the vehicle. After the given seconds it will be removed.</td></tr></tbody></table>

## Vehicle Shop Integrate&#x20;

You have to add this trigger on server side when the player gets a new vehicle:\
\
`TriggerEvent('brutal_keys:server:addVehicleKey', source, plate, plate)`

### <sub><mark style="color:yellow;">ESX - esx\_vehicleshop/main.lua<mark style="color:yellow;"></sub>

<sub>We already integrated the needed triggers to this file. But you can add by yourself too.</sub>

{% file src="/files/watO139gPD7eLSNQXsFy" %}

### <sub><mark style="color:yellow;">QBCORE - qb-vehicleshop/server.lua<mark style="color:yellow;"></sub>

<sub>We already integrated the needed triggers to this file. But you can add by yourself too.</sub>

{% file src="/files/HsOj2XY7No3Rr8RoxAAe" %}

### <sub><mark style="color:yellow;">QBOX- qbx\_vehicleshop/config/server.lua<mark style="color:yellow;"></sub>

<sub>Change the export to this event and it will support the brutal\_keys after you integrated it!</sub>

<pre class="language-lua"><code class="lang-lua">giveKeys = function(src, plate, vehicle)
        --exports.qbx_vehiclekeys:GiveKeys(src, vehicle)
        <a data-footnote-ref href="#user-content-fn-1">TriggerEvent('brutal_keys:server:addVehicleKey', src, plate, plate)</a>
    end,
</code></pre>

## How to use custom keys&#x20;

{% hint style="danger" %}
Client side example!
{% endhint %}

Here is an exmple how to create a custom key for a stash for example.&#x20;

* How to give a key to a player to anything

```lua
local StashName = "stash_1"
exports.brutal_keys:addKey(StashName.."_key", "Chest Key")
```

* How to get if the player have a key for the stash or not

```lua
local keyID = "stash_1_key"
local hasKey,quantity = exports.brutal_keys:getPlayerKey(keyID)

if hasKey then 
    exports.ox_inventory:openInventory('stash', { id = "stash_1"})
else
    -- Dont have key for the stash
end
```

[^1]: you need to add this line


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.brutalscripts.com/site/scripts/keys/exports-triggers.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
