Hello, so i installed storage from esx_inventoryhud(GitHub - Trsak/esx_inventoryhud: Fivem resource for ESX framework - Inventory HUD) to conde-b1g_inventory(https://forum.cfx.re/t/esx-conde-b1g-inventory-fast-items-hotbar-notifications-shortcuts-hud-and-much-more/). So i can open the society storage, i can see the items in it but i cant put it in or remove it from storage.
Client script:
local lastStorage = nil
RegisterNetEvent("conde_inventory:openStorageInventory")
AddEventHandler(
"conde_inventory:openStorageInventory",
function(storage)
lastStorage = storage
ESX.TriggerServerCallback(
"esx_inventoryhud:getStorageInventory",
function(storageData)
setStorageInventoryData(storageData)
openStorageInventory()
end,
storage
)
end
)
function refreshStorageInventory()
ESX.TriggerServerCallback(
"esx_inventoryhud:getStorageInventory",
function(storageData)
setStorageInventoryData(storageData)
end,
lastStorage
)
end
function setStorageInventoryData(data)
items = {}
SendNUIMessage
(
{
action = "setInfoText",
text = "daiktadeze"
}
)
local blackMoney = data.blackMoney
local storageItems = data.inventory
local storageWeapons = data.weapons
if blackMoney > 0 then
accountData = {
label = _U("black_money"),
count = blackMoney,
type = "item_account",
name = "black_money",
usable = false,
rare = false,
canRemove = false
}
table.insert(items, accountData)
end
for i = 1, #storageItems, 1 do
local item = storageItems[i]
if item.count > 0 then
item.type = "item_standard"
item.usable = false
item.rare = false
item.canRemove = false
table.insert(items, item)
end
end
for i = 1, #storageWeapons, 1 do
local weapon = storageWeapons[i]
if storageWeapons[i].name ~= "WEAPON_UNARMED" then
table.insert(
items,
{
label = ESX.GetWeaponLabel(weapon.name),
count = weapon.ammo,
type = "item_weapon",
name = weapon.name,
usable = false,
rare = false,
canRemove = false
}
)
end
end
SendNUIMessage(
{
action = "setSecondInventoryItems",
itemList = items
}
)
end
function openStorageInventory()
loadPlayerInventory()
isInInventory = true
SendNUIMessage(
{
action = "display",
type = "storage"
}
)
SetNuiFocus(true, true)
end
RegisterNUICallback(
"PutIntoStorage",
function(data, cb)
if type(data.number) == "number" and math.floor(data.number) == data.number then
local count = tonumber(data.number)
TriggerServerEvent("esx_inventoryhud:putStorageItem", lastStorage, data.item.type, data.item.name, count)
end
Wait(150)
refreshStorageInventory()
Wait(150)
loadPlayerInventory()
cb("ok")
end
)
RegisterNUICallback(
"TakeFromStorage",
function(data, cb)
if IsPedSittingInAnyVehicle(playerPed) then
return
end
if type(data.number) == "number" and math.floor(data.number) == data.number then
TriggerServerEvent("esx_inventoryhud:getStorageItem", lastStorage, data.item.type, data.item.name, tonumber(data.number))
end
Wait(150)
refreshStorageInventory()
Wait(150)
loadPlayerInventory()
cb("ok")
end
)
Server side script:
ESX.RegisterServerCallback(
"esx_inventoryhud:getStorageInventory",
function(source, cb, storage)
local targetXPlayer = ESX.GetPlayerFromId(target)
local weapons, items, blackMoney
TriggerEvent(
"esx_datastore:getSharedDataStore",
storage,
function(store)
weapons = store.get("weapons")
if weapons == nil then
weapons = {}
end
TriggerEvent(
"esx_addoninventory:getSharedInventory",
storage,
function(inventory)
items = inventory.items
if items == nil then
items = {}
end
TriggerEvent(
"esx_addonaccount:getSharedAccount",
storage .. "_blackMoney",
function(account)
if account ~= nil then
blackMoney = account.money
else
blackMoney = 0
end
cb({inventory = items, blackMoney = blackMoney, weapons = weapons})
end
)
end
)
end
)
end
)
RegisterServerEvent("esx_inventoryhud:getStorageItem")
AddEventHandler(
"esx_inventoryhud:getStorageItem",
function(storage, type, item, count)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
if type == "item_standard" then
local sourceItem = xPlayer.getInventoryItem(item)
TriggerEvent(
"esx_addoninventory:getSharedInventory",
storage,
function(inventory)
local inventoryItem = inventory.getItem(item)
-- is there enough in the property?
if count > 0 and inventoryItem.count >= count then
-- can the player carry the said amount of x item?
if sourceItem.weight ~= -1 and (sourceItem.count + count) > sourceItem.weight then
print("Hello Worl~Ą")
else
inventory.removeItem(item, count)
xPlayer.addInventoryItem(item, count)
TriggerEvent("esx_adminmenu:logSociety", storage, GetPlayerIdentifiers(_source), xPlayer, "TAKE", inventoryItem.label, count, inventoryItem.count - count)
TriggerClientEvent(
"pNotify:SendNotification",
_source,
{
text = _U("took_from_storage", count, inventoryItem.label),
type = "success",
timeout = 3000
}
)
end
else
TriggerClientEvent(
"pNotify:SendNotification",
_source,
{
text = _U("took_not_enough"),
type = "error",
timeout = 3000
}
)
end
end
)
elseif type == "item_account" then
TriggerEvent(
"esx_addonaccount:getSharedAccount",
storage .. "_blackMoney",
function(account)
local roomAccountMoney = account.money
if roomAccountMoney >= count then
account.removeMoney(count)
xPlayer.addAccountMoney(item, count)
TriggerEvent("esx_adminmenu:logSociety", storage, GetPlayerIdentifiers(_source), xPlayer, "TAKE", "Špinavé prachy", count, roomAccountMoney)
else
TriggerClientEvent(
"pNotify:SendNotification",
xPlayer.source,
{
text = _U("bad_amount"),
type = "error",
timeout = 3000
}
)
end
end
)
elseif type == "item_weapon" then
TriggerEvent(
"esx_datastore:getSharedDataStore",
storage,
function(store)
local storeWeapons = store.get("weapons") or {}
local weaponName = nil
local ammo = nil
local components = {}
for i = 1, #storeWeapons, 1 do
if storeWeapons[i].name == item then
weaponName = storeWeapons[i].name
ammo = storeWeapons[i].ammo
if storeWeapons[i].components ~= nil then
components = storeWeapons[i].components
end
table.remove(storeWeapons, i)
break
end
end
store.set("weapons", storeWeapons)
xPlayer.addWeapon(weaponName, ammo)
TriggerEvent("esx_adminmenu:logSociety", storage, GetPlayerIdentifiers(_source), xPlayer, "TAKE", weaponName, ammo, 0)
for i = 1, #components do
xPlayer.addWeaponComponent(weaponName, components[i])
end
end
)
end
end
)
RegisterServerEvent("esx_inventoryhud:putStorageItem")
AddEventHandler(
"esx_inventoryhud:putStorageItem",
function(storage, type, item, count)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
if type == "item_standard" then
local playerItemCount = xPlayer.getInventoryItem(item).count
if playerItemCount >= count and count > 0 then
TriggerEvent(
"esx_addoninventory:getSharedInventory",
storage,
function(inventory)
xPlayer.removeInventoryItem(item, count)
inventory.addItem(item, count)
local inventoryItem = xPlayer.getInventoryItem(item)
TriggerEvent("esx_adminmenu:logSociety", storage, GetPlayerIdentifiers(_source), xPlayer, "PUT", inventoryItem.label, count, inventoryItem.count)
end
)
else
TriggerClientEvent(
"pNotify:SendNotification",
xPlayer.source,
{
text = _U("bad_amount"),
type = "error",
timeout = 3000
}
)
end
elseif type == "item_account" then
local playerAccountMoney = xPlayer.getAccount(item).money
if playerAccountMoney >= count and count > 0 then
xPlayer.removeAccountMoney(item, count)
TriggerEvent(
"esx_addonaccount:getSharedAccount",
storage .. "_blackMoney",
function(account)
account.addMoney(count)
TriggerEvent("esx_adminmenu:logSociety", storage, GetPlayerIdentifiers(_source), xPlayer, "PUT", "Špinavé prachy", count, account.money + count)
end
)
else
TriggerClientEvent(
"pNotify:SendNotification",
xPlayer.source,
{
text = _U("bad_amount"),
type = "error",
timeout = 3000
}
)
end
elseif type == "item_weapon" then
TriggerEvent(
"esx_datastore:getSharedDataStore",
storage,
function(store)
local storeWeapons = store.get("weapons") or {}
local pos, playerWeapon = xPlayer.getWeapon(item)
local components = playerWeapon.components
if components == nil then
components = {}
end
table.insert(
storeWeapons,
{
name = item,
ammo = count,
components = components
}
)
TriggerEvent("esx_adminmenu:logSociety", storage, GetPlayerIdentifiers(_source), xPlayer, "PUT", item, count, count)
store.set("weapons", storeWeapons)
xPlayer.removeWeapon(item)
end
)
end
end
)