function addToInventory(item, type, inventory)
local max = 9999999
local toAdd = item.count
while toAdd > 0 do
toAdd = AttemptMerge(item, inventory, toAdd, max)
if toAdd > 0 then
toAdd = AddToEmpty(item, type, inventory, toAdd, max)
else
toAdd = 0
end
end
end
function AttemptMerge(item, inventory, count)
local max = getItemDataProperty(item.name, 'max') or 9999999
for k, v in pairs(inventory) do
if v.name == item.name then
if v.count + count > max then
local tempCount = max - inventory[k].count
inventory[tostring(k)].count = max
count = count - tempCount
elseif v.count + count <= max then
inventory[tostring(k)].count = v.count + count
return 0
else
print('Missing MERGE condition')
end
end
end
return count
end
function AddToEmpty(item, type, inventory, count)
local max = getItemDataProperty(item.name, 'max') or 9999999
for i = 1, InvType[type].slots, 1 do
if inventory[tostring(i)] == nil then
if count > max then
inventory[tostring(i)] = item
inventory[tostring(i)].count = max
return count - max
else
inventory[tostring(i)] = item
return 0
end
end
end
print('Inventory Overflow!')
return 0
end
function createDisplayItem(item, esxItem, slot, price, type)
local max = 9999999
return {
id = esxItem.name,
itemId = esxItem.name,
qty = item.count,
slot = slot,
label = esxItem.label,
type = type or 'item',
max = getItemDataProperty(esxItem.name, 'max') or max,
stackable = true,
unique = esxItem.rare,
usable = esxItem.usable,
giveable = true,
description = getItemDataProperty(esxItem.name, 'description'),
limiti = esxItem.weight,
metadata = {},
staticMeta = {},
canRemove = esxItem.canRemove,
price = price or 0,
needs = false,
closeUi = getItemDataProperty(esxItem.name, 'closeonuse'),
}
end
Datana "max" adındaa bir stün eklemen gerekiyor. Güle güle kullan kadim dostum