Epsilon Inventory - Item Management
Adding new items to the inventory, image settings, and meta data usage.
Adding New Items
Define new items in the items.lua file:
items.lua
Items = {
['bread'] = {
label = 'Bread',
weight = 200,
stackable = true,
description = 'Fresh bread, satisfies hunger.',
usable = true,
image = 'bread.png'
},
['lockpick'] = {
label = 'Lockpick',
weight = 300,
stackable = true,
description = 'Used to open vehicle doors.',
usable = true,
image = 'lockpick.png'
},
['radio'] = {
label = 'Radio',
weight = 500,
stackable = false,
description = 'Used for communication.',
usable = true,
image = 'radio.png',
unique = true
}
}
Item Properties
| Property | Type | Required | Description |
|---|---|---|---|
label | string | Yes | Display name of the item |
weight | number | Yes | Weight (grams) |
stackable | boolean | Yes | Can be stacked |
description | string | No | Item description |
usable | boolean | No | Can be used |
image | string | No | Image file name |
unique | boolean | No | Is unique (for meta data) |
Item Images
Item images are added in PNG format to the html/images/ folder.
- Recommended size: 128x128px
- Format: PNG (transparent background)
- File name must match the item name (e.g.,
bread.png)
Meta Data Usage
Meta data is used to add additional information to unique items:
Server - Lua
-- Add item with meta data
exports['epsilon-inventory']:addItem(source, 'weapon_pistol', 1, {
serial = 'EPS-' .. math.random(100000, 999999),
durability = 100,
ammo = 30
})
-- Read meta data
local items = exports['epsilon-inventory']:getItems(source)
for _, item in pairs(items) do
if item.name == 'weapon_pistol' then
print('Serial No:', item.metadata.serial)
print('Durability:', item.metadata.durability)
end
end
Usable Item Registration
Register an item on the server side to make it usable:
Server - Lua
exports['epsilon-inventory']:registerUsableItem('bread', function(source, item)
local xPlayer = ESX.GetPlayerFromId(source)
-- Remove the item
exports['epsilon-inventory']:removeItem(source, 'bread', 1)
-- Increase hunger value
TriggerClientEvent('esx_status:add', source, 'hunger', 200000)
-- Notification
xPlayer.showNotification('You ate bread.')
end)