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

PropertyTypeRequiredDescription
labelstringYesDisplay name of the item
weightnumberYesWeight (grams)
stackablebooleanYesCan be stacked
descriptionstringNoItem description
usablebooleanNoCan be used
imagestringNoImage file name
uniquebooleanNoIs unique (for meta data)

Item Images

Item images are added in PNG format to the html/images/ folder.

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)