# Framework Integration

Most of the setup should be understandable, but I'll highlight a few things you might need additional help with. By default, the script is set up for ESX + ox\_inventory.

## Client Functions

Client functions file can be found at `configurations/client/CFunctions.lua` .

### Inventory

This is designed for convenience, automatically taking item labels from your inventory and using them in buying and selling menus.

* `fetchItems` - toggler to use this feature.
* `labelVar` - variable name in your inventory system.
* `getAllItems` - function that should return all the registered items in your inventory system.

Items table has to be returned as follows:

{% hint style="success" %}
This function is called only **ONCE** when a player first time triggers the menu, all the items are saved in cache. Therefore, retrieving your items from the database or server will not cause any issues, as this function is not repeatedly called.
{% endhint %}

```typescript
type GetAllItems = () => ReturnType;

interface ReturnType {
    [item_name: string]: {
        // This will be your label var, it could also be named differently.
        label: string;
        // Other item variables. They will not be used, but everything is fine if you don't remove them.
        [key: string]: unknown;
    }
}
```

### Notifications

Display notifications sent by the script. If you prefer to not show any notifications, you can just leave this function empty.&#x20;

```typescript
type Notification = (
    message: string,
    duration: number, // This will always be 3000
    type: 'error' | 'success' // Notification type.
) => void;
```

### Text Display

Configure how text is displayed when players approach peds. The functions used depend on your `Config.UseEveryTickText` setting.

**When `Config.UseEveryTickText = true`:**

The script will use this function to display text when player is close to a ped or when player can interact with ped.

```lua
DrawTextEveryTick = function (text, coords)
  BeginTextCommandDisplayHelp("STRING")
  AddTextComponentSubstringPlayerName(text)
  EndTextCommandDisplayHelp(2, false, false, 0)
  SetFloatingHelpTextStyle(1, 1, 2, 191, 3, 0)
  SetFloatingHelpTextWorldPosition(1, coords.x, coords.y, coords.z + 1.0)
end,
```

**When `Config.UseEveryTickText = false`:**

The script will use these functions for the same purpose - showing text when player approaches peds and hiding it when they move away. You will need to implement these functions yourself, but this can be done in your own way.

{% tabs %}
{% tab title="ox\_lib" %}

```lua
ShowText = function (text, coords)
  exports['ox_lib']:showTextUI(text)
end,

HideText = function ()
  exports['ox_lib']:hideTextUI()
end,
```

{% endtab %}

{% tab title="okokTextUI" %}

```lua
ShowText = function (text, coords)
  exports['okokTextUI']:Open(text, 'darkblue', 'right')
end,

HideText = function ()
  exports['okokTextUI']:Close()
end,
```

{% endtab %}
{% endtabs %}

### Example Configuration

{% tabs %}
{% tab title="ESX + ox\_inventory" %}

```lua
CFunctions = {
  inventory = {
    fetchItems = true,
    labelVar = 'label',
    getAllItems = function ()
      return exports['ox_inventory']:Items()
    end
  },

  TriggerServerCallback = function(name, cb, ...)
    ESX.TriggerServerCallback(name, cb, ...)
  end,

  Notification = function (message, duration, type)
    ESX.ShowNotification(message)
  end,
  
  DrawTextEveryTick = function (text, coords)
    BeginTextCommandDisplayHelp("STRING")
    AddTextComponentSubstringPlayerName(text)
    EndTextCommandDisplayHelp(2, false, false, 0)
    SetFloatingHelpTextStyle(1, 1, 2, 191, 3, 0)
    SetFloatingHelpTextWorldPosition(1, coords.x, coords.y, coords.z + 1.0)
  end,
  
  ShowText = function (text, coords)
    -- Add your TextUI logic here
  end,
  
  HideText = function ()
    -- Add your TextUI hide logic here
  end,
}
```

{% endtab %}

{% tab title="QB + ox\_inventory" %}

