sg-bags

Free

Advanced backpack system for QBCore (qb-inventory and ox_inventory) that allows players to carry additional storage through usable backpack items.

Overview

A sophisticated backpack system for QBCore Framework that allows players to carry additional storage through usable backpack items. Each backpack creates a unique persistent storage that maintains its contents even after server restarts.

Features

  • Persistent Storage - Each backpack has a unique ID and maintains its contents across server restarts
  • Multiple Backpack Types - Support for 7 different backpack types with customizable capacities
  • Anti-Exploit Measures - Built-in protection against bag inception (putting bags inside bags)
  • Banned Items System - [TEMPORARILY DISABLED] Configurable system to prevent specific items from being stored in bags - will be re-implemented in a future update
  • Smooth Animations - Custom animations when opening/accessing backpacks
  • Database Integration - Automatic database table creation and management
  • Performance Optimized - Efficient database queries with optional indexing
  • Inventory Support - Works with qb-inventory and ox_inventory
  • Developer Friendly - Debug mode for easier troubleshooting
  • Bag Recovery System - Admin command to recover lost bags with original contents

Dependencies

  • QBCore Framework
  • qb-inventory or ox_inventory
  • oxmysql

Installation

1

Install Dependencies

Ensure you have all dependencies installed

2

Download the Script

Download the script

3

Place Script

Place the script in your resources folder

4

Copy Items

Copy the contents of install/items.lua to your qb-core/shared/items.lua

5

Copy Images

Images (choose based on your inventory):

If using qb-inventory: copy all images from install/images/ to qb-inventory/html/images/

If using ox_inventory: copy all images from install/images/ to ox_inventory/web/images/

6

Add to server.cfg

ensure sg-bags

Installation Files

The script comes with an install folder containing:

  • - items.lua - Ready to use QB-Core items configuration
  • - images/ - All required backpack images
  • - backpack1.png
  • - backpack2.png
  • - backpack3.png
  • - backpack4.png
  • - backpack5.png
  • - backpack6.png
  • - backpack7.png

Note: After copying the files, make sure to restart your QB-Core resource to apply the new items.

Configuration

The script is highly configurable through the config.lua file:

Config = {
    Debug = false,        -- Enable/disable debug messages
    FirstTime = false,    -- Enable for first installation (creates database index)
    Inventory = 'auto',   -- 'auto' | 'qb' | 'ox'
    Animation = {         -- Animation settings
        Dict = 'clothingshirt',
        Anim = 'try_shirt_positive_d'
    },
    DatabaseTable = 'sg_bags', -- Database table name
    AllowedJob = 'admin',  -- Job that can use /recoverbag command

    -- ox_inventory hooks (used when Inventory == 'ox' or auto-detected)
    Client = {
        OpenInventory = function(stashId)
            if exports.ox_inventory and exports.ox_inventory.openInventory then
                exports.ox_inventory:openInventory('stash', stashId)
            else
                TriggerServerEvent('ox_inventory:openInventory', 'stash', stashId)
            end
        end,
    },
    Server = {
        RegisterStash = function(stashId, label, slots, maxWeight)
            if exports['ox_inventory'] and exports['ox_inventory'].RegisterStash then
                exports.ox_inventory:RegisterStash(stashId, label, slots, maxWeight, false)
            end
        end,
    }
}

Backpack Configuration

You can configure multiple backpack types with different capacities:

Backpacks = {
    backpack1 = {
        maxWeight = 100000,
        slots = 100
    },
    -- Add more backpack types as needed
}

Banned Items

[TEMPORARILY DISABLED] The banned items functionality has been temporarily removed during development. It will be re-implemented in a future update with improved functionality and better integration with both qb-inventory and ox_inventory systems.

Usage

  1. Add backpack items to your QB-Core shared items
  2. Give players backpack items through your preferred method
  3. Players can use the backpack from their inventory
  4. Each backpack creates a unique storage instance
  5. If using ox_inventory, you can force ox by setting Config.Inventory = 'ox' (or leave auto to detect)

Bag Recovery

The script includes a /recoverbag command to help recover lost or bugged bags:

  • Command: /recoverbag
  • Permission: Only players with the job specified in Config.AllowedJob can use this command (default: 'admin')
  • Usage:
  • 1. Type /recoverbag in chat
  • 2. A menu will appear showing all bag IDs in the database
  • 3. Select a bag to recover
  • 4. The bag will be added to your inventory with all its original contents preserved

This feature is useful for:

  • - Recovering bags lost due to server crashes
  • - Fixing bugged or inaccessible bags
  • - Administrative purposes when helping players

Database

The script automatically creates its required database table. The table structure is:

CREATE TABLE IF NOT EXISTS `sg_bags` (
    `bag_id` VARCHAR(64) NOT NULL,
    `slots` INT NOT NULL,
    `maxweight` INT NOT NULL,
    `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`bag_id`)
)

Debug Mode

Enable debug mode in config.lua to get detailed console output about:

  • - Bag creation
  • - Storage operations
  • - Error messages
  • - Performance metrics

Important Notes

  • Blocked items functionality is temporarily disabled and will return in a future update
  • Adjust backpack capacities based on your server's economy
  • First-time setup should have FirstTime = true in config