> 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
