> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jaksam-scripts.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Inventory item added

> Triggered when an item is successfully added to an inventory.

Triggered when an item is successfully added to an inventory.

<CodeGroup>
  ```lua Event theme={null}
  AddEventHandler('jaksam_inventory:onInventoryItemAdded', function(inventoryId, itemName, amount, metadata, slotId)
  end)
  ```

  ```lua Example theme={null}
  AddEventHandler('jaksam_inventory:onInventoryItemAdded', function(inventoryId, itemName, amount, metadata, slotId)
      local inventoryType = exports['jaksam_inventory']:getInventoryType(inventoryId)
      if inventoryType ~= 'player' then return end -- Only handle player inventories

      print(string.format("Item %s (x%d) added to inventory %s", itemName, amount, inventoryId))

      -- For QBCore: Get player by character identifier
      local Player = exports['qb-core']:GetPlayerByCitizenId(inventoryId)
      if Player then
          local playerId = Player.PlayerData.source
          print(string.format("Player %d added item %s", playerId, itemName))
      end

      -- For ESX: Get player by character identifier
      -- local xPlayer = ESX.GetPlayerFromIdentifier(inventoryId)
      -- if xPlayer then
      --     local playerId = xPlayer.source
      --     print(string.format("Player %d added item %s", playerId, itemName))
      -- end
  end)
  ```
</CodeGroup>

### Parameters

| Name          | Data Type     | Description                                                                                |
| ------------- | ------------- | ------------------------------------------------------------------------------------------ |
| `inventoryId` | string        | The inventory identifier. For players, this is the character identifier                    |
| `itemName`    | string        | The name of the item added                                                                 |
| `amount`      | number        | The quantity added                                                                         |
| `metadata`    | table         | The item's metadata                                                                        |
| `slotId`      | number \| nil | The slot where the item was added (can be nil if a slot wasn't specified when adding item) |


## Related topics

- [Server](/jaksam-inventory/events/server/index.md)
- [Item added](/jaksam-inventory/hooks/on-item-added.md)
- [Inventory item removed](/jaksam-inventory/events/server/on-inventory-item-removed.md)
- [Inventory item transferred](/jaksam-inventory/events/server/on-inventory-item-transferred.md)
- [Inventory created](/jaksam-inventory/hooks/on-inventory-created.md)
