Handle Items Event

The inventory:usedItem event is triggered whenever a player uses an item from their inventory. You can use this event to implement custom logic for specific items.


Event Structure

AddEventHandler('inventory:usedItem', function(itemName, ...)
    -- Your logic here
end)

Parameters

  1. itemName: The name of the used item (string).

  2. ...: Additional parameters if the item sends extra data.


Basic Example: Detect Specific Item Use

AddEventHandler('inventory:usedItem', function(itemName)
    if itemName == "water_bottle" then
        print("Player used a water bottle!")
    end
end)

Implementation Steps

  1. Place the code in a server-side Lua file.

  2. Match the item name (itemName) to your inventory items.

  3. Add any custom functionality as needed.

This event is a simple and effective way to extend your inventory system with custom item logic.

Last updated

Was this helpful?