Log in

View Full Version : Need help with Withdrawing!



benjaminheinesen
07-06-2013, 12:44 AM
elseif (labelName == "Bank") then

Walker.Stop()
wait(2000,4000)
Self.Say("hi")
wait(2000,4000)
Self.SayToNpc("deposit all")
wait(2000,4000)
Self.SayToNpc("yes")
wait(2000,4000)
Self.WithdrawMoney((50*(ManaBuy-Self.ItemCount(ManaPots)))+(180*(HPBuy-Self.ItemCount(HPPots)))+1000)
wait(2000,4000)
Self.SayToNpc("yes")
wait(2000,4000)
Walker.Start()



MaxMana is 500
MaxHP is 30

In my bp I have 466ManaPots and 50HealthPots

Why does my bot only withdraw 700gp?

Messed Around
07-06-2013, 01:04 AM
--Variables
manaID = 266
healthID = 268

manaCost = 50
healthCost = 45

MaxMana = 500
MaxHealth = 30

The .lua code:
elseif (labelName == "Bank") then
setWalkerEnabled(false)
local amount = (((MaxMana-Self.ItemCount(manaID)) * manaCost)+((MaxHealth-Self.ItemCount(healthID)) * healthCost))
Self.SayToNpc({'hi','deposit all','yes','withdraw ' .. amount,'yes','balance','bye'},65)
setWalkerEnabled(true)

benjaminheinesen
07-06-2013, 01:54 AM
I can't get it to work with that :p
Doesn't say the Amount because of the .. amount thing

Messed Around
07-06-2013, 01:57 AM
I can't get it to work with that :p
Doesn't say the Amount because of the .. amount thing

Post your whole .lua file here and put it like this..
[xcode=lua]information[/ xcode]

benjaminheinesen
07-06-2013, 02:05 AM
-----------------------------------------------------------------------------------------------------------------------
--- BP Settings ---
local GoldBP = "Brocade Backpack" --- Your gold backpack (use same colors inside)
local LootBP = "Pirate Backpack" --- Your loot backpack


--- Depot Info ---
--- Your #1 BP inside depot will recieve non-stackables.
--- Your #2 BP inside depot will recieve stackables.
--- Your #3 BP inside depot will recieve life rings.
-----------------------------------------------------------------------------------------------------------------------
--- Hunt Settings ---
local CapLeave = 100 --- Leave spawn if cap is below this.
local LeavePots = 50 --- Leave spawn if mana potions is below this.
local ManaBuy = 500 --- Amount of mana pots to bring on hunt.

local manaID = 268 ---
local healthID = 266 ---
local manaCost = 50 ---
local healthCost = 180 ---
local MaxMana = 500 ---
local MaxHP = 30 ---

local HPBuy = 30 --- Leave spawn if HP potions is below this.
local HPLeave = 10 --- Amount of HP pots to bring on hunt.

local HuntTower = false --- Do you want to hunt the tower? (Ice Witch etc) Recommended 90+
-----------------------------------------------------------------------------------------------------------------------
--- Misc ---
local ManaPots = 268 --- ID of your mana pots.
local HPPots = 239 --- ID of your HP pots.
local CashWithdraw = ManaBuy*50 --- Don't change this.
-----------------------------------------------------------------------------------------------------------------------



Targeting.Start()
Looter.Start()
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")

print([[
-----------------------------------
----This script was created by:----
-----------------------------------
--------------ME-------------------
-----------------------------------]])
wait(7000)

function onWalkerSelectLabel(labelName)
if (labelName == "Deposit") then
delayWalker(7000)
setWalkerEnabled(false)
Self.ReachDepot()
Self.DepositItems(
{5911, 1}, --- red piece of cloth
{5913, 1}, --- brown piece of cloth
{7463, 0}, --- mammoth fur cape
{7290, 1}, --- shard
{7462, 0}, --- Ragnir helmet
{7457, 0}, --- fur boots
{3344, 0}, --- beastslayer axe
{7464, 0}, --- mammoth fur shorts
{7449, 0}, --- crystal sword
{3052, 2}, --- life ring
{823, 0}, --- glacier kilt
{7387, 0}, --- diamond sceptre
{3574, 0}, --- mystic turban
{7459, 0}, --- pair of earmuffs
{3067, 0}, --- hailstorm rod
{819, 0}, --- glacier shoes
{237, 1}, --- strong mana potion
{7379, 0} --- brutetamer's staff
)
wait(1000)

if (Self.Stamina() < 960) then
Walker.Stop()
else
Walker.Start()
end

elseif (labelName == "Checker") then
if (Self.Cap() < CapLeave) then
Walker.Goto("LeaveHunt")
print([[Low cap, leaving hunt..]])
elseif (Self.ItemCount(ManaPots) < LeavePots) then
Walker.Goto("LeaveHunt")
print([[Low manapots, leaving hunt..]])
elseif (Self.ItemCount(HPPots) < HPLeave) then
Walker.Goto("LeaveHunt")
print([[Low HPpots, leaving hunt..]])
else
Walker.Goto("StartHunt")
print([[Enough supplies & cap, continue hunt..]])
end


