Boa tarde! Fiz um script melhor e bem simples. É possível entender o script, Segue o GIF para ver como ele funciona e foi testado no tfs 0.4, tudo certo. Divirta-se
function onUse(cid, item, frompos, item2, topos)
local playerLocation = getCreaturePosition(cid)
local itemData = {
{itemId = 2400, x = 722, y = 658, z = 7},
{itemId = 2401, x = 722, y = 657, z = 7},
{itemId = 2376, x = 724, y = 658, z = 7}
-- Adicione mais itens para combinação aqui
}
local newItemId = 2406 -- ID do novo item após a combinação
local newItemPosition = {x = 724, y = 657, z = 7} -- Posição para o novo item
local foundItems = {}
local hasAllItems = true
for _, data in ipairs(itemData) do
local tileItem = getTileItemById({x = data.x, y = data.y, z = data.z}, data.itemId)
if tileItem.uid > 0 then
table.insert(foundItems, tileItem.uid)
else
hasAllItems = false
break
end
end
if hasAllItems then
for _, uid in ipairs(foundItems) do
if not doRemoveItem(uid, 1) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Erro ao remover um dos itens necessários.")
return false
end
end
local newItem = doCreateItem(newItemId, 1, newItemPosition)
if newItem ~= LUA_ERROR then
doSendMagicEffect(newItemPosition, 39)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Erro ao criar o novo item.")
return false
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você não possui todos os itens necessários para a combinação.")
return false
end
return true
end
@deza
20231130_150112.mp4