useClothingItem
Equips a clothing inventory item onto the local player's ped. Both exports are aliases of the same handler, use whichever name reads better against your inventory's API.
This is what an inventory resource should call from its usingItem handler when the item is a kartik-clothing garment. See Inventory Clothing Items.
š” Syntax
exports['kartik-clothing']:useClothingItem(itemData)
exports['kartik-clothing']:equipClothingItem(itemData)š„ Parameters
| Parameter | Type | Optional | Description |
|---|---|---|---|
itemData | table | No | The item, or its metadata. See the accepted shapes below. |
Accepted shapes
The metadata may sit at any of three depths, which covers ox_inventory, qb-inventory and codem-inventory payloads without a wrapper:
-- the metadata directly
{ component = 11, drawable = 84, texture = 2, collection = 'kartikbase', label = 'Jacket' }
-- nested under `metadata` (ox_inventory)
{ name = 'clothing_item', metadata = { component = 11, drawable = 84, ... } }
-- nested under `info` (qb-inventory)
{ name = 'clothing_item', info = { component = 11, drawable = 84, ... } }At least one of component, componentId, prop or propId must be present, or the call logs an error and does nothing.
| Metadata key | Description |
|---|---|
component / componentId | Component slot id, for a non-prop garment. |
prop / propId | Prop slot id, for a prop. |
drawable, texture, palette | The exact variation. |
collection | The streamed collection the drawable belongs to. |
label | Shown in the progress bar (Putting on <label>ā¦). |
š¤ Returns
Nothing.
āļø Behaviour
- No-ops entirely when
Config.Inventory.Enabledisfalse. - Plays the configured progress bar and animation first (
Config.Inventory.ProgressBar). If the player cancels it, the equip is aborted. - With
Config.Inventory.RemoveOnEquip, the item is taken from the inventory as it goes on. - With
Config.Inventory.ToggleEquip, using the item again takes the piece back off and returns the item.
š» Example
-- ox_inventory usingItem handler
exports('useItem', function(event, item, inventory, slot)
if event ~= 'usingItem' then return end
if item.name ~= 'clothing_item' then return end
TriggerClientEvent('my-resource:equip', inventory.id, item)
end)
-- client
RegisterNetEvent('my-resource:equip', function(item)
exports['kartik-clothing']:useClothingItem(item)
end)