data > actions > scripts > enchantmentSystem.lua:
function onUse(cid, item, frompos, item2, topos)
local playerLocation = getCreaturePosition(cid)
local weaponData = {
-- ID da arma | ID do item de encantamento | quantidade do item de encantamento (opcional) | ID do item que a arma será transformada.
{weaponId = 7735, enchantmentId = 2361, transformId = 2453},
{weaponId = 6132, enchantmentId = 2159, amountEnchantment = 10, transformId = 2646}
}
local positions = {
weaponTable = {x = 32352, y = 31912, z = 7}, -- Onde o jogador deverá colocar a arma.
enchantmentTable = {x = 32354, y = 31912, z = 7} -- Onde o jogador deverá colocar o item de encantamento.
}
function check()
for _, data in pairs(weaponData) do
local weapon = getTileItemById(positions.weaponTable, data.weaponId)
local enchantment = getTileItemById(positions.enchantmentTable, data.enchantmentId)
if weapon.itemid == data.weaponId and enchantment.itemid == data.enchantmentId then
local amountEnchantment = enchantment.type and data.amountEnchantment or 1
if doRemoveItem(enchantment.uid, amountEnchantment) then
doRemoveItem(weapon.uid, 1)
doPlayerAddItem(cid, data.transformId, 1)
doSendMagicEffect(playerLocation, 39)
return true
end
end
end
end
if not check() then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Sem itens necessários para o encantamento.")
doSendMagicEffect(playerLocation, CONST_ME_POFF)
end
return true
end
data > actions > actions.xml:
<!-- Coloque a sua ActionID da alavanca -->
<action actionid="11404" event="script" value="enchantmentSystem.lua" />