One Studios
Server

Events

Server-side events.

All server events are emitted with TriggerEvent (server-local). Subscribe from any other server resource.

These are post-action notifications: they fire after the operation has already succeeded. To block an action, register a Hook instead.
Any inventory-reference field (inventoryId, fromInventory, toInventory) is string | number: a number (the player's server id) when the inventory belongs to a player, otherwise the internal string id (stash:<name>, trunk:<plate>, ...).

onItemAdded

Fires after an item is added to any inventory.

RegisterNetEvent('one_inventory:onItemAdded', function(payload) end)
payload.source
number | nil
Server id of the player whose inventory changed, or nil for non-player inventories.
payload.inventoryId
string | number
Id of the inventory that received the item.
payload.item
string
Item name.
payload.count
number
Count added.
payload.metadata
table | nil
Final stored metadata.
payload.slot
number | nil
Slot the item landed in.
payload.inventoryType
string
Resolved inventory type (player, stash, trunk, ...).
payload.itemDef
table | nil
The resolved item definition, or nil if the item is unknown.

onItemRemoved

Fires after an item is removed from any inventory.

RegisterNetEvent('one_inventory:onItemRemoved', function(payload) end)
payload.source
number | nil
Server id of the player whose inventory changed, or nil for non-player inventories.
payload.inventoryId
string | number
Id of the inventory the item was removed from.
payload.item
string
Item name.
payload.count
number
Count removed.
payload.metadata
table | nil
Metadata used to match which slot(s) were removed from.
payload.slot
number | nil
Slot the item was removed from, when it was restricted to one.

onItemUsed

Fires after a player uses or consumes an item (status effects applied, durability ticked).

RegisterNetEvent('one_inventory:onItemUsed', function(payload) end)
payload.source
number
Player who used the item.
payload.item
string
Item name.
payload.slot
number
Slot the item was used from.
payload.metadata
table | nil
The item's metadata.

onItemSwapped

Fires after items are swapped between slots or between inventories.

RegisterNetEvent('one_inventory:onItemSwapped', function(payload) end)
payload.source
number | nil
The acting player who triggered the move. nil for a programmatic move, e.g. one made through the SwapSlots export.
payload.fromInventory
string | number
Source inventory id.
payload.toInventory
string | number
Destination inventory id.
payload.fromSlot
number
Source slot index.
payload.toSlot
number
Destination slot index.
payload.count
number
Count that moved.
payload.item
string
Name of the item that moved.
payload.fromType
string
Type of the source inventory.
payload.toType
string
Type of the destination inventory.
payload.fromItem
table
The full source slot item.
payload.toItem
table | nil
The full destination slot item, or nil when the target slot was empty (a move).
payload.action
string
One of move (target empty), stack (same stackable item), or swap (different items).
source identifies the acting player, not "which inventory changed". To determine that, read the per-side fromInventory / toInventory and fromType / toType instead: source can be nil for programmatic moves, and for a transfer triggered by another player it identifies that player rather than either side of the swap.

onShopPurchased

Fires after a successful shop purchase (currency charged, stock decremented, item added).

RegisterNetEvent('one_inventory:onShopPurchased', function(payload) end)
payload.source
number
Buyer's server id.
payload.shop
string
Shop name.
payload.item
string
Item name purchased.
payload.count
number
Count purchased.
payload.currency
string
Currency used (cash, black_money, custom).
payload.price
number
Total price charged.
payload.shopId
string
Same value as shop.
payload.shopType
string
Same value as shopId.
payload.toInventory
string | number
Buyer's inventory id.
payload.toSlot
number | nil
Slot the item landed in.
payload.fromSlot
table
The shop's slot the item was purchased from (a slot table, not a slot number).
payload.itemName
string
Same value as item.
payload.metadata
table | nil
Final stored metadata of the purchased item.
payload.unitPrice
number
Per-unit price after dynamic pricing.

onItemCrafted

Fires after a craft succeeds (ingredients consumed, output added).

RegisterNetEvent('one_inventory:onItemCrafted', function(payload) end)
payload.source
number
Player who crafted.
payload.bench
string
Crafting bench name.
payload.item
string
Output item.
payload.count
number
Output count.
payload.metadata
table | nil
Final stored metadata of the crafted item.
payload.benchId
string
Same value as bench.
payload.benchIndex
number
Recipe slot index on the bench.
payload.recipe
table
The recipe slot.
payload.toInventory
string | number | nil
Crafter's inventory id.
payload.toSlot
number | nil
Slot the item landed in.

onItemDropped

Fires after an item is dropped on the ground.

RegisterNetEvent('one_inventory:onItemDropped', function(payload) end)
payload.source
number
Player who dropped the item.
payload.item
string
Item name dropped.
payload.count
number
Count dropped.
payload.fromInventory
string | number
Inventory the item came from.
payload.fromSlot
number
Source slot index.
payload.fromType
string
Type of the source inventory.
payload.fromItem
table
The full source slot item.
payload.dropId
string
Id of the resulting ground drop.
payload.coords
vector3
Drop location. When the item merges into an adjacent existing drop, this is that drop's location.

onItemGiven

Fires after a player-to-player item transfer.

RegisterNetEvent('one_inventory:onItemGiven', function(payload) end)
payload.source
number
The giver.
payload.targetSource
number
The receiver.
payload.item
string
Item name given.
payload.count
number
Count given.
payload.fromContainerId
string | nil
Set when the give originated from an open container instead of the player's main inventory.

onInventoryOpened

Fires after an inventory UI successfully opens.

RegisterNetEvent('one_inventory:onInventoryOpened', function(payload) end)
payload.source
number
Player who opened the inventory.
payload.secondaryType
string | nil
One of stash, shop, crafting, vehicle, dumpster, drop, player, or nil when only the player's own inventory is open.
payload.secondaryId
string | number | nil
Id of the secondary inventory. Shape depends on secondaryType: a plate-prefixed id (trunk:<plate> / glovebox:<plate>) for vehicle, the target's server id for player, and a raw unprefixed name/id (stash name, shop name, bench name, drop id, dumpster id) for the rest.

onInventoryClosed

Fires after an inventory UI closes.

RegisterNetEvent('one_inventory:onInventoryClosed', function(payload) end)
payload.source
number
Player who closed the inventory.

onDefinitionsUpdated

Fires after any item-like definition (item, weapon, ammo, component, container, or clothing) is created, edited, or deleted from any source (admin panel, file import, migration, the CreateItemsDefinition runtime export). Rapid bursts are coalesced into a single event.

AddEventHandler('one_inventory:onDefinitionsUpdated', function() end)
No payload. Use it to rebuild any cached definition list via GetAllItemDefinitions.