PDA

View Full Version : Stamina Potion Help



Firulis
06-20-2017, 06:52 AM
Hello i want to make a script that will make my character use a certain item to refill stamina when is below 40 hours. right now this is what i have

function staminaPotion()
if Self.Stamina() < 2400 then
Self.UseItemWithMe(11588)
end
end
When i try to run this my xenobot rejects it and i want to know if anybody can help me correct it thank you

damulka11
06-20-2017, 04:55 PM
Put whole code in 'while', 'if' start only once, so when code end xenobot close it.



while (true) do
function staminaPotion()
if Self.Stamina() < 2400 then
Self.UseItemWithMe(11588)
wait(1000)
end
end
end

You can even remove this 'function'



while (true) do
if Self.Stamina() < 2400 then
Self.UseItemWithMe(11588)
wait(1000)
end
end

I added 1 sec wait because it may lag so much.

Firulis
06-20-2017, 09:16 PM
hi thanks for the help but i still have a little problem here, when i run the script nothing happens, so i tried replacing the item instead i put the mana potion and it works fine, but when i tried using the actual stamina potion, it doesnt use it, im thinking maybe because the way it works is you click the item and it dessapears and with the mana potion you actually have to select something so im wondering if there is code for that for the bot to just right click and item or something because i'm sure that is the problem

Firulis
06-22-2017, 03:03 AM
Hey i just want to let you guys know that i fixed the problem i did this:

local staminaPotion = 11588
local hours = 40


while (true) do
if Self.Stamina() < ( 60 * hours ) then
Self.UseItem(staminaPotion)
end
end

Joshwa534
06-22-2017, 04:09 AM
Hey i just want to let you guys know that i fixed the problem i did this: ...

I would toss a delay in there so its not performing that check as quickly as possible..

Modules have a built-in delay of 200ms, here's an example of one with a 1 minute delay between checks.



local potion = 11588
local hours = 40

Module.New('stamina-potion', function(module)
if Self.Stamina() < (60 * hours) then
Self.UseItem(potion)
end
module:Delay(60000)
end)


You could even throw in a 1 hour delay after using a stamina potion like this:



Module.New('stamina-potion', function(module)
if Self.Stamina() < (60 * hours) then
Self.UseItem(potion)
module:Delay(60*60000)
else
module:Delay(60000)
end
end)