Log in

View Full Version : [Bug] Script Sell Loot



bot05
08-21-2016, 06:22 AM
anyone can fix this error?

XenoScript Error:
Script: [FLAMEX] SETUP BETA v0.3.lua
Line #: 129
Chunk: C:?Users?gustavo?Pictures?DOCUME?1?XenoBot?Scripts ??_FLAME?1.LUA
Error: 'end' expected (to close 'function' at line 76) near 'elseif'
This is an error with user-input and should not be reported as a bug with XenoBot.

Script Here \/
------------ Labels Name -------------
local Check = "verificar" -- Verifica se é necessário voltar pro dp para repotar ou se o cap estiver abaixo do configurado, se estiver tudo normal continuára a hunt
local Stamina = "stamina" -- Pausa o BOT de acordo com os critérios determinados nas configurações abaixo.
local Bank = "withdraw" -- deposita e retira dinhero necessário para repotar
local OpenBP = "Backpacks" -- abre as backpacks configuradas abaixo
local Refill = "BuySupplies" -- compra potions
local AmmoRefill = "BuyAmmo" -- compra munição

------------ BP USE -------------

local SuppliesUse = true -- Ativa a Supplies Backpack
local RareUse = true -- Ativa a Rare Backpack
local StackUse = true -- Ativa a Stack Backpack
local GoldUse = true -- Ativa a Gold Backpack
local AmmoUse = false -- Ativa a Ammo Backpack

----------- BP SETUP ------------
local SuppliesBP = "Blue Backpack" --- BP que irá ficar seus potions
local GoldBP = "Purple Backpack" --- BP que irá ficar os golds
local rareBPBP = "Brocade Backpack" --- BP que irá ficar os RareItens
local StackBP = "Red Backpack" --- BP que irá ficar os itens agrupáveis
local AmmoBP = "Backpack" --- BP onde irá ficar sua munições

------ REFILL SETUP ------
local MinMana = 150 --- Minimo de Mana para sair da hunt
local MaxMana = 400 --- Maximo de Mana para levar para hunt
local IDMana = 268 --- ID Mana Potion
local PriceMana = 50 --- Preço Mana Potion

local MinHealth = 30 --- Minimo de Health para sair da hunt
local MaxHealth = 100 --- Maximo de Health para levar para hunt
local IDHealth = 239 --- ID Health potion
local PriceHealth = 120 --- Preço Health Potion

local MinAmmo = 150 --- Minimo de Munição para sair da hunt
local MaxAmmo = 1800 --- Maximo de munição para ir para hunt
local IDAmmo = 0 --- id da munição que irá usar
local PriceAmmo = 20 --- Preço da munição que irá usar, se não for usar basta deixar 0

------- EXTRA SETTINGS ------
local MinCap = 50 --- Mínimo de Cap para sair da Hunt.
local TimeStop = 35 --- Minimo de Stamina para o bot pausar


--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------

Targeting.Start()
Looter.Start()

registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")

