SRL Archive - General Botting Help

tabBackpack.isEmpty() problem


Spaceblow

2014-08-05 21:15:01

I'm making a simple script but I really don't know what I'm doing wrong here. So far I made a procedure that probably isn't even finished yet. This is what I have so far:

procedure bankRedberries();
var
bankTimer: TTimeMarker;

begin
if not isLoggedIn() then
exit;

bankScreen.open(BANK_NPC_BLUE);
wait(randomRange(750, 1250));

if bankScreen.isOpen() then
begin
bankTimer.start();
writeLn('Succesfully opened the bank');
repeat
begin
wait(randomRange(600, 900));
bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
wait(randomRange(600, 900));
bankScreen.close();
writeLn('Succesfully closed the bank');
end;
until(tabBackpack.isEmpty()) or (not isLoggedIn()) or (bankTimer.getTime() > 7000);
if tabBackpack.isEmpty() then
writeLn('Succesfully banked Redberries');

end;

end;

Its purpose is to open the bank, deposit an inventory full of redberries, close the bank and check if the backpack is empty. Everything runs very well when I test it out with a bunch of logs until it meets 'tabBackpack.isEmpty()'. Instead of checking if my backpack is empty it just clicks on the gear tab (this window pops up). Sometimes it moves the mouse over this for a second and then clicks on the gear tab. I really don't know why. I literally ran it like maybe 50 times and only once it did everything it had to do.

Maybe the debug could tell you more about my problem:

-- setupSRL()
---- Setting up SRL...
---- initSmart():
------ Attempting to pair to a previously spawned client
------ smartPairToExistingClient():
-------- Found 1 free client(s), attempting to pair to one...
---------- smartSetAsTarget(): Succesfully set SMART[4660] as Simba's target
-------- Succesfully paired to a existing client, SMART[4660]
------ smartPairToExistingClient(): result = true
------ Succesfully initialized via pairing to a previously spawned client
---- initSmart()
------ smartSetupDrawing(): Succesfully setup SMART drawing
---- Waiting up to 5 minutes for RS to load...
------ TRSActionBar.__findButton(): Found the actionbar button @ {X = 566, Y = 397}
------ TRSActionBar.__find(): result = true (height = 75)
------ Dynamic interfaces have been set.
---- Client is ready.
---- Setup SRL in 202ms.
-- setupSRL(): True
-- TRSBankscreen.__openNPC()
---- TRSMinimap.getDots()
------ Found 13 minimap dots (ID: 4369)
---- TRSMinimap.getDots(): [{X = 676, Y = 48}, {X = 659, Y = 94}, {X = 664, Y = 109}, {X = 702, Y = 115}, {X = 663, Y = 118}, {X = 700, Y = 119}, {X = 758, Y = 119}, {X = 697, Y = 122}, {X = 694, Y = 126}, {X = 692, Y = 129}, {X = 744, Y = 130}, {X = 609, Y = 133}, {X = 689, Y = 133}]
---- isMouseOverText()
------ Current mouse-over text: ""
------ Current mouse-over text: "Bank Banker"
------ Found "Bank" in mouse-over string: "Bank Banker"
---- isMouseOverText(): True
---- We found correct mouse-over text
---- Bankscreen or pinscreen is open
-- TRSBankscreen.__openNPC(): result = True
Succesfully opened the bank
---- bankScreen.quickDeposit(): Clicked quick deposit id 0
Succesfully closed the bank
---- TRSGameTab.__initTabs(): Setup gametab properties
-- TRSGameTabs.openTab(2)
---- Opening tab via gametab navigation bar
-- TRSGameTabs.openTab(2): result = False
-- TRSGameTabs.openTab(2)
---- Opening tab via gametab navigation bar
-- TRSGameTabs.openTab(2): result = False
-- Succesfully freed SMART[4660]
-- Freeing gametabs bitmaps...
Successfully executed.


I hope you guys could help me because stuff like this discourages me to make my first script, it's very frustrating… Thanks in advance!

KeepBotting

2014-08-05 21:19:41

