Skip to main content

Exports

Client-side

RegisterItemHandler

Register a new usage handler when an item is used. An item can have multiple handlers from different resources, but only one handler per resource.

client/main.lua
exports.phynix:RegisterItemHandler("scratchcard", function(item, invIndex)
local rand = math.random();
if rand < 0.01 then
TriggerEvent("core:notify", "You have won :D");
else
TriggerEvent("core:notify", "You did not win :(");
end
end);

UseItem

Force the player to use an item. This function will not check if the player has the item before it is used.

client/main.lua
exports.phynix:UseItem(name --[[string]], invIndex --[[int]]);
-- name: the name of the item to use
-- invIndex: the inventory index of item used

GetItemAttribute

Return an attribute of a specific item.

client/main.lua
local value --[[any]] = exports.phynix:GetItemAttribute(name --[[string]], key --[[string]]);
-- name: the item name
-- key: the key of the attribute to return

This can be useful when specific item data is needed, for instance the weight of a Pistol:

client/main.lua
local weight = exports.phynix:GetItemAttribute("pistol", "weight");
TriggerEvent("core:notify", "A Pistol weighs "..weight.." units");

Server-side

GetItem

Return all attributes of a specific item.

server/main.lua
local item --[[table]] = exports.phynix:GetItem(item --[[string]]);

GetItems

Return a dictionary of all items and their attributes, indexed by name.

server/main.lua
local items --[[table]] = exports.phynix:GetItems();

GetItemById

Return all attributes of a specific item, except using the item ID rather than name.

server/main.lua
local item --[[table]] = exports.phynix:GetItemById(itemId --[[int]]);
caution

This is slower than directly accessing an item by index using GetItem and should be avoided.

GetItemDurabilityList