Skip to main content
Inventory 2.0

Registering items

Define item properties and use behavior without storing item definitions in MySQL.

Define an item​

The custom item definition system manages item data such as weight, description and use behavior.

Configuration

Item definition

Register an item and define what happens when a player uses it.

Example
defineItem({
item = 'bread', -- image name and main item name
formatname = 'Kenyér', -- formatted name
type = 'food', -- can be used to group and find items such as food
tradable = true, -- allows the player to drop the item or place it in storage
candelete = true, -- delete the item on death
weight = 1.25, -- weight per item
stackable = true, -- whether multiple items can share a stack; weapons are not stackable
description = 'Bread is a staple food prepared from a dough of flour and water, usually by baking.', -- item description
model = 'v_ret_247_swtcorn2', -- model used when the item is dropped
}, function(source, item, slot)
local identifier = Config.getIdentifier(source)
if not AquiverInventories[identifier] then return end
Config.DebugMsg(string.format('(player:%s) %s used on slot %s', source, item, slot))

local success = AquiverInventories[identifier].removeItemAtSlot(slot, 1)
if success then
Config.DebugMsg('Removed one amount from the bread.')
end
end)

Use defineItem from another resource​

You can expose defineItem as an export for other resources. The inventory must be loaded before another resource registers an item; otherwise, that item will not be registered. Add the inventory as a dependency in the other resource to enforce the correct start order.

Configuration

Resource dependency

Load the inventory before a resource that registers items through the export.

fxmanifest.lua
dependencies {'av_inventory'}