Reset your oldschool interface layout, the context menu is supposed to open down (not up, like it's doing for you) when you hover over a navbutton

On a happier note, I really love the way in which you laid out this thread … this is the proper way to ask for help, you should congratulate yourself on that as it's pretty rare.

Also, the procedure you posted looks pretty solid–you use lots of SRL functions, checks, randomness, and failsafes which is really good.

Spaceblow

2014-08-05 21:30:16

From: KeepBotting
Reset your oldschool interface layout, the context menu is supposed to open down (not up, like it's doing for you) when you hover over a navbutton
Wow, it fixed the problem! I've spent probably more than 2 hours trying to fix the problem while the fix was so simple… Thank you very much for your very quick reply, I appreciate it! :)

From: KeepBotting
On a happier note, I really love the way in which you laid out this thread … this is the proper way to ask for help, you should congratulate yourself on that as it's pretty rare.

Also, the procedure you posted looks pretty solid–you use lots of SRL functions, checks, randomness, and failsafes which is really good.
I'm glad you liked it. I always try to make it as understandable as possible so you guys could help me. I hate it when I want to help someone but I first need to figure out what the person exactly needs help with. I hope you understand my English.

Almost everything I learned so far comes from The Mayor's AIO guide. This is probably the best community I've ever seen, I like everything about it.

KeepBotting

2014-08-05 21:33:30

From: Spaceblow
Wow, it fixed the problem! I've spent probably more than 2 hours trying to fix the problem while the fix was so simple… Thank you very much for your very quick reply, I appreciate it! :)
Quite welcome

add my Skype or PM me if you ever need any help :)

The Mayor

2014-08-05 22:15:48

I'm glad you fixed your issue, but there is a major flaw in your procedure.

What happens if quick deposit failed for some reason? Well, it will still close the bank and then keep looping for 7 seconds waiting for the backpack to be empty, which it will never be.


repeat
begin
wait(randomRange(600, 900));
bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
wait(randomRange(600, 900));
bankScreen.close();
writeLn('Succesfully closed the bank');
end;
until(tabBackpack.isEmpty()) or (not isLoggedIn()) or (bankTimer.getTime() > 7000);

Before closing the bank, you should check if the backPack is empty using bankScreen.getPackCount()


procedure bankRedberries();
var
bankTimer: TTimeMarker;

begin
if not isLoggedIn() then
exit;

bankScreen.open(BANK_NPC_BLUE);

if bankScreen.isOpen(randomRange(2000, 3000)) then //notice how this can take a waitTime parameter
begin
bankTimer.start();
writeLn('Succesfully opened the bank');

repeat
wait(randomRange(600, 900));
bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
wait(randomRange(600, 900));
until (bankscreen.getPackCount = 0) or (not isLoggedIn()) or (bankTimer.getTime() > 7000);

bankScreen.close(); // closebank after pack count already 0

if tabBackpack.isEmpty() then
writeLn('Succesfully banked Redberries');

end;

end;

Spaceblow

2014-08-06 06:41:42

From: KeepBotting
Quite welcome

add my Skype or PM me if you ever need any help :)
I don't have Skype so I'll probably send you a PM when I have just a little question, thank you once again!

From: The Mayor
I'm glad you fixed your issue, but there is a major flaw in your procedure.

What happens if quick deposit failed for some reason? Well, it will still close the bank and then keep looping for 7 seconds waiting for the backpack to be empty, which it will never be.


repeat
begin
wait(randomRange(600, 900));
bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
wait(randomRange(600, 900));
bankScreen.close();
writeLn('Succesfully closed the bank');
end;
until(tabBackpack.isEmpty()) or (not isLoggedIn()) or (bankTimer.getTime() > 7000);

Before closing the bank, you should check if the backPack is empty using bankScreen.getPackCount()


procedure bankRedberries();
var
bankTimer: TTimeMarker;

begin
if not isLoggedIn() then
exit;

bankScreen.open(BANK_NPC_BLUE);

if bankScreen.isOpen(randomRange(2000, 3000)) then //notice how this can take a waitTime parameter
begin
bankTimer.start();
writeLn('Succesfully opened the bank');

repeat
wait(randomRange(600, 900));
bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
wait(randomRange(600, 900));
until (bankscreen.getPackCount = 0) or (not isLoggedIn()) or (bankTimer.getTime() > 7000);

bankScreen.close(); // closebank after pack count already 0

if tabBackpack.isEmpty() then
writeLn('Succesfully banked Redberries');

end;

end;
You actually helped me more than you think. I was also wondering how that box calls when you use the bank, the box that refers to your inventory. I first thought it had something to do with 'depositBox' or something. Not only you helped me with making my procedure better but also with answering the thing I wondered about, thank you very much!