bpm91
Intermediate OT User
- Joined
- May 23, 2019
- Messages
- 944
- Solutions
- 7
- Reaction score
- 130
- Location
- Brazil
- YouTube
- caruniawikibr
I'm trying to make the items on the altars be sacrificed, but it's very complicated, if anyone has a script like this or knows how to solve it.
i use tfs .15
i use tfs .15
Lua:
function onUse(cid, item, frompos, item2, topos)
-- Definindo as posições iniciais dos altares no mapa
local altar_positions = {
{x = 33246, y = 31590, z = 11, altar_id = 1485},
{x = 33253, y = 31588, z = 11, altar_id = 1486},
{x = 33260, y = 31590, z = 11, altar_id = 1487},
{x = 33259, y = 31601, z = 11, altar_id = 1488},
{x = 33247, y = 31601, z = 11, altar_id = 1489}
}
-- Definindo as posições iniciais dos itens no mapa
local item_positions = {
{x = 33246, y = 31590, z = 11, itemid = 5702},
{x = 33253, y = 31588, z = 11, itemid = 5703},
{x = 33260, y = 31590, z = 11, itemid = 5700},
{x = 33259, y = 31601, z = 11, itemid = 3699},
{x = 33247, y = 31601, z = 11, itemid = 5701}
}
-- Verificar se existem 100 itens em cada altar
local todos_itens_presentes = true
for _, altar_info in ipairs(altar_positions) do
local altar_items_count = 0
for _, item_info in ipairs(item_positions) do
local item_on_altar = getTileItemById({x = altar_info.x, y = altar_info.y, z = altar_info.z, itemid = item_info.itemid})
altar_items_count = altar_items_count + #item_on_altar
end
print("Altar ID:", altar_info.altar_id, "Quantidade de Itens:", altar_items_count)
if altar_items_count < 100 then
todos_itens_presentes = false
break
end
end
-- Se todos os itens estiverem presentes, realizar as ações
if todos_itens_presentes then
-- Remover os itens dos altares
for _, altar_info in ipairs(altar_positions) do
local altar_items = getTileItemById({x = altar_info.x, y = altar_info.y, z = altar_info.z, itemid = altar_info.altar_id})
for _, item in ipairs(altar_items) do
doRemoveItem(item.uid)
end
end
-- Remover os itens de cima dos altares
for _, item_info in ipairs(item_positions) do
local item_on_altar = getTileItemById({x = item_info.x, y = item_info.y, z = item_info.z, itemid = item_info.itemid})
for _, item in ipairs(item_on_altar) do
doRemoveItem(item.uid)
end
end
-- Alterar a alavanca
doTransformItem(item.uid, 1945)
-- Dar ao jogador o item desejado
doPlayerAddItem(cid, 2646, 1)
-- Informar ao jogador que a operação foi bem sucedida
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você realizou o ritual com sucesso!")
else
-- Informar ao jogador que a condição não foi atendida
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você precisa ter 100 itens em cada altar para realizar o ritual.")
end
end