Items
config/events.lua > Config.OnUseEvents
In this little guide I'll show you how to trigger a specific event when the player uses an item crafted in av_business.
Trigger a custom event
For this example we are gonna add a custom event for an item type named 'drugs', new item types can be added in config/items.lua > Config.ItemTypes.
We are gonna add a new entry to Config.OnUseEvents table:
['index_key'] = needs to match the item type value,
event = is the event to trigger when you use this item, the event should be client side.
remove = can be true/false, depends if you want to remove the item from player on use
The event to trigger can be located in any resource that you want but for this example we are gonna create it in av_business/client/editable/items.lua.
We are gonna add our custom event at the end of the file:
As you can see the event receives an argument named metadata this info is stored in the item and it contains the item type, ingredients and the prop.
Using this info is on you to trigger an export, event or any function you want.
Last updated