API

Client Exports

find_item

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 data
local item_data = exports.boii_items:find_item('water')

-- Print the item data if it was found
if item_data then
    print('Item data found: ' .. json.encode(item_data))
else
    print('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 data
local item_data = exports.boii_items:find_item('water')

-- Print the item data if it was found
if item_data then
    print('Item data found: ' .. json.encode(item_data))
else
    print('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 = source
exports.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 = source
exports.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.

Export

exports.boii_items:drop_item(source, item_id, amount)

Example

local _src = source
exports.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.

Export

exports.boii_items:pick_up_item(source, net_id, unique_id)

Example

local _src = source

-- Retrieve the net id from entity
local 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 export
exports.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.

Export

exports.boii_items:consume_item(source, data)

Example

local _src = source

-- Define the item data
local data = {
    item = water,
    statuses = {
        thirst = { add = 20, remove = 0 }
    },
    buffs = { 'replenished' },
    debuffs = {},
    effects = {}
}

-- Call the export
exports.boii_items:consume_item(_src, data)

add_drop_data

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.

Export

exports.boii_items:add_drop_data(source, id, drop_data)

Example

local _src = source

-- Retrieve the item data
local item_data = exports.boii_items:find_item('water')

-- Retreive the players position this it to ensure items are created at the players location when dropped
local position = GetEntityCoords(GetPlayerPed(_src))

-- Retrieve the net id from entity
local 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 data
local 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 export
exports.boii_items:add_drop_data(_src, unique_id, drop_data) 

update_item_data

The following is used to update an items data table.

Export

exports.boii_items:update_item_data(source, item_id, updates)

Example

local _src = source

-- Retrieve the item data
local item_data = exports.boii_items:find_item('weapon_pistol')

-- Define the data to update
local updates = {
    ammo = item_data.ammo -= 1,
    durability = item_data.durability -= 10
}

-- Call the export
exports.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.

Export

exports.boii_items:equip_clothing(source, item_id)

Example

local _src = source

-- Call the export
exports.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.

Export

exports.boii_items:remove_item(source, item, amount)

Example

local _src = source

-- Call the export
exports.boii_items:remove_item(_src, 'water', 1)

Last updated