π Inventory
All information about the inventory and its usage is explained here.
Last updated
All information about the inventory and its usage is explained here.
Last updated
exports('bandage', function(data, slot)
local playerPed = PlayerPedId()
local maxHealth = GetEntityMaxHealth(playerPed)
local health = GetEntityHealth(playerPed)
-- Does the ped need to heal? We can cancel the item from being used.
if health < maxHealth then
-- Triggers internal-code to correctly use items.
-- This adds security, removes the item on use, adds progressbar support, and is necessary for server callbacks.
exports.ox_inventory:useItem(data, function(data)
-- The server has verified the item can be used.
if data then
SetEntityHealth(playerPed, math.min(maxHealth, math.floor(health + maxHealth / 16)))
lib.notify({description = 'You feel better already'})
end
end)
else
-- Don't use the item
lib.notify({type = 'error', description = 'You don\'t need a bandage right now'})
end
end)exports('bandage', function(event, item, inventory, slot, data)
-- Player is attempting to use the item.
if event == 'usingItem' then
local playerPed = GetPlayerPed(inventory.id)
local maxHealth = GetEntityMaxHealth(playerPed)
local health = GetEntityHealth(playerPed)
-- Check if the player needs to be healed.
if health >= maxHealth then
TriggerClientEvent('ox_lib:notify', inventory.id, {type = 'error', description = 'You don\'t need a bandage right now'})
-- Returning 'false' will prevent the item from being used
return false
end
return
end
-- Player has finished using the item.
if event == 'usedItem' then
return TriggerClientEvent('ox_lib:notify', inventory.id, {description = 'You feel better already'})
end
-- Player is attempting to purchase the item.
if event == 'buying' then
return TriggerClientEvent('ox_lib:notify', inventory.id, {type = 'success', description = 'You bought a bandage'})
end
end)['bandage'] = {
label = 'Bandage',
weight = 10,
stack = true,
close = true,
allowArmed = false,
consume = 0.25, -- Allows 4 times per item usage untill it gets removed
description = 'Bandage for healing',
client = {
export = 'vesx_items.bandage',
},
},