Exports & Events

All exports and events available to integrate this resource into others.

Types & Classes

All types & classes can be found in types.lua.

Suggestions?

If you wish to have any exports and or events added, please head over to our Discord and create a suggestion post. We are happy to allow for easier integration within other resources.

Client Exports

Is Current Empty

Returns if the current item you are holding is empty or not. Will also return false if you are not holding any item. Example:

---@return boolean
local isEmpty = exports["zyke_consumables"]:IsCurrentItemEmpty()

Has Item Equipped

Returns if you currently have an item. Example:

---@return boolean
local hasItem = exports["zyke_consumables"]:HasItemEquipped()

Is Occupied

Returns if you are currently occupied with any action within our script. Placement, consuming, grabbing item etc. If you are using the script and not idling it, you are most likely labeled as occupied. If you are ever struggling with this, you can enable debug mode and it will explicitly tell you what is making you occupied. Example:

---@return boolean
local isOccupied = exports["zyke_consumables"]:IsOccupied()

Get Equipped Item Metadata

Returns the cached metadata for the item you have equipped. You can find guaranteed values in zyke_consumables/types.lua, along with all of the metadata that already existed on the item before you equipped it. Example:

---@return table | nil
local metadata = exports["zyke_consumables"]:GetCurrentMetadata()

Force Item Unequip

Forcefully unequips your item into your inventory if you have one equipped. Still performs the interaction animations & delays. This does wait for all of the interactions to finish before before you can proceed. This will skip the check for the setting autoPourDrinkOnGround and automatically do it if needed. Example:

exports["zyke_consumables"]:ForceUnequip()

Client Events

Personal Setting Changed (Catch)

When you change any of your personal settings, this is triggered. Example:

---@param setting string
---@param value string | boolean
RegisterNetEvent("zyke_consumables:OnPersonalSettingChanged", function(setting, value)
    -- Perform any action in here
end)

World Item Created (Catch)

When someone places an item, this is triggered. It does not track if you are in render, this will trigger for all world items on creation. Example:

---@param activeItemId string
---@param data table
RegisterNetEvent("zyke_consumables:WorldItemCreated", function(activeItemId, data)
    -- Perform any action in here
end)

World Item Removed (Catch)

When someone removes an item, this is triggered. It does not track if you are in render, this will trigger for all world items on removal. Example:

---@param activeItemId string
---@param netId integer
RegisterNetEvent("zyke_consumables:WorldItemRemoved", function(activeItemId, netId)
    -- Perform any action in here
end)

Server Exports

Is Current Empty

Returns if the current item you are holding is empty or not. Will also return false if you are not holding any item. Example:

---@param plyId integer
---@return boolean
local isEmpty = exports["zyke_consumables"]:IsCurrentItemEmpty(plyId)

Has Item Equipped

Returns if you currently have an item. Example:

---@param plyId integer
---@return boolean
local hasItem = exports["zyke_consumables"]:HasItemEquipped(plyId)

Is Occupied

Returns if you are currently occupied with any action within our script. Placement, consuming, grabbing item etc. If you are using the script and not idling it, you are most likely labeled as occupied. If you are ever struggling with this, you can enable debug mode and it will explicitly tell you what is making you occupied. Example:

---@param plyId integer
---@return boolean
local isOccupied = exports["zyke_consumables"]:IsOccupied(plyId)

Get Equipped Item Metadata

Returns the cached metadata for the item you have equipped. You can find guaranteed values in zyke_consumables/types.lua, along with all of the metadata that already existed on the item before. Example:

---@param plyId integer
---@return table | nil
local metadata = exports["zyke_consumables"]:GetCurrentMetadata(plyId)

Force Item Unequip

Forcefully unequips your item into your inventory if you have one equipped. Still performs the interaction animations & delays. This does wait for all of the interactions to finish before before you can proceed. This will skip the check for the setting autoPourDrinkOnGround and automatically do it if needed. Example:

---@param plyId integer
exports["zyke_consumables"]:ForceUnequip(plyId)

Add To Current Item

Add amount to the current item of the target. This is limited to direct consumption-reward items. Example:

---@param plyId integer
---@param amount number
---@param valueType? "amount" | "percentage" @Default "amount"
---@return boolean
local success = exports["zyke_consumables"]:AddToCurrentItem(plyId, amount, valueType)

Give Ingredient

Gives an ingredient, and allows you to configure the metadata easily in one go. Example:

---@param plyId integer
---@param name string @Item name
---@param amount? integer @Default 1
---@param quality? number @Default 100.0
exports["zyke_consumables"]:GiveIngredient(plyId, name, amount, quality)

Add Item

Gives a consumable item. This export will be replaced with specifics for consumption-reward-based & ingredient-based. Example:

---@param plyId integer
---@param itemIdentifier string @item id in settings or item name
---@param amount? integer @Default 1
---@param activeItemId? string @If the metadata is currently cached, most likely won't use this
---@param metadataIngredients? MetadataIngredient[] @If item is ingredient-based, pass in the ingredients you want, see types.lua
---@param quality? number @If item is direct consumption rewards, this is the quality
exports["zyke_consumables"]:AddItem(plyId, itemIdentifier, amount, activeItemId, metadataIngredients, quality)

Craft Item

Crafts an ingredient-based consumable item. Do keep in mind that the ingredients you input will be added on top of the base ingredient configuration. Example:

---@param plyId integer
---@param itemIdentifier string @item id or item name
---@param ingredients? MetadataIngredient[] | {name: string, quality: number}[] @If none provided, it will just have the base items
---@param requireIngredients? boolean @If enabled, it will check & require the items, along with removing them
---@return boolean
local success = exports["zyke_consumables"]:CraftItem(plyId, itemIdentifier, ingredients, requireIngredients)

Last updated

Was this helpful?