fix(es_extended/server/functions): return new item count on refresh

This commit is contained in:
Kenshin13
2025-07-25 11:58:30 +02:00
parent 60e1d7e7c8
commit 513003fe08
2 changed files with 7 additions and 3 deletions
+5 -1
View File
@@ -668,15 +668,19 @@ if not Config.CustomInventory then
end
end
---@return number newItemCount
function ESX.RefreshItems()
ESX.Items = {}
local items = MySQL.query.await("SELECT * FROM items")
for i = 1, #items do
local itemCount = #items
for i = 1, itemCount do
local item = items[i]
ESX.Items[item.name] = { label = item.label, weight = item.weight, rare = item.rare, canRemove = item.can_remove }
end
refreshPlayerInventories()
return itemCount
end
---@param items { name: string, label: string, weight?: number, rare?: boolean, canRemove?: boolean }[]
@@ -440,9 +440,9 @@ end, true, { help = TranslateCap("command_clearall") })
if not Config.CustomInventory then
ESX.RegisterCommand("refreshitems", "admin", function(xPlayer)
ESX.RefreshItems()
local itemCount = ESX.RefreshItems()
xPlayer.showNotification(Translate("command_refreshitems_success", #ESX.Items), true, false, 140)
xPlayer.showNotification(Translate("command_refreshitems_success", itemCount), true, false, 140)
end, true, { help = TranslateCap("command_refreshitems") })
ESX.RegisterCommand(