Log in

View Full Version : Sorcerer I can't make it error free:/ who can help me?



stp38
08-28-2012, 10:00 PM
Lua script=

-----------------------setting------------------------------------------------------------

maxMana = 80
manaId = 238
leaveMana = 20 --Number of mana potion you want to leave your hunt
------------------------------------------------------------------------------------
dofile("Forgee.lua")
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
function onWalkerSelectLabel(labelName)

if (labelName == "Withdrawmoney") then
setWalkerEnabled(false)
delayWalker(5000)
Self.SayToNpc({"hi","deposit all","yes"}, 65)
sleep(math.random(700, 1400))
delayWalker(2000)
sleep(math.random(700, 1400))
Self.WithdrawMoney((manaPrice*(maxMana-Self.ItemCount(manaId))))
Self.SayToNpc({"yes"})
setWalkerEnabled(true)
end
end
dofile("Forgee.lua")
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
function onWalkerSelectLabel(labelName)

if (labelName == "check") then
if ((Self.ItemCount(manaId) < leaveMana)) or (Self.Cap() < MinCap) then
gotoLabel("Withdrawmoney")
else
gotoLabel("hunt")
end
end
dofile("Forgee.lua")
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
function onWalkerSelectLabel(labelName)

if (labelName == "check1") then
if ((Self.ItemCount(manaId) < leaveMana)) or (Self.Cap() < MinCap) then
gotoLabel("exit")
else
gotoLabel("hunt")
end
end
end
dofile("Forgee.lua")
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
function onWalkerSelectLabel(labelName)

if (labelName == "Resetbp") then
resetBackpacks()
end
end
end
elseif (labelName == "BuyPotions") then
setWalkerEnabled(false)
delayWalker(10000) --Stops walker so that the character doesn't move away from the NPC.
Self.SayToNpc("hi")
sleep(math.random(800, 1700)) --Sleep between everything the character says to avoid suspicion.
Self.SayToNpc({"Hi", "flasks", "yes", "yes", "yes", "Trade"}, 65)
sleep(math.random(800, 1700)) --Sleep between everything the character says to avoid suspicion.
Self.SayToNpc("trade")
sleep(math.random(2000, 2400)) --Sleep between everything the character says to avoid suspicion.
buyitems(ManaPotID, (WantedMPS-Self.ItemCount(ManaPotID)))
sleep(math.random(800, 1700))
setWalkerEnabled(true)
end
end
function buyitems(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
end

stp38
08-28-2012, 10:01 PM
reserved

Kingdom
08-29-2012, 12:13 AM
I fixed it for you (short)




-----------------------setting------------------------------------------------------------

Maxmana = 80
ManaID = 238
Manaprice = 80
Leavemana = 20 --Number of mana potion you want to leave your hunt
MinCap = 30

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

registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
function onWalkerSelectLabel(labelName)
if (labelName == "Withdrawmoney") then
setWalkerEnabled(false)
Self.SayToNpc({"hi","deposit all","yes"}, 65)
wait(900, 1200)
Self.WithdrawMoney((Manaprice*(Maxmana-Self.ItemCount(ManaID))))
wait(900, 1200)
Self.SayToNpc({"yes"})
setWalkerEnabled(true)
elseif (labelName == "Check") then
delayWalker(1000)
if (Self.ItemCount(ManaID) <= Leavemana) or (Self.Cap() < MinCap) then
gotoLabel("Withdrawmoney")
else
gotoLabel("Hunt")
end
elseif (labelName == "Check1") then
if (Self.ItemCount(ManaID) <= Leavemana) or (Self.Cap() < MinCap) then
gotoLabel("Exit")
else
gotoLabel("Hunt")
end
elseif (labelName == "Resetbp") then
delayWalker(8000)
resetBackpacks()
delayWalker(1800)
elseif (labelName == "BuyPotions") then
setWalkerEnabled(false)
wait(900, 1200)
Self.SayToNpc({"Hi", "flasks", "yes", "yes", "yes", "Trade"}, 65)
wait(1200, 2000)
Self.ShopBuyItem(ManaID, Maxmana-Self.ItemCount(ManaID))
wait(900, 1200)
setWalkerEnabled(true)
end
end

function openBackpacks(...)
local displayName = "OpenBackpacks"
local backpacks = {...}
Self.UseItem(Self.Backpack().id) -- Open main backpack.
print("Opening main backpack.")
wait(500, 900)
main = Container.GetFirst()
if #backpacks > 0 then
for i = 1, #backpacks do
if type(backpacks[i]) == 'table' then -- Is parent container specified?
tmpBP = Container.GetByName(backpacks[i][1])
for spot = 0, tmpBP:ItemCount() do
item = tmpBP:GetItemData(spot)
if item.id == backpacks[i][2] then
tmpBP:UseItem(spot)
print("Opening backpack from list. " .. backpacks[i][1] .. ", " .. backpacks[i][2])
wait(500, 800)
end
end
else -- If there is no parent specified we will use the main bp.
for spot = 0, main:ItemCount() do
item = main:GetItemData(spot)
if item.id == backpacks[i] then
main:UseItem(spot)
print("Opening backpack from list, " .. backpacks[i])
wait(500, 800)
end
end
end
end
local indexes = Container.GetIndexes()
for i = 1, #indexes do
if type(backpacks[i]) == "table" then
if Container.GetFromIndex(indexes[i]):ID() ~= backpacks[i][1] then
return false
end
else
if Container.GetFromIndex(indexes[i]):ID() ~= backpacks[i] then
return false
end
end
end
return true
end
end

function getOpenBackpacks()
local indexes = Container.GetIndexes() -- Find index for all open backpacks
local open = {} -- Create a place to store our open backpacks
for i = 1, #indexes do -- Search all open backpacks
tmpBP = Container.GetFromIndex(indexes[i])
table.insert(open, tmpBP:ID()) -- Store this backpack
end
return open -- Return found backpacks
end

function resetBackpacks(tries)
setWalkerEnabled(false)
local open = getOpenBackpacks() -- Save a list of open backpacks
local tries = 3 -- Give the script 3 tries to achieve a successful reset.
repeat
closeBackpacks() -- Close all backpacks
wait(600, 800) -- wait a little bit
local reopen = openBackpacks(unpack(open)) -- I store the return from openBackpacks, true if successfull, false otherwise
if tries == 0 then -- Check how many tries function has left
print("BackpackReset failed!") -- Tell the user reset has failed
return false
end
tries = tries - 1 -- One try has been spent
until reopen -- If reopen is true it means all backpacks were opened successfully and function is done
print("BackpackReset was successfull!") -- Tell user reset was successful
setWalkerEnabled(true)
return true
end

Self.ReachNpc = function(name, tries)
local npc = Creature.GetByName(name)
if (npc:DistanceFromSelf() > 3) then
tries = tries or 15
repeat
local nposi = npc:Position()
Self.UseItemFromGround(nposi.x, nposi.y, nposi.z)
wait(1500)
tries = tries - 1
until (npc:DistanceFromSelf() <= 3) or (tries == 0)
end
end

stp38
08-29-2012, 11:55 AM
Ty gonna try it soon