```lua
CFunctions = {
  inventory = {
    fetchItems = true,
    labelVar = 'label',
    getAllItems = function ()
      return exports['ox_inventory']:Items()
    end
  },

  TriggerServerCallback = function(name, cb, ...)
    QBCore.Functions.TriggerCallback(name, cb, ...)
  end,

  Notification = function (message, duration, type)
    QBCore.Functions.Notify(message, type, duration)
  end,
  
  DrawTextEveryTick = function (text, coords)
    BeginTextCommandDisplayHelp("STRING")
    AddTextComponentSubstringPlayerName(text)
    EndTextCommandDisplayHelp(2, false, false, 0)
    SetFloatingHelpTextStyle(1, 1, 2, 191, 3, 0)
    SetFloatingHelpTextWorldPosition(1, coords.x, coords.y, coords.z + 1.0)
  end,
  
  ShowText = function (text, coords)
    -- Add your TextUI logic here
  end,
  
  HideText = function ()
    -- Add your TextUI hide logic here
  end,
}
```

{% endtab %}

{% tab title="QBX + ox\_inventory" %}

```lua
CFunctions = {
  inventory = {
    fetchItems = true,
    labelVar = 'label',
    getAllItems = function ()
      return exports['ox_inventory']:Items()
    end
  },

  TriggerServerCallback = function(name, cb, ...)
    cb(lib.callback.await(name, false, ...))
  end,

  Notification = function (message, duration, type)
    -- Not sure if this framework has built-in notifications system
  end,
    
  DrawTextEveryTick = function (text, coords)
    BeginTextCommandDisplayHelp("STRING")
    AddTextComponentSubstringPlayerName(text)
    EndTextCommandDisplayHelp(2, false, false, 0)
    SetFloatingHelpTextStyle(1, 1, 2, 191, 3, 0)
    SetFloatingHelpTextWorldPosition(1, coords.x, coords.y, coords.z + 1.0)
  end,
  
  ShowText = function (text, coords)
    -- Add your TextUI logic here
  end,
  
  HideText = function ()
    -- Add your TextUI hide logic here
  end,
}
```

{% endtab %}
{% endtabs %}

## Server Functions

Server functions file can be found at `configurations/server/SFunctions.lua` .

Everything here should be understandable.

### Example Configuration

{% tabs %}
{% tab title="ESX + ox\_inventory" %}

```lua
SFunctions = {
  RegisterServerCallback = function(name, cb, ...)
    ESX.RegisterServerCallback(name, cb, ...)
  end,

  HasMoney = function(source, amount, moneyType)
    local money = 0;

    if not moneyType or moneyType == 'cash' then
      money = exports['ox_inventory']:GetItem(source, 'money', false, true)
    elseif moneyType == 'black' then
      money = exports['ox_inventory']:GetItem(source, 'black_money', false, true)
    end

    return money >= amount
  end,

  AddMoney = function(source, amount, moneyType)
    if not moneyType or moneyType == 'cash' then
      exports['ox_inventory']:AddItem(source, 'money', amount)
    elseif moneyType == 'black' then
      exports['ox_inventory']:AddItem(source, 'black_money', amount)
    end
  end,

  RemoveMoney = function(source, amount, moneyType)
    if not moneyType or moneyType == 'cash' then
      exports['ox_inventory']:RemoveItem(source, 'money', amount)
    elseif moneyType == 'black' then
      exports['ox_inventory']:RemoveItem(source, 'black_money', amount)
    end
  end,

  HasItem = function(source, itemName, amount)
    return exports['ox_inventory']:GetItem(source, itemName, false, true) >= amount
  end,

  CanCarryItem = function (source, itemName, amount)
    return exports['ox_inventory']:CanCarryItem(source, itemName, amount)
  end,

  AddItem = function (source, itemName, amount)
    exports['ox_inventory']:AddItem(source, itemName, amount)
  end,

  RemoveItem = function (source, itemName, amount)
    exports['ox_inventory']:RemoveItem(source, itemName, amount)
  end
}
```

