PDA

View Full Version : please help me edite my script



ahmedsaif5
12-09-2019, 01:30 PM
i have only one option in my script to buy one kind of runes ..i want to to add another option ander it to buy runes again like sd .. and there are 4 parts need edite 1- to put items id 2- to put amount to buy 3- to put amount to leave 4- a new label to add in walker

--[[

!!!!Script Original é do: Nixez (do forum do XenoBot)!!!!

Traduzido e adicionou algumas Funções:
Lukz - tibiaking.com
LukzBR - www.pandoriumx.com
https://www.youtube.com/user/OoORonaldoOoO - youtube.com
em outros Forums meu nick é: jaiminho.


!!!OBS: NÃO USE ESSE ARQUIVO, FAÇA SEMPRE UMA COPIA!!!

//////////////////////////
| |
| INICIO DAS INFORMAÇÕES |
| |
//////////////////////////

/// SCRIPT COMEÇA SEMPRE DO LADO DO BANCO(script always starts next to the bank). \\\

Labels:
- AbrirBPs(open bag) -----------------------------(DO LADO DO BANCO)(beside the bank)
- ChecarParaHunt(he checks if you have the necessary items pot rune etc..) -----------------------
- Banco (bank)--------------------------------(DO LADO DO BANCO)
// ANDAR ATÉ O SHOP PARA COMPRAR POTS(go to the npc where you sell potion).
- ComprarPots (buy potion)--------------------------(on the npc side where you sell potion)
- ChecarDenovo(he checks if you bought all potion otherwise he comes back) -------------------------

// ANDAR ATÉ O SHOP PARA COMPRAR RUNAS.
- ComprarRunas (buy rune) -------------------------(DO LADO DA LOJA DE COMPRAR RUNAS)(next to the npc that sells runes)
- ChecarDenovo(he checks if you bought the right amount of rune otherwise he comes back to buy more)

// ANDAR ATÉ O SHOP PARA COMPRAR FLEXAS.(walk to the npc that sells arrow)
- ComprarFlexas (buy munition)------------------------(DO LADO DA LOJA DE COMPRAR FLEXAS SE FOR RP)
- ChecarDenovo(check if you bought all the ammunition correctly otherwise it comes back)-------------------------(DO LADO DO BANCO) ** SE FOR SÓ COMPRAR FLEXAS, VOLTAR AO BANCO ANTES.

- CaminhoHunt(walk to hunt)--------------------------(IR ATÉ A HUNT)

- Start --------------------------------(DENTRO DO RESPAWN)
- ReAbrirBPs(re open backpack ---------------------------(SEMPRE QUE ANDAR POR TODA HUNT, VAI RE-ABRIR AS BPs).
// ANDAR POR TODO SO RESPAWN.(after walking all the respawn you continue).
- ChecarTudo (check if you have potions, rune or ammo)---------------------------(DEPOIS QUE ANDAR POR TODA CAVE)(after walking all over the cave)
- SairDaCave (if I didn't have potion he leaves the cave)---------------------------




///////////////////////
| |
| FIM DAS INFORMAÇÕES |
| |
///////////////////////
--]]


--[[
////////////////////////////
| |
| INICIO DAS CONFIGURAÇÕES |
| |
////////////////////////////

--]]

-- MANA POTION --
local ManaPotID = 23373 --(Potion mana id you will use).
local PrecoMP = 0

-- HEALTH POTION --
local HealthPotID = 0 --(Potion health id you will use)spirit potion and ultimate spirit.
local PrecoHP = 0

-- MUNIÇÃO --
local IDMunicao = 0 -- ID ammunition.
local PrecoMunicao = 0

-- RUNA --
local RunaID = 3191 -- ID RUNE.
local PrecoRuna = 0

--[[///////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////--]]

-- *******COMPRAR QUANTAS(buy how much): (QUANTIDADE)(amount)*******
local QuantidadeMP = 350
-- QUANTIDADE DE MANA POTIONS QUE O BOT IRA COMPRAR PARA IR CAÇAR(amount of mana buy to hunt).

local QuantidadeHP = 0
-- QUANTIDADE DE HEALTH POTIONS QUE O BOT IRA COMPRAR PARA IR CAÇAR(amount of health buy to hunt).

local QuantidadeMunicao = 0
-- QUANTIDADE DE MUNIÇÃO QUE VAI COMPRAR((amount of ammunition buy to hunt)

local QuantidadeRuna = 1000
-- QUANTIDADE DE RUNAS QUE O BOT IRA COMPRAR PARA IR CAÇAR(amount of rune buy to hunt)


--[[///////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////--]]

-- *******SAIR COM(go out with)
local MPSair = 150
-- DEIXAR HUNT SE A QUANTIDADE DE MANA POTIONS FOR MENOR(goes away if mana is less than)
local HPSair = 0
-- DEIXAR HUNT SE A QUANTIDADE DE HEALTH POTIONS FOR MENOR(goes away if health is less than)
local MunicaoSair = 0
-- DEIXAR HUNT SE A QUANTIDADE DE AMMO FOR MENOR (goes away if ammunition is less than)
local QuantidadeRunaSair = 350
-- DEIXAR HUNT SE A QUANTIDADE DE RUNAS FOR MENOR (goes away if rune is less than)
local CapSair = 100
-- DEIXAR HUNT SE A QUANTIDADE DE CAP FOR MENOR(goes away if cap is less than)

--[[///////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////--]]


-- CONFIGURAÇÃO DAS BPs (Do not put the main backpack it already opens automatically only different bags do not put one inside the other)
local LootBP = "red backpack"
local GoldBP = "beach backpack"
local PotsBP = "orange backpack"
local MunicaoBP = ""

--[[
/////////////////////////
| |
| FIM DAS CONFIGURAÇÕES | FINISH CONFIGURATION DO NOT EDIT ANYTHING AFTER THIS LINE PLIS!!!!!!!!!!!!!!!!!
| |
/////////////////////////

NÃO EDITAR NADA DEPOIS DESTA LINHA, EDITE SOMENTE SE VOCE SOUBER O QUE FAZ!.

--]]



registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")


function onWalkerSelectLabel(labelName)
-- CHECA SE VOCE TEM POTS E CAP DURANTE A HUNT.
if (labelName == "ChecarTudo") then
Walker.ConditionalGoto((Self.ItemCount(HealthPotID ) <= HPSair) or
(Self.ItemCount(ManaPotID) <= MPSair) or
(Self.Cap() < CapSair) or
(Self.ItemCount(RunaID) <= QuantidadeRunaSair) or
(Self.ItemCount(IDMunicao) <= MunicaoSair), "SairDaCave", "Start")


-- CHECAR SE TEM OU NÃO TEM POTIONS, SE TER VAI CAÇAR(CaminhoHunt), SE NÃO TER, VAI NO BANCO(Banco) TIRAR GOLD PRA COMPRAR POTS.
elseif (labelName == "ChecarParaHunt") then
Walker.ConditionalGoto((Self.ItemCount(HealthPotID ) < QuantidadeHP) or
(Self.ItemCount(ManaPotID) < QuantidadeMP) or
(Self.ItemCount(RunaID) < QuantidadeRuna) or
(Self.ItemCount(IDMunicao) < QuantidadeMunicao), "Banco", "CaminhoHunt")
Targeting.Start()
Looter.Start()


-- CHECAR SE TEM OU NÃO TEM POTIONS, SE TER VAI CAÇAR(CaminhoHunt), SE NÃO TER, VAI NO BANCO(Banco) TIRAR GOLD PRA COMPRAR POTS.
elseif (labelName == "ChecarDenovo") then
Walker.ConditionalGoto((Self.ItemCount(HealthPotID ) < QuantidadeHP) or
(Self.ItemCount(ManaPotID) < QuantidadeMP) or
(Self.ItemCount(RunaID) < QuantidadeRuna) or
(Self.ItemCount(IDMunicao) < QuantidadeMunicao), "Banco", "CaminhoHunt")
Targeting.Start()
Looter.Start()


-- PEGAR BARCO IDA E VOLTA
elseif (labelName == "Barco1") then
Creature.Follow("Captain Fearless")
Walker.Stop()
Self.SayToNpc("Hi")
wait (1000)
Self.SayToNpc("thais")
wait (1000)
Self.SayToNpc("Yes")
wait(2000,3000)
Walker.Start()

elseif (labelName == "Barco2") then
Creature.Follow("Captain Breezelda")
Walker.Stop()
Self.SayToNpc("Hi")
wait (1000)
Self.SayToNpc("Venore")
wait (1000)
Self.SayToNpc("Yes")
wait(2000,3000)
Walker.Start()


elseif (labelName == "SairDaCave") then
if (Self.Cap() < CapSair) then
print([[SEM CAP, DESATIVANDO LOOTER!]])
Looter.Stop()
end

-- RE-ABRIR TODAS AS BPs **DENTRO DO RESPAWN**
elseif (labelName == "ReAbrirBPs") then
print([[RE-ABRINDO BPs...]])
Cavebot.Stop()
Self.CloseContainers()
Self.OpenMainBackpack(true):OpenChildren({Item.Get ID(LootBP), true},{GoldBP, true},{PotsBP, true},{MunicaoBP, true})
wait(500,1000)
Cavebot.Start()

-- ABRIR TODAS AS BPs
elseif (labelName == "AbrirBPs") then
print([[ABRINDO BPs...]])
Walker.Stop()
Self.CloseContainers()
Self.OpenMainBackpack(true):OpenChildren({Item.Get ID(LootBP), true},{GoldBP, true},{PotsBP, true},{MunicaoBP, true})
wait(500,1000)
Walker.Start()

-- RESETA TODAS AS BPs (PARA DEPOSITAR OS ITEMS DEPOIS DA HUNT)
elseif (labelName == "ResetarBPs") then
print([[RESETANDO BPs, PARA DEPOSITAR TODOS OS ITEMS!...]])
Walker.Stop()
Targeting.Stop()
wait(500,1000)
Self.CloseContainers()
wait(500,1000)
Self.OpenMainBackpack(true)
Container.GetFirst():OpenChildren(LootBP)
wait(500,1000)
if (Self.Stamina() < 960) then -- OBS: 960 minutos = 16 horas!!
Walker.Stop()
print([[VOCE NÃO TEM STAMINA, SAINDO...]])
Self.Logout()
Cavebot.Stop()
else
Walker.Start()
print([[VOCE AINDA TEM STAMINA!]])
end


-- DEPOSITA TODOS OS ITENS QUE VOCE PEGOU NA HUNT E DEPOSITA NO DP E CHECA SE VOCE TEM STAMINA.
--[[ elseif (labelName == "DepositarItems") then
Walker.Stop()
wait(1600,2400)
Self.DepositItems({9689, 0}, {8031, 0}, {10275, 0}, {9692, 0}, {5894, 0})
wait(500,1500)
Self.DepositItems({11485, 0}, {12600, 0}, {10276, 0})
if (Self.Stamina() < 960) then -- OBS: 960 minutos = 16 horas!!
Walker.Stop()
else
Walker.Start()
end--]]

-- VAI NO BANCO TIRAR O TANTO DE GOLD QUE PRECISA PRA COMPRAR OS POTS, RUNAS E MUNIÇÃO QUE ESTÁ DEFIN`O LA EM CIMA.
elseif (labelName == "Banco") then
print([[RETIRANDO DINHEIRO..]])
Walker.Stop()
wait(800,1400)
Self.SayToNpc("hi")
wait(800,1400)
Self.SayToNpc("deposit all")
wait(800,1400)
Self.SayToNpc("yes")
wait(1800,2400)
Self.WithdrawMoney((PrecoMP*(QuantidadeMP-Self.ItemCount(ManaPotID)))+50)
wait(800,1400)
Self.WithdrawMoney((PrecoHP*(QuantidadeHP-Self.ItemCount(HealthPotID)))+50)
wait(800,1400)
Self.WithdrawMoney((PrecoRuna*(QuantidadeRuna-Self.ItemCount(RunaID)))+50)
wait(800,1400)
Self.WithdrawMoney((PrecoMunicao*(QuantidadeMunica o-Self.ItemCount(IDMunicao)))+50)
wait(800,1400)
Self.SayToNpc("balance")
Walker.Start()

-- COMPRA AS RUNAs QUE ESTA DEFINIDO LA EM CIMA.
elseif (labelName == "ComprarRunas") then
print([[COMPRANDO RUNAs...]])
Walker.Stop()
wait(800,1500)
Self.SayToNpc({"Hi", "Trade"}, 80)
wait(800,1740)
Self.ShopBuyItemsUpTo(RunaID, QuantidadeRuna)
wait(2000,3000)
Walker.Start()


-- COMPRA OS POTS QUE ESTA DEFINIDO LA EM CIMA.
elseif (labelName == "ComprarPots") then
print([[COMPRANDO POTs...]])
Walker.Stop()
wait(500,1000)
Self.SayToNpc({"Hi", "Vial", "yes", "trade"}, 80)
wait(500,1000)
Self.ShopBuyItemsUpTo(ManaPotID, QuantidadeMP)
wait(500,1000)
Self.ShopBuyItemsUpTo(HealthPotID, QuantidadeHP)
wait(500,1000)
Walker.Start()

elseif (labelName == "Trade") then
setBotEnabled(false)
print([[Vendendo Loot]])
Self.SayToNpc({"Hi", "Trade"}, 65)
wait(1000,2000)
local ITEMS_TO_SELL = {"Moohtant Cudgel", "Execowtioner Axe", "Alloy Legs", "Rubber Cap", "Heat Core", "Metal Bat", "Mino Lance", "Glooth Cape", "Mooh'tah Plate", "Gearwheel Chain", "Mino Shield", "Cowtana", "Glooth Whip", "Glooth Amulet", "Glooth Blade", "Metal Spats", "Glooth Blade", "Glooth Club", "Glooth Axe", "Small Emerald", "Small Topaz"}
for _, ITEM in ipairs(ITEMS_TO_SELL) do
Self.ShopSellAllItems(ITEM)
wait(500, 1000)
Walker.Start()
end

-- COMPRA OS FLEXAS QUE ESTA DEFINIDO LA EM CIMA.
elseif (labelName == "ComprarFlexas") then
print([[COMPRANDO FLEXAS..]])
Walker.Stop()
wait(500,1000)
Self.SayToNpc({"Hi", "Trade"}, 80)
wait(500,1000)
Self.ShopBuyItemsUpTo(IDMunicao, QuantidadeMunicao)
wait(500,1000)
Self.ShopBuyItemsUpTo(IDMunicao, QuantidadeMunicao)
wait(500,1000)
Walker.Start()

end
end


function Self.DepositItems2(DPBox, ...)
if (#arg > 0) then setBotEnabled(false) end
local depositInfo = {}

function makeDepositInfo(input)
local ret = {}
for i = 1, #input do
local data = input[i]
local spot = 0
local id = 0
if (type(data) == 'table') then
spot = data[2]
id = Item.GetItemIDFromDualInput(data[1])
else
spot = 0
id = Item.GetItemIDFromDualInput(data)
end

if (not ret[spot]) then
ret[spot] = {}
ret[spot].realIndex = -1
ret[spot].items = {}
end
table.insert(ret[spot].items, id)
end
return ret
end

if (#arg > 0) then
depositInfo = makeDepositInfo(arg)
else
local _input = getDepositorList()
local _realInput = {}
for i = 1, #_input, 2 do
local tempInput = {}
tempInput[1] = _input[i]
tempInput[2] = _input[i+1]
table.insert(_realInput, tempInput)
end
depositInfo = makeDepositInfo(_realInput)
end


local indexes = Container.GetAll() -- list of containers open before we start depositing
local depot = Self.OpenDepot()
local badIndexes = #indexes == 0
if (badIndexes or not depot) then
if (badIndexes) then
print("XenoBot: Unable to find open backpacks to deposit from.")
else
print("XenoBot: Depositor failed to open depot.")
end
if (#arg > 0) then setBotEnabled(true) end
return false
end

depot:Minimize()

for i = 0, depot:ItemCount()-1 do
if (depot:GetItemData(i).id == 22796 + DPBox) then
depot:UseItem(i, true) wait(Self.Ping() * 2, Self.Ping() * 3)
end
end

for spot, data in pairs(depositInfo) do -- loop to open all the needed backpacks
local currentSpot = 0
for i = 0, depot:ItemCount() - 1 do -- search all items in the depot
if (Item.isContainer(depot:GetItemData(i).id)) then -- only consider containers
if (currentSpot == spot) then -- should we open this?
data.realIndex = Container.GetFreeSlot()
while (depot:UseItem(spot) ~= 1) do
wait(100)
end
wait(Self.Ping() + 300)
Container.Minimize(data.realIndex)
end
currentSpot = currentSpot + 1 -- increment
end
end
end
local tempDepositInfo = {} -- warn about and get rid of all depot backpacks which cant be opened
for spot, data in pairs(depositInfo) do
if (data.realIndex ~= -1) then
tempDepositInfo[spot] = data
else
print("XenoBot: Depositor is missing a container in depot slot #" .. spot .. ". Please place cascading containers at the required slot in your depot.")
end
end
depositInfo = tempDepositInfo
function depositItem(depositInfo, contFrom, spot) --when this returns true, we skip the item because we cant deposit it
local currentItem = contFrom:GetItemData(spot)
for _, data in pairs(depositInfo) do -- loop through all of our deposit items
if (table.contains(data.items, currentItem.id)) then -- should we deposit this specific one? try
local depositBp = Container.New(data.realIndex)
if (not depositBp:isOpen()) then -- dest container not open, skip this item
return true
end
if (depositBp:ItemCount() < depositBp:ItemCapacity()) then -- if the backpack isn't full, let's use the final slot
contFrom:MoveItemToContainer(spot, data.realIndex, depositBp:ItemCapacity() - 1)
return false
elseif (depositBp:ID() >= 22797 and depositBp:ID() <= 22813) then
contFrom:MoveItemToContainer(spot, data.realIndex, math.random(0, 3))
return false
else -- its full, lets either open the next one or find a good spot
local toSpot = -1 -- fine the best place to put it if we can still fit it
for sp = 0, depositBp:ItemCount() - 1 do
local spData = depositBp:GetItemData(sp)
if (spData.id == currentItem.id and spData.count ~= 100) then
toSpot = sp
end
end
if (not Item.isStackable(currentItem.id) or toSpot == -1) then -- no room for this, open a new container
if (not Item.isContainer(depositBp:GetItemData(depositBp:I temCapacity() - 1).id)) then -- cant open this container, continue to the next item
if (not data.warned) then
data.warned = true
print("XenoBot: Depositor is unable to find room in deposit container #" .. data.realIndex .. ".")
end
return true
end
depositBp:UseItem(depositBp:ItemCapacity() - 1, true)
return false
else -- there's at least some room, lets fill it up
contFrom:MoveItemToContainer(spot, data.realIndex, toSpot)
return false
end
end
end
end
return true
end
function depositItems(depositInfo, indexes)
local containers = {}
for _, index in ipairs(indexes) do -- actually deposit now
local container = Container.New(index)
if (container:isOpen()) then
local checkSpot = 0
while (checkSpot < container:ItemCount()) do -- loop until no more items to deposit
if (depositItem(depositInfo, container, checkSpot)) then
checkSpot = checkSpot + 1 -- if we cant deposit this, skip it
else
if (containers[index] == nil) then containers[index] = 0 end
containers[index] = containers[index] + 1
wait(300, 700)
end
end
end
end
return containers
end
-- deposit items, cascading into new backpacks
local cascadedBps = {}
while (true) do
local cascades = depositItems(depositInfo, indexes)
wait(Self.Ping() + 200)

local opened = false
for index, count in pairs(cascades) do
if (count > 0) then
local cont = Container.New(index)
local lastItem = cont:GetItemData(cont:ItemCount() - 1)
if (Item.isContainer(lastItem.id)) then
if (cascadedBps[index] == nil) then cascadedBps[index] = 0 end
repeat
wait(Self.Ping() + 700)
until (cont:UseItem(cont:ItemCount() - 1, true) ~= 0)
wait(Self.Ping() + 700)
cascadedBps[index] = cascadedBps[index] + 1
opened = true
end
end
end

if (opened == false) then break end
end
-- go back to parent backpacks
for index, times in pairs(cascadedBps) do
for i = 1, times do
Container.GoBack(index)
wait(300, 700)
end
end
wait(800, 1300)
-- close everything
depot:Close()
wait(300, 600)
for spot, data in pairs(depositInfo) do
Container.New(data.realIndex):Close()
wait(200, 400)
end
wait(1500)
delayWalker(2500)
if (#arg > 0) then setBotEnabled(true) end
return true
end