PDA

View Full Version : Knight ERROR: failed to buy item: 7643



Yamo
02-17-2013, 02:52 PM
i got this error in a script of Wyrms LB (http://forums.xenobot.net/showthread.php?3360-100-AFK-FREE-SCRIPTS-THREAD-BY-Y2Quake&p=33139&viewfull=1#post33139)


This is the .Lua


-------------------------------------------------
----------------Y2Quake--------------------
--------------FULL WYRMS LB------------------
-----------------ELITE KNIGHT-----------------------
-------------------------------------------------
--Settings---------------------------------------
MPotID = 268 --- mana potion ID
MinMPots = 50 ---- if less then script will exit spawn
MPots = 500 ----- amount to refill
MPotprice = 50 ---- price of 1 single mana pot
HPotID = 7643 ---- health potion ID
HPotprice = 310 ---- health potion price
HPots = 80 ---- health potions you want to buy
MinHPots = 20 ---- min of health potions to leave
MinCap = 80 ---- if less then script will exit spawn
secondfloor = true ---- 1 if you want to go second floor aswell// 2 if you just want to hunt +1.
-------------------------------------------------
--END OF SETTINGS--------------------------------



--- DO NOT CHANGE BELOW UNLESS YOU KNOW WHAT YOU'RE DOING ---

registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")

local info = [[
Free script made by:
Y2Quake]]
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
dofile("Forgee.lua")
function onWalkerSelectLabel(labelName)
if (labelName == "check") then
delayWalker(1000)
setWalkerEnabled(false)
if (Self.ItemCount(MPotID) <= MinMPots) or (Self.Cap() < MinCap) or (Self.ItemCount(HPotID) <= MinHPots) then
setWalkerEnabled(true)
gotoLabel("refill")
else
setWalkerEnabled(true)
gotoLabel("checkfloors")
end
elseif (labelName == "KeepHunting") then
print(info)
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(900, 1200)
Self.WithdrawMoney((HPotprice*(HPots-Self.ItemCount(HPotID))))
wait(900, 1200)
Self.SayToNpc("yes")
wait(15000,19000)
setWalkerEnabled(true)
elseif (labelName == "deposit") then
setWalkerEnabled(false)
Self.DepositItems(10281, 816, 8043, 8092, 8045, 9304, 7430, 8027, 7449, 3073, 3415, {9665, 1}, {3028, 1}, {3033, 1})
wait(1500,1900)
setWalkerEnabled(true)
elseif (labelName == "tradepots") then
setWalkerEnabled(false)
wait(900, 1200)
Self.SayToNpc({"Hi", "flasks", "yes", "yes", "yes", "Trade"}, 65)
sleep(math.random(2000, 2400))
buyAlotOfItemsBecauseItsSuchAGodDamnBigDeal(MPotID , (MPots-Self.ItemCount(MPotID)))
sleep(math.random(2000, 2400))
buyAlotOfItemsBecauseItsSuchAGodDamnBigDeal(HPotID , (HPots-Self.ItemCount(HPotID)))
sleep(math.random(2000, 2400))
setWalkerEnabled(true)
elseif (labelName == "resetbackpacks") then
dofile("Forgee.lua")
delayWalker(15000)
resetBackpacks()
elseif (labelName == "checkfloors") then
delayWalker(1000)
if (secondfloor == true) then
gotoLabel("goup")
elseif (secondfloor == false) then
gotoLabel("KeepHunting")
end
elseif (labelName == "check2") then
if (Self.ItemCount(MPotID) <= MinMPots) or (Self.Cap() < MinCap) or (Self.ItemCount(HPotID) <= MinHPots) then
setWalkerEnabled(true)
gotoLabel("refill")
else
setWalkerEnabled(true)
gotoLabel("KeepHunting")
end

end
end

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



how i fix it ?

NeeP
02-17-2013, 05:08 PM
Self.ShopBuyItemsUpTo() instead of buyAlotOfItemsBecause...()