Server events
Listen for item and observer changes on the server.
Event reference
4 eventsServer events
Subscribe to changes emitted by the inventory system.
avp_inv:onItemAddedTriggered when an inventory receives a new item.
inventoryUniqueIDstringitemInventoryItemavp_inv:onItemRemovedTriggered when a complete item stack is removed and its itemHash is destroyed.
inventoryUniqueIDstringitemInventoryItemavp_inv:onObserverAddedTriggered when a player is added to the inventory observers.
inventoryUniqueIDstringsourcenumberavp_inv:onObserverRemovedTriggered when a player is removed from the inventory observers.
inventoryUniqueIDstringsourcenumberItem removal
avp_inv:onItemRemoved is only triggered when the full stack is removed. Removing two items from a stack of four does not trigger the event.
Configuration
Item changes
Read the hash of items added to or completely removed from an inventory.
AddEventHandler("avp_inv:onItemAdded", function(inventoryUniqueID, item)
print(item.itemHash)
end)
AddEventHandler("avp_inv:onItemRemoved", function(inventoryUniqueID, item)
print(item.itemHash)
end)
Configuration
Observer changes
Read the inventory weight when an observer is added or removed.
AddEventHandler("avp_inv:onObserverAdded", function(inventoryUniqueID, source)
local weight = exports["avp_inv_4"]:GetWeight(inventoryUniqueID)
print(weight)
end)
AddEventHandler("avp_inv:onObserverRemoved", function(inventoryUniqueID, source)
local weight = exports["avp_inv_4"]:GetWeight(inventoryUniqueID)
print(weight)
end)