elseif (labelName == "StepWest") then
Walker.Stop()
wait(1000,1500)
Self.Step("west")
wait(1000,1500)
Walker.Start()

elseif (labelName == "StepSouth") then
Walker.Stop()
wait(1000,1500)
Self.Step("south")
wait(1000,1500)
Walker.Start()

elseif (labelName == "StepNorth") then
Walker.Stop()
wait(1000,1500)
Self.Step("north")
wait(1000,1500)
Walker.Start()

elseif (labelName == "StepEast") then
Walker.Stop()
wait(1000,1500)
Self.Step("east")
wait(1000,1500)
Walker.Start()

elseif (labelName == "CheckSupplies") then
Walker.Stop()
wait(2000,5000)
if (Self.ItemCount(ManaPots) < (ManaBuy-1)) then
print([[Supply failed, retrying..]])
Walker.Goto("PotFail")
Walker.Start()
else
Walker.Goto("GoHunt")
Walker.Start()
print([[Supply success, lets hunt!]])
end

elseif (labelName == "Bank") then
setWalkerEnabled(false)
local amount = (((MaxMana-Self.ItemCount(manaID)) * manaCost)+((MaxHealth-Self.ItemCount(healthID)) * healthCost))
Self.SayToNpc({'hi','deposit all','yes','withdraw ' .. amount,'yes','balance','bye'},65)
setWalkerEnabled(true))


elseif (labelName == "Bank1") then

Walker.Stop()
wait(2000,4000)
Self.Say("hi")
wait(2000,4000)
Self.SayToNpc("deposit all")
wait(2000,4000)
Self.SayToNpc("yes")
wait(2000,4000)
Self.WithdrawMoney((50*(ManaBuy-Self.ItemCount(ManaPots)))+(180*(HPBuy-Self.ItemCount(HPPots)))+1000)
wait(2000,4000)
Self.SayToNpc("yes")
wait(2000,4000)
Walker.Start()

elseif (labelName == "BuyPOTS") then
Walker.Stop()
wait(2000,3000)
Self.SayToNpc("hi")
wait(2000,4000)
Self.SayToNpc("vial")
wait(2000,4000)
Self.SayToNpc("yes")
wait(2000,4000)
Self.Speak("trade", SPEAK_NPC)
wait(2000,4000)
Self.ShopBuyItemsUpTo(ManaPots, ManaBuy)
wait(2000,4000)
Self.ShopBuyItemsUpTo(HPPots, HPBuy)
wait(2000,4000)
Walker.Start()



elseif (labelName == "BPReset") then
Walker.Stop()
wait(2000,4000)
Self.CloseContainers()
wait(2000,4000)
Self.OpenMainBackpack(true):OpenChildren({Item.Get ID(GoldBP), true}, {Item.GetID(LootBP), true})
wait(2000,4000)
Walker.Start()

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

-----

benjaminheinesen
07-06-2013, 02:10 AM
Messed Around

Messed Around
07-06-2013, 02:20 AM
benjaminheinesen, Withdraw should work now.

