# LB Phone

If you are using the **LB Phone** and need to integrate it with the **Origen Inventory**, follow the steps below to ensure a proper integration. Please read carefully and proceed according to the specific information relevant to your setup.

### Step 1 - Installation

To complete the integration, you need to add the following files inside the LB Phone resource.

#### First file:

Go to the folder: `lb-phone/client/custom/uniquePhones`

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

#### Second file:

Go to the folder: `lb-phone/server/custom/uniquePhones`

{% file src="/files/93xLVnsLwT9AaQ0rfwQx" %}

### Step 2 - Integration

#### Client Side

Go to the file `lb-phone/client/custom/frameworks/(yourframework)/item.lua` , find this function `function HasItem(...)` and add this code in this file:

```lua
    elseif GetResourceState("origen_inventory") == "started" then
        return (exports.origen_inventory:Search("count", itemName) or 0) > 0
```

Check if the code looks like this form:

```lua
function HasItem(itemName)
    if GetResourceState("ox_inventory") == "started" then
        return (exports.ox_inventory:Search("count", itemName) or 0) > 0
    elseif GetResourceState("origen_inventory") == "started" then
        return (exports.origen_inventory:Search("count", itemName) or 0) > 0
    end

    return QB.Functions.HasItem(itemName)
end
```

#### Server Side

Go to the file `lb-phone/server/custom/frameworks/(yourframework)/qb.lua` , find this function `function HasItem(...)` and add this code on the file:

```lua
    elseif GetResourceState("origen_inventory") == "started" then
        return (exports.origen_inventory:getItemCount(source, itemName) or 0) > 0
```

Check if the code looks like this form:

```lua
function HasItem(source, itemName)
    if GetResourceState("ox_inventory") == "started" then
        return (exports.ox_inventory:Search(source, "count", itemName) or 0) > 0
    elseif GetResourceState("qs-inventory") == "started" then
        return (exports["qs-inventory"]:GetItemTotalAmount(source, itemName) or 0) > 0
    elseif GetResourceState("origen_inventory") == "started" then
        return (exports.origen_inventory:getItemCount(source, itemName) or 0) > 0
    end

    local qPlayer = QB.Functions.GetPlayer(tonumber(source))

    if not qPlayer then
        debugprint("HasItem: Failed to get player for source:", source)
        return false
    end

    return (qPlayer.Functions.GetItemByName(itemName)?.amount or 0) > 0
end
```

*Thanks for **PolDescomm** to find this solution for the code* :heart:

### Step 3 - Configuratión

Now, go to the file `lb-phone/config.lua` and look for the `Config.Item.Inventory` section. Replace the current inventory value with `origen_inventory` so that the **LB Phone** script can properly detect our inventory system.

```lua
Config.Item = {}
-- If you want to set up multiple items & frame colours, see https://docs.lbscripts.com/phone/configuration/#multiple-items--colored-phones
Config.Item.Require = true -- require a phone item to use the phone
--...(the rest of the code found in config.lua)

Config.Item.Inventory = "origen_inventory" --[[
```

**Now, follow the steps according to your server configuration needs:**

* **uniquePhones Enabled:**\
  When `uniquePhones` is enabled, you can have multiple functional phones in the inventory, each containing different information.\
  If you lose the phone item, you will also lose all the data stored inside it.\
  All information for each phone is saved within its corresponding item.
* **uniquePhones Disabled:**\
  When `uniquePhones` is disabled, any phone item in your inventory will display the same information as the first registered phone.\
  Even if you lose the phone item, your data will remain saved.\
  Once you obtain a new phone item, your previous information will still be accessible.

{% tabs %}
{% tab title="Unique Phones Activated" %}
If you are following this documentation, it means you plan to use the **Unique Phones** feature on your server. Therefore, you need to follow the steps below:

#### 1. Add the Item:

```lua
phone = {
    label = "Phone",
    weight = 190,
    stack = false,
    consume = 0,
    client = {
        export = "lb-phone.UsePhoneItem",
        add = function()
            TriggerEvent("lb-phone:itemAdded")
        end,
        remove = function()
            TriggerEvent("lb-phone:itemRemoved")
        end
    }
},

```

#### **2. Enable Unique Phones:**

Now, you need to enable the Unique Phones option in the `lb-phone/config.lua` file.\
Locate the `Config.Item.Unique` setting and set it to **true**:

```lua
Config.Item.Unique = true
```

Once done, restart your server.
{% endtab %}

{% tab title="Unique Phones Desactivated" %}
If you are following this documentation, it means you plan to don't use the **Unique Phones** feature on your server. Therefore, you need to follow the steps below:

#### 1. Add the Item:

```lua
phone = {
    label = "Phone",
    weight = 190,
    stack = false,
    consume = 0,
    client = {
        add = function()
            TriggerEvent("lb-phone:itemAdded")
        end,
        remove = function()
            TriggerEvent("lb-phone:itemRemoved")
        end
    }
},

```

#### **2. Disable Unique Phones:**

Now, you need to disable the Unique Phones option in the `lb-phone/config.lua` file.\
Locate the `Config.Item.Unique` setting and set it to **False**:

```lua
Config.Item.Unique = false
```

Once done, restart your server.
{% endtab %}
{% endtabs %}

Enjoy!! :smile:


---

# 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_inventory/scripts-support/lb-phone.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.
