PunktG
10-24-2012, 06:40 AM
Hello
i got some problem with this lua file
all is working but from time to time bot ignore labels
it doesn't happen a lot but i cant put bot full afk :(
---------- Settings ---------
MPotID = 268 --- mana potion ID
MinMPots = 65 ---- if less then script will exit spawn
MPots = 350 ----- amount to refill
MPotprice = 60 ---- price of 1 single mana pot
MinCap = 100 ---- if less then script will exit spawn
-- Set the item ID's of the items you want to deposit. if you add a new item with a new bracket, --
-- make sure to add " , " Like this {3333, 4}, OBS!! Do not add that after the last item!--
BP1 = {5949} -- Set the backpacks you use. Do not include main backpack!!
BP2 = {2869} -- OBS! YOU MAY NOT HAVE 2 BACKPACKS OF THE SAME COLOUR. (MAIN BACKPACK CAN'T HAVE THE SAME COLOUR AS ANY --OTHER BACKPACK)
BP3 = {5801}
----------------------------- ITEM ID THAT MAY BE REQUIRED! -----------------------------
-- [14674] anniversary backpack
-- [3253] backpack of holding
-- [5949] beach backpack
-- [2869] blue backpack
-- [8860] brocade backpack
-- [2854] brown backpack
-- [14249] buggy backpack
-- [2872] camouflage backpack
-- [9605] crown backpack
-- [9601] demon backpack
-- [14248] deepling backpack
-- [10326] dragon backpack
-- [10324] expedition backpack
-- [7342] fur backpack
-- [2871] golden backpack
-- [2865] green backpack
-- [2870] grey backpack
-- [10202] heart backpack
-- [5801] jewelled backpack
-- [10327] minotaur backpack
-- [9604] moon backpack
-- [9602] orange backpack
-- [5926] pirate backpack
-- [2868] purple backpack
-- [2867] red backpack
-- [10346] santa backpack
-- [2866] yellow backpack
-- [266]Health Potion - 45gp
-- [236]Strong Health Potion - 80gp
-- [239]Great Health Potion - 190gp
-- [7643]Ultimate Health Potion - 310gp
-- [268]Mana Potion - 50 gp
-- [237]Strong Mana Potion - 80gp
-- [238]Great Mana Potion - 120gp
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
------------------ DO NOT TOUCH THIS CODE --------------------------
-------------------- IF YOU DO NOT KNOW ----------------------------
-------------------- WHAT YOU ARE DOING ----------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
dofile("Forgee.lua")
function onWalkerSelectLabel(labelName)
if (labelName == "checker") then
delayWalker(1000)
setWalkerEnabled(false)
if (Self.ItemCount(MPotID) <= MinMPots) or (Self.Cap() < MinCap)then
setWalkerEnabled(true)
gotoLabel("leaveCave")
else
setWalkerEnabled(true)
gotoLabel("keepHunting")
end
elseif (labelName == "bank") then
setWalkerEnabled(false)
NpcConv("hi","deposit all","yes","balance")
wait(900, 1200)
Self.WithdrawMoney((MPotprice*(MPots-Self.ItemCount(MPotID))))
wait(900, 1200)
Self.SayToNpc("yes")
wait(1500,1900)
setWalkerEnabled(true)
elseif (labelName == "deposit") then
setWalkerEnabled(false)
local dprandomise = (math.random(1,2))
Self.DepositItems({10279, 0}, {3032, 0}, {3313, 1}, {3556, 1}, {281, 0}, {282, 0}, {10328, 0})
wait(1500,1900)
setWalkerEnabled(true)
elseif (labelName == "potions") then
setWalkerEnabled(false)
wait(900, 1200)
Self.SayToNpc({"Hi", "flasks", "yes", "yes", "yes", "Trade"}, 65)
wait(900, 1200)
buyAlotOfItemsBecauseItsSuchAGodDamnBigDeal(MPotID , (MPots-Self.ItemCount(MPotID)))
wait(200, 500)
setWalkerEnabled(true)
elseif (labelName == "backpacks") then
bpOpen()
delayWalker(5000)
elseif(labelName == "beforePortal1")then
wait(3000)
delayWalker(2000)
gotoLabel("afterPortal1")
elseif(labelName == "beforePortal2")then
wait(2000)
delayWalker(1000)
gotoLabel("afterPortal2")
elseif(labelName == "beforePortal3")then
wait(2000)
delayWalker(1000)
gotoLabel("afterPortal3")
elseif(labelName == "beforePortal4")then
wait(2000)
delayWalker(1000)
gotoLabel("afterPortal4")
elseif (labelName == "checkpot") and (Self.ItemCount(MPotID) < (MPots-20)) then
gotoLabel("beforepot")
elseif(labelName == "pd1")then
wait(1000)
delayWalker(2000)
gotoLabel("pd2")
elseif(labelName == "s1")then
wait(1000)
gotoLabel("s2")
elseif(labelName == "s21")then
wait(4000)
gotoLabel("s3")
elseif(labelName == "s4")then
wait(1000)
gotoLabel("s41")
elseif(labelName == "s5")then
wait(5000)
gotoLabel("s51")
elseif(labelName == "s6")then
wait(5000)
gotoLabel("s61")
elseif(labelName == "s7")then
wait(5000)
gotoLabel("s71")
elseif (labelName == "checkbank") then
if (Self.DistanceFromPosition(33013, 31492, 10) ~= 0) then
gotoLabel("beforebank")
end
elseif (labelName == "checkbank2") then
if (Self.DistanceFromPosition(33013, 31484, 10) ~= 0) then
gotoLabel("leavebank")
end
elseif (labelName == "checkbank3") then
if (Self.DistanceFromPosition(33013, 31540, 10) ~= 0) then
gotoLabel("leavepot")
end
elseif (labelName == "doorEast") then
delayWalker(2000)
if tostring(Map.IsTileWalkable(Self.Position().x + 1, Self.Position().y, Self.Position().z)) == "false" then
Self.OpenDoor(Self.Position().x + 1, Self.Position().y, Self.Position().z)
end
elseif (labelName == "doorWest") then
delayWalker(2000)
if tostring(Map.IsTileWalkable(Self.Position().x - 1, Self.Position().y, Self.Position().z)) == "false" then
Self.OpenDoor(Self.Position().x - 1, Self.Position().y, Self.Position().z)
end
elseif (labelName == "doorSouth") then
delayWalker(2000)
if tostring(Map.IsTileWalkable(Self.Position().x, Self.Position().y + 1, Self.Position().z)) == "false" then
Self.OpenDoor(Self.Position().x, Self.Position().y + 1, Self.Position().z)
end
elseif (labelName == "doorNorth") then
delayWalker(2000)
if tostring(Map.IsTileWalkable(Self.Position().x, Self.Position().y - 1, Self.Position().z)) == "false" then
Self.OpenDoor(Self.Position().x, Self.Position().y - 1, Self.Position().z)
end
elseif (labelName == "exaniUp") then
setWalkerEnabled(false)
wait(500)
Self.Say("exani hur up")
sleep(math.random(700, 1400))
setWalkerEnabled(true)
elseif (labelName == "exaniDown") then
setWalkerEnabled(false)
wait(500)
Self.Say("exani hur down")
sleep(math.random(700, 1400))
setWalkerEnabled(true)
elseif (labelName == "check1") then
if (Self.DistanceFromPosition(32994, 31551, 4) ~= 0) then
gotoLabel("doorNorth")
end
elseif (labelName == "check2") then
if (Self.DistanceFromPosition(33013, 31554, 4) ~= 0) then
gotoLabel("go2")
end
elseif (labelName == "check3") then
if (Self.DistanceFromPosition(33031, 31547, 6) ~= 0) then
gotoLabel("go3")
end
elseif (labelName == "check4") then
if (Self.DistanceFromPosition(33023, 31549, 5) ~= 0) then
gotoLabel("go4")
end
elseif (labelName == "check5") then
if (Self.DistanceFromPosition(33007, 31557, 5) ~= 0) then
gotoLabel("go5")
end
elseif (labelName == "check6") then
if (Self.DistanceFromPosition(33060, 31528, 10) ~= 0) then
gotoLabel("go6")
end
elseif (labelName == "check7") then
if (Self.DistanceFromPosition(33056, 31531, 10) ~= 0) then
gotoLabel("go7")
end
elseif (labelName == "leverEast") then
setWalkerEnabled(false)
wait(500)
Self.UseLever(Self.Position().x + 1, Self.Position().y, Self.Position().z, 2772)
setWalkerEnabled(true)
end
end
------------------------------ FUNCTION ----------------------------------
function buyAlotOfItemsBecauseItsSuchAGodDamnBigDeal(item, count)
count = tonumber(count) or 1
repeat
local amnt = math.min(count, 100)
if(Self.ShopBuyItem(item, amnt) == 0)then
return printf("ERROR: failed to buy item: %s", tostring(item))
end
wait(200,500)
count = (count - amnt)
until count <= 0
end
function bpOpen()
setWalkerEnabled(false)
closeBackpacks()
wait(500)
openBackpacks(BP1, BP2, BP3) -- HERE YOU CAN ADD MORE BACKPACKS
setWalkerEnabled(true)
end
function openBackpacks(...) -- openBackpacks(id1, id2, id3)
Self.UseItem(Self.Backpack().id)
wait(1900, 3700)
for _, input in ipairs(arg) do
local Bp = Container.GetFromIndex(input[2])
for spot = 0, Bp:ItemCount() do
local item = Bp:GetItemData(spot)
if(item.id == input[1]) then
Bp:UseItem(spot)
break
end
end
wait(900, 1700)
end
end
function NpcConv(...)
for _, str in ipairs(arg) do
wait((tostring(str):len() / 125) * 60000 * math.random(1.1, 1.8))
Self.SayToNpc(str)
end
end
i got some problem with this lua file
all is working but from time to time bot ignore labels
it doesn't happen a lot but i cant put bot full afk :(
---------- Settings ---------
MPotID = 268 --- mana potion ID
MinMPots = 65 ---- if less then script will exit spawn
MPots = 350 ----- amount to refill
MPotprice = 60 ---- price of 1 single mana pot
MinCap = 100 ---- if less then script will exit spawn
-- Set the item ID's of the items you want to deposit. if you add a new item with a new bracket, --
-- make sure to add " , " Like this {3333, 4}, OBS!! Do not add that after the last item!--
BP1 = {5949} -- Set the backpacks you use. Do not include main backpack!!
BP2 = {2869} -- OBS! YOU MAY NOT HAVE 2 BACKPACKS OF THE SAME COLOUR. (MAIN BACKPACK CAN'T HAVE THE SAME COLOUR AS ANY --OTHER BACKPACK)
BP3 = {5801}
----------------------------- ITEM ID THAT MAY BE REQUIRED! -----------------------------
-- [14674] anniversary backpack
-- [3253] backpack of holding
-- [5949] beach backpack
-- [2869] blue backpack
-- [8860] brocade backpack
-- [2854] brown backpack
-- [14249] buggy backpack
-- [2872] camouflage backpack
-- [9605] crown backpack
-- [9601] demon backpack
-- [14248] deepling backpack
-- [10326] dragon backpack
-- [10324] expedition backpack
-- [7342] fur backpack
-- [2871] golden backpack
-- [2865] green backpack
-- [2870] grey backpack
-- [10202] heart backpack
-- [5801] jewelled backpack
-- [10327] minotaur backpack
-- [9604] moon backpack
-- [9602] orange backpack
-- [5926] pirate backpack
-- [2868] purple backpack
-- [2867] red backpack
-- [10346] santa backpack
-- [2866] yellow backpack
-- [266]Health Potion - 45gp
-- [236]Strong Health Potion - 80gp
-- [239]Great Health Potion - 190gp
-- [7643]Ultimate Health Potion - 310gp
-- [268]Mana Potion - 50 gp
-- [237]Strong Mana Potion - 80gp
-- [238]Great Mana Potion - 120gp
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
------------------ DO NOT TOUCH THIS CODE --------------------------
-------------------- IF YOU DO NOT KNOW ----------------------------
-------------------- WHAT YOU ARE DOING ----------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
dofile("Forgee.lua")
function onWalkerSelectLabel(labelName)
if (labelName == "checker") then
delayWalker(1000)
setWalkerEnabled(false)
if (Self.ItemCount(MPotID) <= MinMPots) or (Self.Cap() < MinCap)then
setWalkerEnabled(true)
gotoLabel("leaveCave")
else
setWalkerEnabled(true)
gotoLabel("keepHunting")
end
elseif (labelName == "bank") then
setWalkerEnabled(false)
NpcConv("hi","deposit all","yes","balance")
wait(900, 1200)
Self.WithdrawMoney((MPotprice*(MPots-Self.ItemCount(MPotID))))
wait(900, 1200)
Self.SayToNpc("yes")
wait(1500,1900)
setWalkerEnabled(true)
elseif (labelName == "deposit") then
setWalkerEnabled(false)
local dprandomise = (math.random(1,2))
Self.DepositItems({10279, 0}, {3032, 0}, {3313, 1}, {3556, 1}, {281, 0}, {282, 0}, {10328, 0})
wait(1500,1900)
setWalkerEnabled(true)
elseif (labelName == "potions") then
setWalkerEnabled(false)
wait(900, 1200)
Self.SayToNpc({"Hi", "flasks", "yes", "yes", "yes", "Trade"}, 65)
wait(900, 1200)
buyAlotOfItemsBecauseItsSuchAGodDamnBigDeal(MPotID , (MPots-Self.ItemCount(MPotID)))
wait(200, 500)
setWalkerEnabled(true)
elseif (labelName == "backpacks") then
bpOpen()
delayWalker(5000)
elseif(labelName == "beforePortal1")then
wait(3000)
delayWalker(2000)
gotoLabel("afterPortal1")
elseif(labelName == "beforePortal2")then
wait(2000)
delayWalker(1000)
gotoLabel("afterPortal2")
elseif(labelName == "beforePortal3")then
wait(2000)
delayWalker(1000)
gotoLabel("afterPortal3")
elseif(labelName == "beforePortal4")then
wait(2000)
delayWalker(1000)
gotoLabel("afterPortal4")
elseif (labelName == "checkpot") and (Self.ItemCount(MPotID) < (MPots-20)) then
gotoLabel("beforepot")
elseif(labelName == "pd1")then
wait(1000)
delayWalker(2000)
gotoLabel("pd2")
elseif(labelName == "s1")then
wait(1000)
gotoLabel("s2")
elseif(labelName == "s21")then
wait(4000)
gotoLabel("s3")
elseif(labelName == "s4")then
wait(1000)
gotoLabel("s41")
elseif(labelName == "s5")then
wait(5000)
gotoLabel("s51")
elseif(labelName == "s6")then
wait(5000)
gotoLabel("s61")
elseif(labelName == "s7")then
wait(5000)
gotoLabel("s71")
elseif (labelName == "checkbank") then
if (Self.DistanceFromPosition(33013, 31492, 10) ~= 0) then
gotoLabel("beforebank")
end
elseif (labelName == "checkbank2") then
if (Self.DistanceFromPosition(33013, 31484, 10) ~= 0) then
gotoLabel("leavebank")
end
elseif (labelName == "checkbank3") then
if (Self.DistanceFromPosition(33013, 31540, 10) ~= 0) then
gotoLabel("leavepot")
end
elseif (labelName == "doorEast") then
delayWalker(2000)
if tostring(Map.IsTileWalkable(Self.Position().x + 1, Self.Position().y, Self.Position().z)) == "false" then
Self.OpenDoor(Self.Position().x + 1, Self.Position().y, Self.Position().z)
end
elseif (labelName == "doorWest") then
delayWalker(2000)
if tostring(Map.IsTileWalkable(Self.Position().x - 1, Self.Position().y, Self.Position().z)) == "false" then
Self.OpenDoor(Self.Position().x - 1, Self.Position().y, Self.Position().z)
end
elseif (labelName == "doorSouth") then
delayWalker(2000)
if tostring(Map.IsTileWalkable(Self.Position().x, Self.Position().y + 1, Self.Position().z)) == "false" then
Self.OpenDoor(Self.Position().x, Self.Position().y + 1, Self.Position().z)
end
elseif (labelName == "doorNorth") then
delayWalker(2000)
if tostring(Map.IsTileWalkable(Self.Position().x, Self.Position().y - 1, Self.Position().z)) == "false" then
Self.OpenDoor(Self.Position().x, Self.Position().y - 1, Self.Position().z)
end
elseif (labelName == "exaniUp") then
setWalkerEnabled(false)
wait(500)
Self.Say("exani hur up")
sleep(math.random(700, 1400))
setWalkerEnabled(true)
elseif (labelName == "exaniDown") then
setWalkerEnabled(false)
wait(500)
Self.Say("exani hur down")
sleep(math.random(700, 1400))
setWalkerEnabled(true)
elseif (labelName == "check1") then
if (Self.DistanceFromPosition(32994, 31551, 4) ~= 0) then
gotoLabel("doorNorth")
end
elseif (labelName == "check2") then
if (Self.DistanceFromPosition(33013, 31554, 4) ~= 0) then
gotoLabel("go2")
end
elseif (labelName == "check3") then
if (Self.DistanceFromPosition(33031, 31547, 6) ~= 0) then
gotoLabel("go3")
end
elseif (labelName == "check4") then
if (Self.DistanceFromPosition(33023, 31549, 5) ~= 0) then
gotoLabel("go4")
end
elseif (labelName == "check5") then
if (Self.DistanceFromPosition(33007, 31557, 5) ~= 0) then
gotoLabel("go5")
end
elseif (labelName == "check6") then
if (Self.DistanceFromPosition(33060, 31528, 10) ~= 0) then
gotoLabel("go6")
end
elseif (labelName == "check7") then
if (Self.DistanceFromPosition(33056, 31531, 10) ~= 0) then
gotoLabel("go7")
end
elseif (labelName == "leverEast") then
setWalkerEnabled(false)
wait(500)
Self.UseLever(Self.Position().x + 1, Self.Position().y, Self.Position().z, 2772)
setWalkerEnabled(true)
end
end
------------------------------ FUNCTION ----------------------------------
function buyAlotOfItemsBecauseItsSuchAGodDamnBigDeal(item, count)
count = tonumber(count) or 1
repeat
local amnt = math.min(count, 100)
if(Self.ShopBuyItem(item, amnt) == 0)then
return printf("ERROR: failed to buy item: %s", tostring(item))
end
wait(200,500)
count = (count - amnt)
until count <= 0
end
function bpOpen()
setWalkerEnabled(false)
closeBackpacks()
wait(500)
openBackpacks(BP1, BP2, BP3) -- HERE YOU CAN ADD MORE BACKPACKS
setWalkerEnabled(true)
end
function openBackpacks(...) -- openBackpacks(id1, id2, id3)
Self.UseItem(Self.Backpack().id)
wait(1900, 3700)
for _, input in ipairs(arg) do
local Bp = Container.GetFromIndex(input[2])
for spot = 0, Bp:ItemCount() do
local item = Bp:GetItemData(spot)
if(item.id == input[1]) then
Bp:UseItem(spot)
break
end
end
wait(900, 1700)
end
end
function NpcConv(...)
for _, str in ipairs(arg) do
wait((tostring(str):len() / 125) * 60000 * math.random(1.1, 1.8))
Self.SayToNpc(str)
end
end