The following can be used to retrieve data for an item on the client side.
Export
exports.boii_items:find_item(item_id)
Example
-- Retreive the item datalocal item_data = exports.boii_items:find_item('water')-- Print the item data if it was foundif item_data thenprint('Item data found: ' .. json.encode(item_data))elseprint('Item data not found')end
Server Exports
find_item
The following can be used to retrieve an items data on the server side.
Export
exports.boii_items:find_item(item_id)
Example
-- Retreive the item datalocal item_data = exports.boii_items:find_item('water')-- Print the item data if it was foundif item_data thenprint('Item data found: ' .. json.encode(item_data))elseprint('Item data not found')end
use_item
The following can be used to trigger the on use of an item.
However since items are registered as usable through the boii_utils item bridge this can be ran by calling the utils event boii_utils:cl:use_item.
Export
exports.boii_items:use_item(source, item_id)
Example
local _src = sourceexports.boii_items:use_item(_src, 'water')
use_weapon
The following can be used to trigger the on use of a weapon.
However since items are registered as usable through the boii_utils item bridge this can be ran by calling the utils event boii_utils:cl:use_item.
Export
exports.boii_items:use_weapon(source, item_id)
Example
local _src = sourceexports.boii_items:use_weapon(_src, 'weapon_pistol')
drop_item
The following can be used to drop an item.
To do this through an inventory system you will have to code this yourself to your specific inventory.
local _src = sourceexports.boii_items:drop_item(_src, 'water', 1)
pick_up_item
The following can be used to pick up a dropped item.
Suggested method here would be to use a target system *(this has been shown in example)* however a drawtext ui could be used on proximity to a drop. However this requires coding by yourself specific to your server.
This runs internally however could be used externally if you require.
local _src = source-- Retrieve the net id from entitylocal entity_net_id =NetworkGetNetworkIdFromEntity(obj)-- Create a unique reference ID for the dropped item.local unique_id ='dropped_item_' ..tostring(entity_net_id) -- Unique reference ID-- Call the exportexports.boii_items:pick_up_item(_src, entity_net_id, unique_id)
consume_item
The following can be used to consume an item.
This runs internally however you could trigger this externally if required.
The following can be used to add data for a dropped item into both the server side items table and database.
This runs internally however if you need to add data externally you can.
local _src = source-- Retrieve the item datalocal item_data = exports.boii_items:find_item('water')-- Retreive the players position this it to ensure items are created at the players location when droppedlocal position =GetEntityCoords(GetPlayerPed(_src))-- Retrieve the net id from entitylocal entity_net_id =NetworkGetNetworkIdFromEntity(obj)-- Create a unique reference ID for the dropped item.local unique_id ='dropped_item_' ..tostring(entity_net_id) -- Unique reference ID-- Define the drop datalocal drop_data = { model = item_data.model, position = position , item_id = item_data.id, label = item_data.label, amount =1, category = item_data.category, data = item_data.data}-- Call the exportexports.boii_items:add_drop_data(_src, unique_id, drop_data)
update_item_data
The following is used to update an items data table.
local _src = source-- Retrieve the item datalocal item_data = exports.boii_items:find_item('weapon_pistol')-- Define the data to updatelocal updates = { ammo = item_data.ammo -=1, durability = item_data.durability -=10}-- Call the exportexports.boii_items:update_item_data(_src, 'weapon_pistol', updates)
equip_clothing
The following can be used to equip clothing items.
This runs internally however if you wish to equip clothing externally you can do.
local _src = source-- Call the exportexports.boii_items:equip_clothing(_src, 'body_armour')
remove_item
The following can be used to remove an item.
This runs internally when a player drops an item however if you wish to use this externally you can do, however there is not much reason to do this.