Meta Bags

Meta Bags is a fully-featured backpack and inventory system for FiveM servers. It integrates with ox_inventory and provides visual wearable backpacks, lockable bags, and prop-based items.

Meta Bags

Meta Bags is a fully-featured backpack and inventory system for FiveM servers. It integrates with ox_inventory and provides visual wearable backpacks, lockable bags, and prop-based items.


Table of Contents

  1. Requirements
  2. Installation
  3. Configuration
  4. Bag Setup
  5. Integrating with Clothing Menus
  6. Lockable Bags
  7. Whitelist & Blacklist Items

Requirements

  • FiveM server running ox_inventory.
  • Optional: Clothing system (e.g., illenium-appearance) for wearable backpack integration.
  • Basic knowledge of Lua scripting for customizing bag properties.

Installation

  1. Place the MetaBag resource folder into your server’s resources directory.
  2. Ensure ox_inventory is installed and started before MetaBag in your server.cfg:
ensure ox_inventory
ensure MetaBag
  1. Start your server.

Configuration

The config file is located at config.lua. Key options:

return {
    bagItem = 'metabag',               -- Inventory item name used to equip bags
    carryMultipleBags = 3,             -- Number of backpacks a player can
    lockpickItem = 'lockpick',         -- Item used to lockpick locked bags
    bags = { ... }                     -- Define all bag types here
}

Bag Definition

Each bag object can have the following fields:

FieldTypeDescription
metaIDstringUnique identifier for the bag.
slotsnumberNumber of inventory slots the bag provides.
weightnumberMaximum weight the bag can carry.
clothtableOptional clothing components for male/female characters.
proptableOptional prop attachment for non-clothing items.
lockedbooleanDetermines if the bag is initially locked.
hasLockbooleanAllows locking/unlocking with a PIN.
whitelisttableOptional list of allowed item types. Cannot be used with blacklist.
blacklisttableOptional list of blocked item types. Cannot be used with whitelist.

Inventory Item (ox_inventory ONLY)

["metabag"] = {
    weight = 15,
    stack = false,
    close = true,
    description = "How did you get this?",
    consume = 0,          -- don’t consume on use
    client = {
        export = 'env_metabags.bagExport'
    },
    buttons = {
        {
            label = 'Roll/Unroll',
            action = function(slot)
                lib.callback.await('env_metabags:server:rollup', false, slot)
            end
        },
    }
},

Example Bag (Clothing-Based)

{
    metaID = 'backpack1',
    slots = 20,
    weight = 200000,
    cloth = {
        male = { bag = { model = 132, texture = 0 } },
        female = { bag = { model = 132, texture = 0 } }
    }
    hasLock = false,
    canRollup = true
}

Example Bag (Prop-Based)

{
    metaID = 'medicbag',
    slots = 10,
    weight = 50000,
    prop = {
        model = 'xm_prop_smug_crate_s_medical',
        animation = {
            dict = 'missheistdocksprep1hold_cellphone',
            anim = 'static',
        },
        bone = 57005,
        position = {
            pos = vector3(0.29, -0.05, 0.0),
            rot = vector3(-25.0, 280.0, 75.0)
        }
    },
    hasLock = true,
    canRollup = false
}

Integrating with Clothing Menus

MetaBag allows certain clothing items to be blocked when a bag is equipped to prevent clipping or incompatible outfits.

Using BagBlocked State

This disables attached props and components while in your desired clothing menu. Example implementation provided for illenium-appearance.

Navigate to OpenShop function found in illenium-appearance/client/client.lua. - Add LocalPlayer.state:set('BagBlocked', true, false) at the top of the function. - Add LocalPlayer.state:set('BagBlocked', false, false) at the end of the function.

--Example
function OpenShop(config, isPedMenu, shopType)
    -- ENV INTEGRATION
    LocalPlayer.state:set('BagBlocked', true, true)

    TriggerEvent('env_metamasks:client:removeMaskItem')
    Wait(100)
    lib.callback("illenium-appearance:server:hasMoney", false, function(hasMoney, money)
        if not hasMoney and not isPedMenu then
            lib.notify({
                title = "Cannot Enter Shop",
                description = "Not enough cash. Need $" .. money,
                type = "error",
                position = Config.NotifyOptions.position
            })
            return
        end

        client.startPlayerCustomization(function(appearance)
            if appearance then
                if not isPedMenu then
                    TriggerServerEvent("illenium-appearance:server:chargeCustomer", shopType)
                end
                TriggerServerEvent("illenium-appearance:server:saveAppearance", appearance)
            else
                lib.notify({
                    title = _L("cancelled.title"),
                    description = _L("cancelled.description"),
                    type = "inform",
                    position = Config.NotifyOptions.position
                })
            end
            Framework.CachePed()
            -- ENV INTEGRATION
            LocalPlayer.state:set('BagBlocked', false, true)
        end, config)
    end, shopType)
end

This ensures the bags do not become saved as player outfits. Additional integration may be required depending on how your clothing menu works.

Meta Data items for shops

See the example below of proper metadata configuration of a for sale item. This is an example ox inventory shops item. You can make the bags available in any inventory that supports meta data. My reccomendation is fd_shops. See felis.gg

{ name = "metabag", price = 1000, count = 100, metadata = { label = "Backpack 3",    description = 'General purpose storage bag.',  imageurl = 'nui://env_metabags/inventoryimages/backpack3.png',    metaID = 'backpack3' } },

Reload Skin

Most clothing systems have a reload skin option available. To avoid sync issues you can listen for these events. See example for illenium-apppearance in env_metabags/open/illenium.lua. Clear all wearables and after a short wait you can equipBagsFromInventory to reset the player ped at the time the refresh occurs.

RegisterNetEvent('illenium-appearance:client:reloadSkin', function()
    ClearAllWearables()
    Wait(2000)
    equipBagsFromInventory()
end)

Lockable Bags

Some bags can have a PIN lock. See the Example Bag above for reference of how to enable/disable a lockable bag.

{
    metaID = 'duffle18',
    hasLock = true,
    slots = 20,
    weight = 200000,
}
  • Players need to enter the correct PIN to access the bag’s inventory.
  • Lockpick items can be used to bypass locks if configured.

Rollable Bags

You can configure specific bags to be rollable. When bags are rolled they will not trigger prop/component changes. You cannot roll a bag with items in it and you cannot place items into a rolled bag. See the Example Bag section above for reference of how to enable/disable a rollable bag.


Whitelist & Blacklist Items

Meta Bags supports controlling what items a bag can carry:

  • Whitelist: Only listed items are allowed in the bag.
  • Blacklist: Items listed cannot be stored in the bag.
whitelist = {'WEAPON_PISTOL'} -- Only pistols allowed
-- blacklist = {'WEAPON_RPG'} -- Cannot be used with whitelist

Only one of whitelist or blacklist can be applied per bag.