This ESX script allows you to place storage at any coordinate you want! The script will draw a marker and allow you to deposit / withdraw objects with ox inventory using the stash module. This script does require OX Inventory (GitHub - overextended/ox_inventory: Slot-based inventory with metadata.)
Support will not be provided. I am using es_extended from txAdmin
Had one other report that the SQL wasn’t working properly, I’m not entirely sure why. For the time being, it goes into the addon_inventory table if you would like to manually add it. Sorry!
It would be possible if you ran a job check in the server callback for import/export I would assume.
These code lines are untested, but would go in the server/main.lua (replacing these existing functions)
ESX.RegisterServerCallback('esx_CustomStorage:getStockItems', function(source, cb, storageName)
local xPlayer = ESX.GetPlayerFromId(source)
if Config.ServerPrint then
print('Getting items from: ' .. storageName)
end
if xPlayer.getJob().name== 'police' then
TriggerEvent('esx_addoninventory:getSharedInventory', storageName, function(inventory)
cb(inventory.items)
end)
end
end)
RegisterNetEvent('esx_CustomStorage:putStockItems')
AddEventHandler('esx_CustomStorage:putStockItems', function(itemName, count, storageName)
local xPlayer = ESX.GetPlayerFromId(source)
local sourceItem = xPlayer.getInventoryItem(itemName)
if xPlayer.getJob().name== 'police' then
TriggerEvent('esx_addoninventory:getSharedInventory', storageName, function(inventory)
local inventoryItem = xPlayer.getInventoryItem(itemName)
-- does the player have enough of the item?
if sourceItem.count >= count and count > 0 then
xPlayer.removeInventoryItem(itemName, count)
inventory.addItem(itemName, count)
xPlayer.showNotification('You have deposited ~b~' .. count .. ' ~y~' .. inventoryItem.label)
else
xPlayer.showNotification('Invalid Amount')
end
end)
end
end)
RegisterNetEvent('esx_CustomStorage:getStockItem')
AddEventHandler('esx_CustomStorage:getStockItem', function(itemName, count, storageName)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
if xPlayer.getJob().name== 'police' then
TriggerEvent('esx_addoninventory:getSharedInventory', storageName, function(inventory)
local inventoryItem = inventory.getItem(itemName)
-- is there enough in the society?
if count > 0 and inventoryItem.count >= count then
if xPlayer.canCarryItem(itemName, count) then
inventory.removeItem(itemName, count)
xPlayer.addInventoryItem(itemName, count)
xPlayer.showNotification('You have withdrawn ~b~' .. count .. ' ~y~ ' .. inventoryItem.label)
else
xPlayer.showNotification('~r~Invalid Amount')
end
else
xPlayer.showNotification('~r~Invalid Amount')
end
end)
end
end)