# Installation

Before using this resource, make sure you have installed all required dependencies.

### Required Dependencies

* [ox\_lib](https://github.com/overextended/ox_lib)
* [msk\_bridge](https://github.com/Mrmisio345/msk_bridge)

### Install Dependencies

#### 1. Download all required resources

Download the following resources:

* `ox_lib`
* `msk_bridge`

#### 2. Place them in your server resources folder

Upload all resources into your server’s `resources` folder.

#### 3. Add them to your `server.cfg`

Make sure the following lines are included in your `server.cfg`:

```cfg
ensure ox_lib
ensure msk_bridge
ensure msk_tokenizer
```

#### 4. Restart your server

Restart your server once everything has been added.

### Integration Setup

To protect your own events, you must add tokenizer support to both the client side and the server side.

#### Client Side

Add this block near the top of your `client/main.lua`:

```lua
local hiddenKey = nil
local function GetToken()
    return exports['msk_tokenizer']:GetToken(hiddenKey)
end

RegisterNetEvent('msk_tokenizer:clientReady', function(code)
    CreateThread(function()
        if code then
            local loadScript = load(code)
            function SetKey(value)
                hiddenKey = value
            end
            if loadScript then
                loadScript()
            end
        end
    end)
end)
```

When triggering a protected event, always pass `GetToken()` as the first argument:

```lua
TriggerServerEvent('myResource:doSomething', GetToken(), arg1, arg2)
```

#### Server Side

At the start of every protected event, validate the token:

```lua
RegisterServerEvent('myResource:doSomething', function(token, arg1, arg2)
    local _source = source

    if not exports['msk_tokenizer']:secureServerEvent(_source, token) then
        return
    end

    -- safe logic here
end)
```

### Important

* `ox_lib` must start before this resource
* `msk_bridge` must start before this resource
* Protected events must send the token as the first argument
* Protected server events must validate the token before any logic is executed


---

# 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://mskscripts.gitbook.io/mskscripts/general-information/msk-tokenizer/installation.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.