print([[ !! SETUP v0.3!!
-- www.TibiaEasy-cracker.blogspot.com.br --
\\ By FlameX // ]])
wait(5000)

function onWalkerSelectLabel(labelName)

-- Checar na hunt
if (labelName == Check) then
Walker.ConditionalGoto((Self.Cap() <= MinCap) or
(Self.ItemCount(IDAmmo) < MinAmmo) or
(Self.ItemCount(IDMana) < MinMana) or
(Self.ItemCount(IDHealth) < MinHealth), "Leave", "Continue")

-- Depositar e Retirar grana
elseif (labelName == Bank) then
print([[Withdraw Money for Repot]])
local withdrawManas = math.max(MaxMana - Self.ItemCount(IDMana), 0)*PriceMana
local withdrawHealths = math.max(MaxHealth - Self.ItemCount(IDHealth), 0)*PriceHealth
local withdrawAmmo = math.max(MaxAmmo - Self.ItemCount(IDAmmo), 0)*PriceAmmo
local totalmoneyneeded = (withdrawManas + withdrawHealths + withdrawAmmo)
local MATHCEIL = (math.ceil((totalmoneyneeded)))
Walker.Stop()
Self.SayToNpc({"hi", "deposit all", "yes"}, 65)
if (totalmoneyneeded > 0) then
Self.SayToNpc({"withdraw " .. MATHCEIL, "yes", "balance"}, 65)
end
wait(2000)
Walker.Start()

-- Depositar no DP e Checar stamina
elseif (labelName == Stamina) then
Walker.Stop()
wait(1900,2400)
if (Self.Stamina() <= TimeStop * 60) then
Walker.Stop()
print([[Low Stamina Stopping!!!]])

else
Walker.Start()
print([[Normal, continuing!!!]])
end

-- Vender Loots
elseif (labelName == "Robert") then
setBotEnabled(false)
print([[Vendendo Loots...]])
Self.SayToNpc({"Hi", "Trade"}, 65)
wait(1000,2000)
local ITEMS_TO_SELL = {"magic plate armor", "demon shield", "mastermind shield", "demonrage sword", "giant sword", "golden legs"}
for _, ITEM in ipairs(ITEMS_TO_SELL) do
Self.ShopSellAllItems(ITEM)
wait(300, 500)
end
setBotEnabled(true)
end

-- Comprar Supplies
elseif (labelName == Refill) then
Walker.Stop()
print([[Comprando...]])
if (Self.ItemCount(IDMana) < MaxMana) or (Self.ItemCount(IDHealth) < MaxHealth) then
Self.SayToNpc({"hi", "flasks", "yes", "yes", "yes", "yes", "yes", "yes", "trade"}, 65)
wait(2000)
if (Self.ItemCount(IDMana) < MaxMana) then
BuyItems(IDMana, MaxMana)
wait(500)
end
if (Self.ItemCount(IDHealth) < MaxHealth) then
BuyItems(IDHealth, MaxHealth)
wait(500)
end
wait(200, 500)
end
Walker.Start()
elseif (labelName == AmmoRefill) then
Walker.Stop()
print([[Comprando...]])
if (Self.ItemCount(IDAmmo) < MaxAmmo) then
Self.SayToNpc({"hi", "trade"}, 65)
wait(2000)
if (Self.ItemCount(IDAmmo) < MaxAmmo) then
BuyItems(IDAmmo, MaxAmmo)
wait(500)
end
end

-- Resetar Backpack (Colocar sempre depois do bank)
elseif (labelName == OpenBP) then
Walker.Stop()
print([[Reopen Backpacks...]])
wait(1000,2000)
Self.CloseContainers()
wait(2000,3000)
Self.OpenMainBackpack(true):OpenChildren({Item.Get ID(SuppliesBP), SuppliesUse}, {Item.GetID(StackBP), StackUse}, {Item.GetID(rareBP), RareUse}, {Item.GetID(GoldBP), GoldUse}, {Item.GetID(AmmoBP), AmmoUse})
wait(2000,3000)
Walker.Start()


end
end

----------------------- Functions ----------------------
function BuyItems(item, count) -- item = item id, count = how many you want to buy up to
wait(900, 1200)
if (Self.ItemCount(item) < count) then
Self.ShopBuyItem(item, (count-Self.ItemCount(item)))
wait(200, 500)
end
end

Self.ReachDepot = function (tries)
local tries = tries or 3
Walker.Stop()
local DepotIDs = {3497, 3498, 3499, 3500}
local DepotPos = {}
for i = 1, #DepotIDs do
local dps = Map.GetUseItems(DepotIDs[i])
for j = 1, #dps do
table.insert(DepotPos, dps[j])
end
end
local function gotoDepot()
local pos = Self.Position()
print("Depots found: " .. tostring(#DepotPos))
for i = 1, #DepotPos do
location = DepotPos[i]
Self.UseItemFromGround(location.x, location.y, location.z)
wait(1000, 2000)
if Self.DistanceFromPosition(pos.x, pos.y, pos.z) >= 1 then
wait(5000, 6000)
if Self.DistanceFromPosition(location.x, location.y, location.z) == 1 then
Walker.Start()
return true
end
else
print("Something is blocking the path. Trying next depot.")
end
end
return false
end

repeat
reachedDP = gotoDepot()
if reachedDP then
return true
end
tries = tries - 1
sleep(100)
print("Attempt to reach depot was unsuccessfull. " .. tries .. " tries left.")
until tries <= 0

return false
end

Map.GetUseItems = function (id)
if type(id) == "string" then
id = Item.GetID(id)
end
local pos = Self.Position()
local store = {}
for x = -7, 7 do
for y = -5, 5 do
if Map.GetTopUseItem(pos.x + x, pos.y + y, pos.z).id == id then
itemPos = {x = pos.x + x, y = pos.y + y, z = pos.z}
table.insert(store, itemPos)
end
end
end
return store
end