Kartik Scripts

Inventory Clothing Items & Stable IDs

Turn purchased clothing into real inventory items. Buy a jacket in a shop and it arrives in your inventory as an item carrying its drawable, texture, stable hash identifier, and preview image in metadata; use the item to put it on, use it again to take it off.

Configured in shared/config_inventory.lua.


๐ŸŒŸ How It Works

  1. A player checks out in a clothing shop. For each cart line the server builds an item with metadata describing the exact garment and adds it to their inventory.
  2. Using the item fires the equip flow: an optional progress bar plays, then the piece goes on the ped.
  3. With RemoveOnEquip, the item is consumed as it goes on. Taking the piece off hands the item back with its metadata intact, so nothing is lost.

โš™๏ธ Configuration

Config.Inventory = {
    Enabled        = true,  -- Master toggle for the whole system
    RemoveOnEquip  = true,  -- Consume the item once it is on the ped
    UseGenericItem = true,  -- One item for everything, vs slot-specific item names
    DefaultItem    = 'clothing_item',

    AutoEquip      = true,  -- Equip immediately on use
    ToggleEquip    = true,  -- Using it again takes the piece back off

    ProgressBar = {
        Enabled  = true,
        Duration = 2000, -- ms
        AnimDict = 'clothingtie',
        AnimClip = 'try_tie_neutral_a',
    },

    Items = { --[[ item name -> slot map, see below ]] }
}

Generic vs slot-specific items

  • UseGenericItem = true (default), every purchase becomes one item, Config.Inventory.DefaultItem (clothing_item). The metadata says what it actually is, so one registered item covers the whole wardrobe. This is the simplest setup and the one to start with.
  • UseGenericItem = false: purchases use the slot-specific names from Config.Inventory.Items (torso, pants, hat, โ€ฆ). You must register every one of those items in your inventory resource.

[!IMPORTANT] To register clothing_item or slot-specific item names in ox_inventory, qb-core, qs-inventory, or codem-inventory, see the step-by-step Item-Based Clothing Installation Guide.


๐Ÿ”‘ Stable Clothing Identifiers & Addon Hashes

When clothing is stored as an inventory item, pure numeric IDs (drawable: 45) can break whenever new clothing packs are added or FiveM game builds update, shifting numeric index offsets.

kartik-clothing solves this by calculating and storing Stable Clothing Hashes in item metadata:

  1. Hash Generation: Addon items generate a deterministic hash derived from the streamed collection name, YMT/YTD asset name, component slot, and texture ID.
  2. Pack Resiliency: If a new clothing pack changes numeric drawable indices, kartik-clothing resolves the item via its stable hash identifier rather than raw index numbers.
  3. Inventory Durability: Clothing items stored in player inventories, stashes, or trunk inventories remain fully functional across server updates and clothing pack additions.

๐Ÿท๏ธ Item Metadata

Every clothing item carries the garment it represents:

KeyDescription
component / propThe slot id, whichever kind it is; the other is nil.
drawable, texture, paletteThe exact variation indices.
clothingId / hashThe Stable Clothing Identifier protecting items against pack re-indexing.
collectionThe streamed collection the drawable belongs to (kartikbase for design-studio garments).
label, descriptionDisplay text, defaulted from the slot name.
image / imageurl / imageUrl / url / iconThe preview thumbnail URL, written under every key so it renders whatever your inventory reads.

The preview URL is built by the same helper the shop grid uses, so a default-colour item gets the same image in the inventory as it had on the shelf.


๐Ÿ‘• Taking Clothing Off

/takeoff and /puton work whether or not the item system is on. With it on, removing a piece grants the item back to the player's inventory. See Commands & Keybinds.

A removed slot falls back to Config.BareDefaults for that body, so nobody ends up with a floating torso.


๐Ÿ”Œ For Developers

Two client exports let another resource drive the equip flow, both take the item's metadata table and are what an inventory's usingItem handler should call:

exports['kartik-clothing']:useClothingItem(itemData)
exports['kartik-clothing']:equipClothingItem(itemData)

See useClothingItem. The metadata may be passed as the item table itself, or nested under metadata or info, all three shapes are accepted, which covers ox_inventory, qb-inventory and codem-inventory item payloads.

Two net events do the inventory side, and are what the client fires as a piece goes on or comes off:

EventDirectionPayload
kartik-clothing:server:removeEquippedItemClient โ†’ Server{ name, slot, metadata }, take the item away as it is worn.
kartik-clothing:server:grantUnequippedItemClient โ†’ ServerThe metadata table, hand the item back as it is removed.

Both no-op when Config.Inventory.Enabled is false.


๐Ÿงฐ Supported Inventories

Bridges ship for ox_inventory, qb-inventory, codem-inventory and the qb/qbx/ESX core usable-item registries. See Supported Frameworks/Scripts.

On this page