--// Edidtable \\--
local slot = 3 --- slot id , must contain a container to check in.
local itemm = { -- item id , transfrom to itemid
[2446] = {transformto = 2466},
[2774] = {transformto = 1192}
}
local transform_all_found = true -- set to false if you want to transform only 1 item not all found items
--// function \\--
function doScanContainerFor(uid, id) -- Returns a table of uid of matched item and true if item found else it returns false
local ret,containers, scan = h, {}, {}
for i = 0, getContainerSize(uid) do
local v = getContainerItem(uid, i)
if v.itemid == id then
table.insert(scan,v.uid)
end
if isContainer(v.uid) and getContainerSize(v.uid) > 0 then
table.insert(containers, v.uid)
end
end
for i = 1, #containers do
check = doScanContainerFor(containers[i], id)
if check then
for i = 1,#check do
table.insert(scan,check[i])
end
end
end
return #scan > 0 and true and scan or false
end
--// Script \\--
function onUse(cid, item, fromPosition, itemEx, toPosition)
for k,v in pairs(itemm) do
local scanned = doScanContainerFor(getPlayerSlotItem(cid,slot).uid, k)
if scanned then
if transform_all_found then
for _,t in ipairs(scanned) do
doTransformItem(t,v.transformto)
end
else
doTransformItem(scanned[1],v.transformto)
end
end
end
return true
end