📱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

Second file:

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

Step 2 - Integration

Client Side

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

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

Check if the code looks like this form:

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/qb/qb.lua , find this function function HasItem and add this code on the file:

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

Check if the code looks like this form:

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 ❤️

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.

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.

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:

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:

Config.Item.Unique = true

Once done, restart your server.

Enjoy!! 😄

Last updated