{% endtab %}

{% tab title="QB + ox\_inventory" %}

```lua
SFunctions = {
  RegisterServerCallback = function(name, cb, ...)
    QBCore.Functions.CreateCallback(name, cb, ...)
  end,

  HasMoney = function(source, amount, moneyType)
    local money = 0;

    if not moneyType or moneyType == 'cash' then
      money = exports['ox_inventory']:GetItem(source, 'money', false, true)
    elseif moneyType == 'black' then
      money = exports['ox_inventory']:GetItem(source, 'black_money', false, true)
    end

    return money >= amount
  end,

  AddMoney = function(source, amount, moneyType)
    if not moneyType or moneyType == 'cash' then
      exports['ox_inventory']:AddItem(source, 'money', amount)
    elseif moneyType == 'black' then
      exports['ox_inventory']:AddItem(source, 'black_money', amount)
    end
  end,

  RemoveMoney = function(source, amount, moneyType)
    if not moneyType or moneyType == 'cash' then
      exports['ox_inventory']:RemoveItem(source, 'money', amount)
    elseif moneyType == 'black' then
      exports['ox_inventory']:RemoveItem(source, 'black_money', amount)
    end
  end,

  HasItem = function(source, itemName, amount)
    return exports['ox_inventory']:GetItem(source, itemName, false, true) >= amount
  end,

  CanCarryItem = function (source, itemName, amount)
    return exports['ox_inventory']:CanCarryItem(source, itemName, amount)
  end,

  AddItem = function (source, itemName, amount)
    exports['ox_inventory']:AddItem(source, itemName, amount)
  end,

  RemoveItem = function (source, itemName, amount)
    exports['ox_inventory']:RemoveItem(source, itemName, amount)
  end
}
```

{% endtab %}

{% tab title="QBX + ox\_inventory" %}

```lua
SFunctions = {
  RegisterServerCallback = function(name, cb, ...)
    lib.callback.register(name, function(source, ...)
      local p = promise:new()

      local callback = function(...)
          p:resolve(...)
      end

      cb(source, callback, ...)
      
      return Citizen.Await(p)
    end)
  end,

  HasMoney = function(source, amount, moneyType)
    local money = 0;

    if not moneyType or moneyType == 'cash' then
      money = exports['ox_inventory']:GetItem(source, 'money', false, true)
    elseif moneyType == 'black' then
      money = exports['ox_inventory']:GetItem(source, 'black_money', false, true)
    end

    return money >= amount
  end,

  AddMoney = function(source, amount, moneyType)
    if not moneyType or moneyType == 'cash' then
      exports['ox_inventory']:AddItem(source, 'money', amount)
    elseif moneyType == 'black' then
      exports['ox_inventory']:AddItem(source, 'black_money', amount)
    end
  end,

  RemoveMoney = function(source, amount, moneyType)
    if not moneyType or moneyType == 'cash' then
      exports['ox_inventory']:RemoveItem(source, 'money', amount)
    elseif moneyType == 'black' then
      exports['ox_inventory']:RemoveItem(source, 'black_money', amount)
    end
  end,

  HasItem = function(source, itemName, amount)
    return exports['ox_inventory']:GetItem(source, itemName, false, true) >= amount
  end,

  CanCarryItem = function (source, itemName, amount)
    return exports['ox_inventory']:CanCarryItem(source, itemName, amount)
  end,

  AddItem = function (source, itemName, amount)
    exports['ox_inventory']:AddItem(source, itemName, amount)
  end,

  RemoveItem = function (source, itemName, amount)
    exports['ox_inventory']:RemoveItem(source, itemName, amount)
  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.syntaxa.xyz/advanced-ped-dialog/configuration/framework-integration.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.
