pedronavila
12-08-2015, 02:16 AM
Hello, I'm triying to do my second full AFK script. (Positive-Global Otserver)
With the first one I hadn't any problem but in this I have that problem:
All work good but when the bot try to buy potions he talk with the npc and open the shop windows but don't buy nothing and follow with the next waypoint.
Script that I'm using:
local MinMana = 50 --- How many mana potions until you leave the hunt.
local MaxMana = 1000 --- How many mana potions you begin the hunt with.
local IDMana = 268 --- ID Mana Potion
local CostMana = 50 --- Price Mana Potion
local MinHealth = 30 --- How many health potions until you leave the hunt.
local MaxHealth = 200 --- How many health potions you begin the hunt with.
local IDHealth = 7643 --- ID Health potion
local CostHealth = 310 --- Price Health Potion
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
function onWalkerSelectLabel(labelName)
if (labelName == "Pots") then
Walker.Stop()
print([[Comprando...]])
if (Self.ItemCount(IDMana) < MaxMana) or (Self.ItemCount(IDHealth) < MaxHealth) then
Self.SayToNpc({"hi","trade", "magic stuff"}, 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()
end
end
function BuyItems(item, count)
wait(900, 1200)
if (Self.ItemCount(item) < count) then
Self.ShopBuyItem(item, (count-Self.ItemCount(item)))
wait(200, 500)
end
end
Earlier I had used this code with my first script and it worked well, so I think that the problem is with the npc.
Anyone can helpme?
Thank you :D and sorry for my fucking bad english xD
ososzayat
12-08-2015, 02:47 AM
first.. you dont have to add "local" before variables except if it's inside a function
i've edited your script (using native xenobot function) 'i deleted the function u had (BuyItems).. hope it works now ;)
MinMana = 50 --- How many mana potions until you leave the hunt.
MaxMana = 1000 --- How many mana potions you begin the hunt with.
IDMana = 268 --- ID Mana Potion
CostMana = 50 --- Price Mana Potion
MinHealth = 30 --- How many health potions until you leave the hunt.
MaxHealth = 200 --- How many health potions you begin the hunt with.
IDHealth = 7643 --- ID Health potion
CostHealth = 310 --- Price Health Potion
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
function onWalkerSelectLabel(labelName)
if (labelName == "Pots") 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
Self.ShopBuyItem(IDMana, (MaxMana-Self.ItemCount(IDMana))
wait(500)
end
if (Self.ItemCount(IDHealth) < MaxHealth) then
Self.ShopBuyItem(IDHealth, (MaxHealth-Self.ItemCount(IDHealth))
wait(500)
end
wait(200, 500)
end
Walker.Start()
end
end
pedronavila
12-08-2015, 03:37 AM
Oh yeah, I know that
Self.SayToNpc({"hi","trade","magic stuff"}, 65)
That's how I got it, I forgot to put in the code, but does not work
pedronavila
12-08-2015, 03:54 AM
first.. you dont have to add "local" before variables except if it's inside a function
i've edited your script (using native xenobot function) 'i deleted the function u had (BuyItems).. hope it works now ;)
MinMana = 50 --- How many mana potions until you leave the hunt.
MaxMana = 1000 --- How many mana potions you begin the hunt with.
IDMana = 268 --- ID Mana Potion
CostMana = 50 --- Price Mana Potion
MinHealth = 30 --- How many health potions until you leave the hunt.
MaxHealth = 200 --- How many health potions you begin the hunt with.
IDHealth = 7643 --- ID Health potion
CostHealth = 310 --- Price Health Potion
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
function onWalkerSelectLabel(labelName)
if (labelName == "Pots") 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
Self.ShopBuyItem(IDMana, (MaxMana-Self.ItemCount(IDMana))
wait(500)
end
if (Self.ItemCount(IDHealth) < MaxHealth) then
Self.ShopBuyItem(IDHealth, (MaxHealth-Self.ItemCount(IDHealth))
wait(500)
end
wait(200, 500)
end
Walker.Start()
end
end
Dont work :/
ososzayat
12-08-2015, 04:09 AM
Dont work :/
Well.. I already made a Script for hive i used it while playing shadowcores\Aurera-global... worked 100% for long time... here is the Lua...
try editing to >> Self.SayToNpc({"hi","trade","magic stuff"}, 65) or whatever npc wants :D
----------- BP SETUP ------------
--[BP 1] Main
--[BP 2] Products
--[BP 3] Loot
--[BP 4] Gems
--[BP 5] Mana
----------- DP SETUP ------------
--[DP 1] Products
--[DP 2] Rares
------------ Settings -----------
minStamina = 16 -- (hours)
-- Mana Potions --
ManasToLeave = 500
WantedManas = 1100
ManaPotID = 268
ManaCost = 50
-- Health Potions --
HPotToLeave = 150
WantedHPots = 250
HPotID = 7643
HPotCost = 310
-- Backpacks --
MainBp = "expedition backpack"
ProductBp = "shopping bag"
LootBp = "orange backpack"
GemsBp = "camouflage backpack"
ManaBp = "fur backpack"
-- Extra --
MinCap = 50
SoftBoots = false
---------------------XX Don't Change Anything Below This XX------------------------
---------------------XX Don't Change Anything Below This XX------------------------
---------------------XX Don't Change Anything Below This XX------------------------
---------------------XX Don't Change Anything Below This XX------------------------
Targeting.Start()
Looter.Start()
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
function onWalkerSelectLabel(labelName)
----------------------- Checkers -----------------------
if (labelName == "CheckHunt") then
if (Self.ItemCount(ManaPotID) <= ManasToLeave) or (Self.Cap() < MinCap) or (Self.ItemCount(HPotID) <= HPotToLeave) then
gotoLabel("Leave")
else
gotoLabel("StartHunt")
end
elseif (labelName == "CheckMana") then
if (Self.ItemCount(ManaPotID) < WantedManas-10) or (Self.ItemCount(HPotID) < WantedHPots-10) then
gotoLabel("NotEnoughMana")
else
gotoLabel("EndMana")
end
elseif (labelName == "EndScript") then
Walker.Stop()
wait(2000)
gotoLabel("StartScript")
Walker.Start()
elseif (labelName == "CheckStamina") then
Walker.Stop()
local condition = Self.Stamina() < minStamina * 60
Walker.ConditionalGoto(condition, "NOSTAMINA", "GoodStamina")
wait(2000,2400)
Walker.Start()
elseif (labelName == "Logout") then
Walker.Stop()
os.exit()
------------------------ Deposite Items ------------------------
elseif (labelName == "Deposite") then
Walker.Stop()
Self.ReachDepot()
Self.DepositItems({14088, 1}, {3554, 1}, {14086, 1}, {14087, 1}, {14089, 1}, {3036, 2}, {9058, 2}, {281, 2}, {282, 2}, {7440, 2}, {3032, 2}, {9057, 2}, {3033, 2}, {3027, 2}, {3030, 2}, {14083, 0}, {14079, 0}, {14225, 0}, {14077, 0}, {14082, 0}, {14078, 0}, {14076, 0}, {14080, 0}, {14081, 0})
wait(1500,1900)
Walker.Start()
----------------------------- Bank -----------------------------
elseif (labelName == "Bank") then
Walker.Stop()
Self.Say("hi")
wait(900, 1200)
Self.SayToNpc("deposite all")
wait(900, 1200)
Self.SayToNpc("yes")
wait(900, 1200)
Self.WithdrawMoney((ManaCost*(WantedManas-Self.ItemCount(ManaPotID))+30000))
wait(900, 1200)
Self.WithdrawMoney((HPotCost*(WantedHPots-Self.ItemCount(HPotID))))
wait(900, 1200)
Self.SayToNpc("yes")
wait(900, 1200)
Self.SayToNpc("balance")
Walker.Start()
------------------------- POTS Refiller --------------------------
elseif (labelName == "ManaNPC") then
Walker.Stop()
Self.SayToNpc({"hi", "trade"}, 65)
wait(900, 1200)
Self.SlowBuyItems(ManaPotID, (WantedManas-Self.ItemCount(ManaPotID)))
wait(900, 1200)
Self.SlowBuyItems(HPotID, (WantedHPots-Self.ItemCount(HPotID)))
wait(900, 1200)
Walker.Start()
--------------------------- Loot Seller ---------------------------
elseif (labelName == "SellLoot") then
Walker.Stop()
Self.SayToNpc({"hi", "trade"}, 65)
wait(900, 1200)
for _, v in ipairs({"carapace shield", "grasshopper legs", "calopteryx cape", "compound eye", "crawler head plating", "dung ball", "hive scythe", "kollos shell", "spidris mandible", "spitter nose", "swarmer antenna"}) do
Self.ShopSellAllItems(v)
Self.ShopSellAllItems(v)
wait(800, 1200)
end
Walker.Start()
------------------------------- Bps -------------------------------
elseif (labelName == "ResetBps") then
Walker.Stop()
Self.CloseContainers()
Self.OpenMainBackpack(true):OpenChildren(
{ProductBp, true},
{LootBp, true},
{GemsBp, true},
{ManaBp, true}
)
Walker.Start()
------------------------ Travelling ----------------------------
elseif (labelName == "ToVenore") then
Walker.Stop()
customFollowNPC("Scrutinon")
wait(1000, 2000)
Self.SayToNpc({"hi", "venore", "yes"}, 90)
wait(1000, 2000)
Walker.Start()
elseif (labelName == "ToGrayIsland") then
Walker.Stop()
customFollowNPC("Captain Fearless")
wait(1000, 2000)
Self.SayToNpc({"hi", "gray island", "yes"}, 90)
wait(1000, 2000)
Walker.Start()
--------------------------- Softs ------------------------------
elseif (labelName == "EndSoftBoots") then
Walker.Stop()
gotoLabel("SkipSofts")
Walker.Start()
elseif (labelName == "SoftBootsNPC") then
Walker.Stop()
Self.SayToNpc({"hi", "soft boots", "yes"}, 90)
Self.SayToNpc({"hi", "soft boots", "yes"}, 90)
Self.SayToNpc({"hi", "soft boots", "yes"}, 90)
Self.SayToNpc({"hi", "soft boots", "yes"}, 90)
Walker.Start()
elseif (labelName == "CheckSofts") then
Walker.Stop()
if ((Self.ItemCount(3549) == 0)) and ((Self.ItemCount(6529) == 0)) and ((SoftBoots == true)) then
gotoLabel("StartSoftBoots")
Walker.Start()
else
gotoLabel("SkipSofts")
Walker.Start()
end
elseif (labelName == "StartHunt") then
delayWalker(1500)
Self.Equip(6529, "feet")
elseif (labelName == "GoHunt") then
delayWalker(1500)
Self.Equip(3079, "feet")
elseif (labelName == "Leave") then
delayWalker(1500)
Self.Equip(3079, "feet")
end
end
--------------------------- Functions ---------------------------
function Self.SlowBuyItems(item, count)
local func = (type(item) == "string") and shopBuyItemByName or shopBuyItemByID
count = tonumber(count) or 1
repeat
local amnt = math.min(count, 100)
if (func(item, amnt) == 0) then
return 0, amnt
end
wait(1500)
count = (count - amnt)
until
count <= 0
return 1, 0
end
function resetBackpacks()
Self.CloseContainers()
Self.OpenMainBackpack(true):OpenChildren(
{ProductBp, true},
{LootBp, true},
{GemsBp, true},
{ManaBp, true}
)
end
Module.New('BpReset', function(BackPacks)
local numBPs = #Container.GetAll()
if numBPs < 5 then
Looter.Stop()
delayWalker(1750 * numBPs)
resetBackpacks()
Looter.Start()
end
BackPacks:Delay(4500, 5500)
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
pedronavila
12-08-2015, 04:35 AM
ososzayat Bro, but for buy potions on that NPC you need to say magic stuff before, so I think that in this script the bot bought mana potions in venore, so i will do the same, thank you anyway :D
Can you give me the customFollowNPC Function?
ososzayat
12-08-2015, 05:04 AM
@ososzayat (http://forums.xenobot.net/member.php?u=53429) Bro, but for buy potions on that NPC you need to say magic stuff before, so I think that in this script the bot bought mana potions in venore, so i will do the same, thank you anyway :D
Can you give me the customFollowNPC Function?
i buy pots from the rock in gray island.. idk what's wrong with your bot xD
well.. follow npc isn't working on ots.. already tryed before with no success.. so u can add a checker like this one so it keeps trying to catch the npc when he gets near.. if unlucky it may take long time :s
1- Add Label
2- Stand in middle of boat
3- Add Script
3- Add Script
4- Add Script (XX=Your X position in the Stand)
BF1
Stand (XX, YY, ZZ)
Self.SayToNpc({"hi", "travel", "venore", "yes"}, 90)
wait(500)
if (Self.Position().x == XX) then Walker.Goto("BF1") end
do the same when you go back to gray island.. hope this was useful.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.