Postado Março 27, 2018 7 anos @marcot, então amigo, será que você poderia colocar duas coisas a mais no seu script? A 1ª é: Para cada tier a pessoa ter uma quantia necessária de dinheiro, tipo assim.Fusão de Tier 1 para Tier 2: 3 helds tier 1 + 60K Fusão de Tier 2 para Tier 3: 3 helds tier 2 + 150K Fusão de Tier 3 para Tier 4: 3 helds tier 3 + 300K Fusão de Tier 4 para Tier 5: 3 helds tier 4 + 700K Fusão de Tier 5 para Tier 6: 3 helds tier 5 + 1KK Fusão de Tier 6 para Tier 7: 3 helds tier 6 + 1.5KK Fusão de Tier 7 para Tier 7: 3 helds tier 7 + 1.8KK A 2ª é: Poder colocar a fusão de helds tier 7 por tier 7 pois não tá dando para fundir tier 7 "You cannot fuse tier 7 held items." Editado Março 27, 2018 7 anos por Arthasz Walker (veja o histórico de edições)
Postado Março 27, 2018 7 anos Em 27/03/2018 em 02:45, Arthasz Walker disse: @marcot, então amigo, será que você poderia colocar para cada tier a pessoa ter uma quantia necessária de dinheiro, tipo assim.Fusão de Tier 1 para Tier 2: 3 helds tier 1 + 60K Fusão de Tier 2 para Tier 3: 3 helds tier 2+ 150K Fusão de Tier 3 para Tier 4: 3 helds tier 3+ 300K Fusão de Tier 4 para Tier 5: 3 helds tier 4+ 700K Fusão de Tier 5 para Tier 6: 3 helds tier 5+ 1KK Fusão de Tier 6 para Tier 7: 3helds tier 6+ 1.5KK Não estou com nenhum servidor no PC pelo momento para testar, mas tente esse: -- Held Fusion 0.1 by Marcot -- Se encontrou algum erro no script, favor enviar PM explicando os erros -- http://www.tibiaking.com/forum/profile/120572-marcot/ -- Configuracoes necessarias para o script local config = { quest = { -- Precisa fazer quest? (Nao mexa caso negativo) necessaria = false, -- Eh necessario fazer uma quest para liberar o sistema? storageID = 10001, -- Qual o storageID dessa quest? (caso true, anteriormente) }, chestPos = {x = 92, y = 114, z = 7, stackpos = 1}, -- Posicao do Bau (certifique-se que nao tenha nada encima dele) -- Tenha atencao para que a soma das chances dos helds em cada tier seja igual a 100 prices = { ["tier_1"] = 60000, ["tier_2"] = 150000, ["tier_3"] = 300000, ["tier_4"] = 700000, ["tier_5"] = 1000000, ["tier_6"] = 1500000, }, helds = { -- Item IDs e chance de vir o held [1] = { -- Array Tier 1 {ID = 2159, chance = 10}, {ID = 2160, chance = 80}, {ID = 2158, chance = 10}, }, [2] = { -- Array Tier 2 {ID = 2000, chance = 20}, {ID = 2001, chance = 20}, {ID = 2002, chance = 20}, {ID = 2003, chance = 20}, {ID = 2004, chance = 20}, }, [3] = { -- Array Tier 3 }, [4] = { -- Array Tier 4 }, [5] = { -- Array Tier 5 }, [6] = { -- Array Tier 6 }, [7] = { -- Array Tier 7 }, }, } function onUse(cid, item, fromPosition, itemEx, toPosition) if config.quest.necessaria and getPlayerStorageValue (cid, config.quest.storageID) == 0 then -- Erro caso a pessoa use a maquina sem ter feito a quest -- Valido apenas quando a opcao esta ativada doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You don\'t have permission to use this machine.") return false end items = {nil, nil, nil} container = getThingFromPos(config.chestPos) for i = 0, 2 do items[i + 1] = getContainerItem (container.uid, i) if items [i + 1].itemid == 0 or items [i + 1].itemid == nil then -- Erro quando tem menos de 3 itens no bau doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need 3 held items to fuse.") return false end end heldType = {nil, nil, nil} for j=1, 3 do for i=1, 7 do for k = 1, #config.helds[i] do if config.helds[i][k].ID == items[j].itemid then heldType[j] = i end end end if heldType [j] == nil then -- Erro a ser exibido caso o jogador coloque algum item que nao seja um held na maquina doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This machine works only to held items.") return false end end if heldType[1] ~= heldType[2] or heldType[2] ~= heldType[3] then -- Erro a ser exibido caso o jogador coloque helds de tiers diferentes doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need helds with the same tier.") return false elseif heldType[1] == 7 or heldType[2] == 7 or heldType[3] == 7 then doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You cannot fuse tier 7 held items.") return false end if not doPlayerRemoveMoney(cid, config.prices.tier_..heldType[1]) then -- Se nao for possivel retirar a quantia de dinheiro do jogador, finalizar script doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need " .. config.prices.tier_..heldType[1] .. " gold to fuse tier ".. heldType[1].. " held items.") return false end -- Sortear qual held vira for i = 1, 3 do doRemoveItem(items[i].uid, 1) end tierSorteado = heldType[1] + 1 numeroSorte = math.random(1, 100) itemIDSorteado = sorteiaValor (tierSorteado, numeroSorte) doPlayerAddItem(cid, itemIDSorteado, 1) -- Mensagem exibida ao fundir com sucesso doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You received your new held item.") return true end -- Função retirada de https://pt.stackoverflow.com/questions/147884/sorteio-aleat%C3%B3rio-mas-com-diferentes-probabilidades function sorteiaValor (tierSorteado, numeroSorte) x = numeroSorte for i = 1, #config.helds[tierSorteado] do x = x - config.helds[tierSorteado][i].chance if x <= 0 then return config.helds[tierSorteado][i].ID end end end Os preços são configurados no próprio config, a modificação que fiz foi adicionar a variável de configurar e essas 3 linhas: if not doPlayerRemoveMoney(cid, config.prices.tier_..heldType[1]) then -- Se nao for possivel retirar a quantia de dinheiro do jogador, finalizar script doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need " .. config.prices.tier_..heldType[1] .. " gold to fuse tier ".. heldType[1].. " held items.") return false end Se não der certo pode me marcar aqui com o erro que apresentar Editado Março 27, 2018 7 anos por marcot (veja o histórico de edições)
Postado Março 27, 2018 7 anos @marcot Editado Março 27, 2018 7 anos por Arthasz Walker (veja o histórico de edições)
Postado Março 27, 2018 7 anos @Arthasz Walker, Desculpa, fiz um erro besta, nem lembrei que prices era um array kkk. Acho que dessa vez vai, desculpa mesmo não estar podendo testar no momento estou sem meu desktop com os arquivos de otserver Tenta essa versão: -- Configuracoes necessarias para o script local config = { quest = { -- Precisa fazer quest? (Nao mexa caso negativo) necessaria = false, -- Eh necessario fazer uma quest para liberar o sistema? storageID = 10001, -- Qual o storageID dessa quest? (caso true, anteriormente) }, chestPos = {x = 92, y = 114, z = 7, stackpos = 1}, -- Posicao do Bau (certifique-se que nao tenha nada encima dele) -- Tenha atencao para que a soma das chances dos helds em cada tier seja igual a 100 prices = { ["tier_1"] = 60000, ["tier_2"] = 150000, ["tier_3"] = 300000, ["tier_4"] = 700000, ["tier_5"] = 1000000, ["tier_6"] = 1500000, }, helds = { -- Item IDs e chance de vir o held [1] = { -- Array Tier 1 {ID = 2159, chance = 10}, {ID = 2160, chance = 80}, {ID = 2158, chance = 10}, }, [2] = { -- Array Tier 2 {ID = 2000, chance = 20}, {ID = 2001, chance = 20}, {ID = 2002, chance = 20}, {ID = 2003, chance = 20}, {ID = 2004, chance = 20}, }, [3] = { -- Array Tier 3 }, [4] = { -- Array Tier 4 }, [5] = { -- Array Tier 5 }, [6] = { -- Array Tier 6 }, [7] = { -- Array Tier 7 }, }, } function onUse(cid, item, fromPosition, itemEx, toPosition) if config.quest.necessaria and getPlayerStorageValue (cid, config.quest.storageID) == 0 then -- Erro caso a pessoa use a maquina sem ter feito a quest -- Valido apenas quando a opcao esta ativada doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You don\'t have permission to use this machine.") return false end items = {nil, nil, nil} container = getThingFromPos(config.chestPos) for i = 0, 2 do items[i + 1] = getContainerItem (container.uid, i) if items [i + 1].itemid == 0 or items [i + 1].itemid == nil then -- Erro quando tem menos de 3 itens no bau doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need 3 held items to fuse.") return false end end heldType = {nil, nil, nil} for j=1, 3 do for i=1, 7 do for k = 1, #config.helds[i] do if config.helds[i][k].ID == items[j].itemid then heldType[j] = i end end end if heldType [j] == nil then -- Erro a ser exibido caso o jogador coloque algum item que nao seja um held na maquina doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This machine works only to held items.") return false end end if heldType[1] ~= heldType[2] or heldType[2] ~= heldType[3] then -- Erro a ser exibido caso o jogador coloque helds de tiers diferentes doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need helds with the same tier.") return false elseif heldType[1] == 7 or heldType[2] == 7 or heldType[3] == 7 then doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You cannot fuse tier 7 held items.") return false end if not doPlayerRemoveMoney(cid, config.prices["tier_"..heldType[1]]) then -- Se nao for possivel retirar a quantia de dinheiro do jogador, finalizar script doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need " .. config.prices.tier_..heldType[1] .. " gold to fuse tier ".. heldType[1].. " held items.") return false end -- Sortear qual held vira for i = 1, 3 do doRemoveItem(items[i].uid, 1) end tierSorteado = heldType[1] + 1 numeroSorte = math.random(1, 100) itemIDSorteado = sorteiaValor (tierSorteado, numeroSorte) doPlayerAddItem(cid, itemIDSorteado, 1) -- Mensagem exibida ao fundir com sucesso doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You received your new held item.") return true end -- Função retirada de https://pt.stackoverflow.com/questions/147884/sorteio-aleat%C3%B3rio-mas-com-diferentes-probabilidades function sorteiaValor (tierSorteado, numeroSorte) x = numeroSorte for i = 1, #config.helds[tierSorteado] do x = x - config.helds[tierSorteado][i].chance if x <= 0 then return config.helds[tierSorteado][i].ID end end end Editado Março 27, 2018 7 anos por marcot (veja o histórico de edições)
Postado Março 27, 2018 7 anos @marcot Funcionou perfeitamente mano, muito obrigado, posso te marcar em um tópico de ajuda pra ver se você consegue resolver o meu problema irmão? Mas acho que você esqueceu de outra coisa. if not doPlayerRemoveMoney(cid, config.prices["tier_"..heldType[1]]) then -- Se nao for possivel retirar a quantia de dinheiro do jogador, finalizar script doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need " .. >> config.prices.tier_..heldType[1] << .. " gold to fuse tier ".. heldType[1].. " held items.") return false end Você colocou o array no primeiro e não colocou no segundo: Citar config.prices["tier_..heldType[1]] fora isso o script tá ótimo, rep+.
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.