Config
You can check out default config
config = {}
config.keyToAccept = 'e' -- which key confirms lock picking
config.inventoryType = 'Configure' -- qbcore, esx, oxinventory
-- A function that checks the possession of an item and the taking of an item / Server side
config.doesPlayerHaveItem = function(source, itemName, amount)
if config.inventoryType == 'esx' then
while ESX == nil do
ESX = exports['es_extended']:getSharedObject()
Wait(5)
end
local xPlayer = ESX.GetPlayerFromId(source)
local itemCount = xPlayer.getInventoryItem(itemName).count
if itemCount ~= nil and itemCount >= amount then
xPlayer.removeInventoryItem(itemName, amount)
return true
end
return false
elseif config.inventoryType == 'qbcore' then
while QBCore == nil do
QBCore = exports['qb-core']:GetCoreObject()
Wait(5)
end
local player = QBCore.Functions.GetPlayer(source)
local totalAmount = 0
for _, item in ipairs(player.Functions.GetItemsByName(itemName)) do
totalAmount = totalAmount + item.amount
end
if totalAmount >= amount then
player.Functions.RemoveItem(itemName, amount)
return true
end
return false
elseif config.inventoryType == 'oxinventory' then
if exports.ox_inventory:GetItemCount(source, itemName) >= amount then
exports.ox_inventory:RemoveItem(source, itemName, amount)
return true
end
return false
else
print("Configure your inventoryType correctly in config.lua.")
return false
end
end
Last updated