# Installation

{% tabs %}
{% tab title="QBCore" %}

### Installation for QBCore

#### Step 1

Put the <mark style="color:blue;">**`origen_notify`**</mark> script inside the resources folder.

#### Step 2

Then go to server.cfg and put <mark style="color:blue;">**`ensure origen_notify`**</mark>

#### Step 3 (*Client Side*)

If you want to change the Notifications for your server. In your script `qb-core/client/functions.lua` search for the existing `Notify` function. It might look something like: `function QBCore.Functions.Notify(...)`

When you find this section in your file, remplace this code for this code:

```lua
function QBCore.Functions.Notify(text, texttype, length) 
    exports["origen_notify"]:ShowNotification(text) 
end
```

#### Step 4 (*Server Side*)

Now we will proceed to replace the notifications on the server side, for this we will go to `qb-core/server/functions.lua.` We will look for the `function QBCore.Functions.Notify(...)`. and we will replace it with the following code:

```lua
function QBCore.Functions.Notify(source, text, texttype, length) 
    exports["origen_notify"]:ShowNotification(source, text) 
end
```

#### Step 5 (**Change the DrawText)**

1. **Locate the file**: In your script, `qb-core/client/drawtext.lua`:
2. **Replace** the code with this file:&#x20;

```lua
local buffer = {}

local function hideText()
    for k, v in pairs(buffer) do
        exports['origen_notify']:RemoveHelp(v)
        buffer[k] = nil
    end
end

local function drawText(text)
    if buffer[text] then return end
    local key = ""
    local formattedText = text or ""

      if string.find(formattedText, "%[.-%]") then
          key, formattedText = string.match(formattedText, "%[(.)%](.+)"), text:gsub("%[.-%]", "")
      end

      if string.find(formattedText, "%~.-%~") then
          key, formattedText = string.match(formattedText, "~(.-)~"), text:gsub("~(.-)~", "")
          if key == "INPUT_ENTER" then
              key = "F"
          else
              key = "E"
          end
      end
      if key == "" then key = "E" end
    buffer[text] = exports['origen_notify']:CreateHelp(key, formattedText or text)
end

local function changeText(text, position)
    if type(position) ~= 'string' then position = 'left' end

    SendNUIMessage({
        action = 'CHANGE_TEXT',
        data = {
            text = text,
            position = position
        }
    })
end

local function keyPressed()
    CreateThread(function() -- Not sure if a thread is needed but why not eh?
        SendNUIMessage({
            action = 'KEY_PRESSED',
        })
        Wait(500)
        hideText()
    end)
end

RegisterNetEvent('qb-core:client:DrawText', function(text, position)
    drawText(text, position)
end)

RegisterNetEvent('qb-core:client:ChangeText', function(text, position)
    changeText(text, position)
end)

RegisterNetEvent('qb-core:client:HideText', function()
    hideText()
end)

RegisterNetEvent('qb-core:client:KeyPressed', function()
    keyPressed()
end)

exports('DrawText', drawText)
exports('ChangeText', changeText)
exports('HideText', hideText)
exports('KeyPressed', keyPressed)
```

#### Step 6

Enjoy!! :smile:
{% endtab %}

{% tab title="ESX" %}

### Installation for ESX

#### Step 1

Put the <mark style="color:blue;">**`origen_notify`**</mark> script inside the resources folder.

#### Step 2

Then go to server.cfg and put <mark style="color:blue;">**`ensure origen_notify`**</mark>

#### Step 3

Navigate to the resource es\_extended/client/functions.lua. Once in the resource, delete the functions **\[ESX.ShowHelpNotification]** and **\[ESX.ShowNotification]**:

Next, copy the following lines of code that I will provide below for use.

```lua
---@Vars
local helpNotifications = {}
local OrigenNotify = exports.origen_notify

---@Funcs

---@param text string
local function Trim(text)
    return (text:gsub("^%s*(.-)%s*$", "%1"))
end

---@param text string
---@param secondKey string
local function CreateHelpNotification(text, secondKey)
    local key, textAfter = text:match('%[([^%]]+)%]%s*(para%s+.*)')
    if (not key or Trim(key) == '') then
        key, textAfter = text:match('%[([^%]]+)%]%s*(.*)')
    end
    return OrigenNotify:CreateHelp(secondKey and secondKey or (key and key or ''),
        textAfter and textAfter or (text and text or ''))
end

local function RemoveExpiredNotifications()
    local currentTime = GetGameTimer()

    for key, notification in pairs(helpNotifications) do
        if (currentTime - notification.time) > 200 then
            OrigenNotify:RemoveHelp(notification.id)
            helpNotifications[key] = nil
        end
    end
end

---@param text string
---@param key string
local function ShowHelpNotification(text, key)
    local notification = helpNotifications[text]
    if (notification) then
        notification.time = GetGameTimer()
        return
    end
    helpNotifications[text] = { time = GetGameTimer(), id = CreateHelpNotification(text, key or nil) }
end

---@Threads
CreateThread(function()
    while (true) do
        local sleepThread = 1000
        local hasNotifications = next(helpNotifications) ~= nil

        if hasNotifications then
            sleepThread = 200
            RemoveExpiredNotifications()
        end

        Wait(sleepThread)
    end
end)

function ESX.ShowHelpNotification(...)
    ShowHelpNotification(...)
end

function ESX.ShowNotification(...)
    return OrigenNotify:ShowNotification(...)
end
```

**Locate the Function**: In your script, `es_extended/client/functions.lua` find this functions **\[ESX.TesxUI]** and **\[ESX.HideUI]**:

```lua
function ESX.TextUI(...)
	return IsResourceFound('esx_textui') and exports['esx_textui']:TextUI(...)
end

---@return nil
function ESX.HideUI()
	return IsResourceFound('esx_textui') and exports['esx_textui']:HideUI()
end
```

**Replace** with this code:&#x20;

```lua
local buffer = {}

function ESX.TextUI(text, secondKey)
    if buffer[text] then return end
    local key = secondKey or ""
    local formattedText = text or ""

    if not secondKey then
        if string.find(formattedText, "%[.-%]") then
            key, formattedText = string.match(formattedText, "%[(.)%](.+)"), text:gsub("%[.-%]", "")
        end
    
        if string.find(formattedText, "%~.-%~") then
            key, formattedText = string.match(formattedText, "~(.-)~"), text:gsub("~(.-)~", "")
            if key == "INPUT_ENTER" then
                key = "F"
            else
                key = "E"
            end
        end
        if key == "" then key = "E" end
    end 
    buffer[text] = exports['origen_notify']:CreateHelp(key, formattedText or text)
end

function ESX.HideUI()
    for k, v in pairs(buffer) do
        exports['origen_notify']:RemoveHelp(v)
        buffer[k] = nil
    end
end
```

#### Step 4

Enjoy!! :smile:
{% endtab %}
{% endtabs %}

{% hint style="warning" %}
We recommend uploading our script files without using FileZilla, as the upload process may corrupt our scripts. As a recommendation, please use WinSCP or other reliable programs to upload the files.
{% endhint %}


---

# 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.origennetwork.store/origen-notify/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.