-----------------------------------------------------------------------------------------------------------------------
--- BP Settings ---
local GoldBP = "Brocade Backpack" --- Your gold backpack (use same colors inside)
local LootBP = "Pirate Backpack" --- Your loot backpack
--- Depot Info ---
--- Your #1 BP inside depot will recieve non-stackables.
--- Your #2 BP inside depot will recieve stackables.
--- Your #3 BP inside depot will recieve life rings.
-----------------------------------------------------------------------------------------------------------------------
--- Hunt Settings ---
local CapLeave = 100 --- Leave spawn if cap is below this.
local LeavePots = 50 --- Leave spawn if mana potions is below this.
local ManaBuy = 500 --- Amount of mana pots to bring on hunt.
local manaID = 268 ---
local healthID = 266 ---
local manaCost = 50 ---
local healthCost = 180 ---
local MaxMana = 500 ---
local MaxHealth = 30 ---
local HPBuy = 30 --- Leave spawn if HP potions is below this.
local HPLeave = 10 --- Amount of HP pots to bring on hunt.
local HuntTower = false --- Do you want to hunt the tower? (Ice Witch etc) Recommended 90+
-----------------------------------------------------------------------------------------------------------------------
--- Misc ---
local ManaPots = 268 --- ID of your mana pots.
local HPPots = 239 --- ID of your HP pots.
local CashWithdraw = ManaBuy*50 --- Don't change this.
-----------------------------------------------------------------------------------------------------------------------
Targeting.Start()
Looter.Start()
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
print([[
-----------------------------------
----This script was created by:----
-----------------------------------
--------------ME-------------------
-----------------------------------]])
wait(7000)
function onWalkerSelectLabel(labelName)
if (labelName == "Deposit") then
delayWalker(7000)
setWalkerEnabled(false)
Self.ReachDepot()
Self.DepositItems(
{5911, 1}, --- red piece of cloth
{5913, 1}, --- brown piece of cloth
{7463, 0}, --- mammoth fur cape
{7290, 1}, --- shard
{7462, 0}, --- Ragnir helmet
{7457, 0}, --- fur boots
{3344, 0}, --- beastslayer axe
{7464, 0}, --- mammoth fur shorts
{7449, 0}, --- crystal sword
{3052, 2}, --- life ring
{823, 0}, --- glacier kilt
{7387, 0}, --- diamond sceptre
{3574, 0}, --- mystic turban
{7459, 0}, --- pair of earmuffs
{3067, 0}, --- hailstorm rod
{819, 0}, --- glacier shoes
{237, 1}, --- strong mana potion
{7379, 0} --- brutetamer's staff
)
wait(1000)
if (Self.Stamina() < 960) then
Walker.Stop()
else
Walker.Start()
end
elseif (labelName == "Checker") then
if (Self.Cap() < CapLeave) then
Walker.Goto("LeaveHunt")
print([[Low cap, leaving hunt..]])
elseif (Self.ItemCount(ManaPots) < LeavePots) then
Walker.Goto("LeaveHunt")
print([[Low manapots, leaving hunt..]])
elseif (Self.ItemCount(HPPots) < HPLeave) then
Walker.Goto("LeaveHunt")
print([[Low HPpots, leaving hunt..]])
else
Walker.Goto("StartHunt")
print([[Enough supplies & cap, continue hunt..]])
end
elseif (labelName == "StepWest") then
Walker.Stop()
wait(1000,1500)
Self.Step("west")
wait(1000,1500)
Walker.Start()
elseif (labelName == "StepSouth") then
Walker.Stop()
wait(1000,1500)
Self.Step("south")
wait(1000,1500)
Walker.Start()
elseif (labelName == "StepNorth") then
Walker.Stop()
wait(1000,1500)
Self.Step("north")
wait(1000,1500)
Walker.Start()
elseif (labelName == "StepEast") then
Walker.Stop()
wait(1000,1500)
Self.Step("east")
wait(1000,1500)
Walker.Start()
elseif (labelName == "CheckSupplies") then
Walker.Stop()
wait(2000,5000)
if (Self.ItemCount(ManaPots) < (ManaBuy-1)) then
print([[Supply failed, retrying..]])
Walker.Goto("PotFail")
Walker.Start()
else
Walker.Goto("GoHunt")
Walker.Start()
print([[Supply success, lets hunt!]])
end
elseif (labelName == "Bank") then
setWalkerEnabled(false)
local amount = (((MaxMana-Self.ItemCount(manaID)) * manaCost)+((MaxHealth-Self.ItemCount(healthID)) * healthCost))
Self.SayToNpc({'hi','deposit all','yes','withdraw ' .. amount,'yes','balance','bye'},65)
setWalkerEnabled(true)
elseif (labelName == "Bank1") then
setWalkerEnabled(false)
local amount = (((MaxMana-Self.ItemCount(manaID)) * manaCost)+((MaxHealth-Self.ItemCount(healthID)) * healthCost))
Self.SayToNpc({'hi','deposit all','yes','withdraw ' .. amount,'yes','balance','bye'},65)
setWalkerEnabled(true)
elseif (labelName == "BuyPOTS") then
Walker.Stop()
wait(2000,3000)
Self.SayToNpc("hi")
wait(2000,4000)
Self.SayToNpc("vial")
wait(2000,4000)
Self.SayToNpc("yes")
wait(2000,4000)
Self.Speak("trade", SPEAK_NPC)
wait(2000,4000)
Self.ShopBuyItemsUpTo(ManaPots, ManaBuy)
wait(2000,4000)
Self.ShopBuyItemsUpTo(HPPots, HPBuy)
wait(2000,4000)
Walker.Start()
elseif (labelName == "BPReset") then
Walker.Stop()
wait(2000,4000)
Self.CloseContainers()
wait(2000,4000)
Self.OpenMainBackpack(true):OpenChildren({Item.Get ID(GoldBP), true}, {Item.GetID(LootBP), true})
wait(2000,4000)
Walker.Start()
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

benjaminheinesen
07-06-2013, 02:24 AM
Does not execute :/
Messed Around

Messed Around
07-06-2013, 02:27 AM
benjaminheinesen, edited post. copy/paste it again

Edit: "In my bp I have 466ManaPots and 50HealthPots"
Yet you say MaxHP is 30? Put the spare 20 in depot and your old code will work I think.
You have too many healths so it's not counting correctly.

benjaminheinesen
07-06-2013, 02:30 AM
Messed Around
I think I figured it out, thanks ;)