Skip to main content
Registers a new item definition at runtime (in-memory only, not saved to file). Only safe, declarative fields are accepted, everything else is rejected at any depth.
Items registered this way will be lost on resource restart. Use this to let external scripts define their own items without editing _data/items.lua.

Parameters

Return value

Notes

itemData only accepts the following safe fields; any other field is silently stripped: Required fields: label (string), weight (number, >= 0), stackable (boolean) Optional fields: description, image, close, maxStack, rarity, type, customSymbol, ammo, durability, degrade, decay, consume, isGrenadeType, separateWeight, universal, oxClientEvent, oxClientExport, oxServerExport Optional table fields (validated recursively, no functions allowed inside): metadata, status, useOptions, inventoryOptions, throwableOptions, dynamicMetadata Also:
  • Items registered with registerItem exist only in memory. They are lost on resource restart. If you need persistent items, use the in-game admin menu or add them to _data/items.lua
  • Unknown items are cleaned up lazily when each inventory is first loaded, not at startup, your script can safely call registerItem at any time before the player’s inventory is accessed, typically on resource start
  • You can combine registerItem with registerUsableItem to define both the item and its use behavior from an external script
  • If the item name already exists, registration is rejected to prevent overwriting file-defined items
  • Table fields (like metadata, useOptions, etc.) are deep-copied, so changes to the original table after registration have no effect