SRL Archive - First Scripts

My first script (Fady's Headless Arrow Maker)


fady

2015-02-24 22:38:02

I'm sorry if I'm a bit sloppy, this is my first script and I just started working on this today. I wanted to post this to get some feedback on how I'm doing in terms of functionality and sustainability. I know that I might have over complicated some of my procedures and any tips are much appreciated.

Firstly, I want to thank The Mayor for his tutorials, without them I'd be lost. I'd also like to thank and Apologize to Camel for not asking him first before using his Anti ban procedure, but I did/do not have the 10 posts required to send a PM. If you have any objections to my use of the procedure let me know, but your anti-ban was great from my perspective, so thank you.

Features:
Feathers arrow shafts into Headless Arrows
Uses keyboard to click action bar, with fail safe if keyboard stops working to use the mouse to click inventory slot
simple antiban during progress window, takes mini breaks 5-10 minutes as an antiban procedure every once in a while

Instructions:
1- fill out username and password
2- make sure your shafts are in inventory slot 1, and action bar slot 1
3- i suggest keeping an eye on the script while it works for now, because it hasn't had extensive testing

To-Do list:
1- add headless arrow to arrow functionality
a)make mode and arrowhead type by user input
b)make action bar and inventory slots by user input
c)have the script change the Mouse over text data according to user input
2- add breaks
3- add a proggy

Current issues (that i know of):
1- once the fail safe mouse mode is activated it stays in that mode, and doesn't check back for the keyboard after a while. (I'll probably work on this sometime this week, before moving on to my To-Do list) (added a random integer 100 that will exit the mouse repeat if it hits >95)
2- if the user has more shafts than feathers, it will get stuck on the production window, and keep trying to click start once out of feathers. (added a fail safe that will terminate the script if progress window doesn't open within 5 seconds of clicking start)

and now to the script!!


program HeadlessArrowMaker;

{$DEFINE SMART}
{$I SRL-6/SRL.simba}
{$I SPS/lib/SPS-RS3.Simba}

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := 'user';
password := 'password';
isActive := true;
isMember := false;
world := 61; //world selecter (0 for random, -1 for just play button, other for specific world)
end
currentPlayer := 0;
end;
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~//
// Big Thanks to //
// The Mayor for his tutorials! //
// Camel for the Antiban in his Aircrafter //
// //
////////////////////// DO NOT TOUCH BELOW THIS LINE!! ////////////////////////
////////////////////// DO NOT TOUCH BELOW THIS LINE!! ////////////////////////
///////////////// Only Edit if you know what you're doing!! //////////////////
///////////////// Only Edit if you know what you're doing!! //////////////////
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~//

procedure Antiban(); //Taken from Camel's Aircrafter + some customiation (credit to him for an amazing script)
var
i: integer;
begin
i := random(850);
if i < 90 then
begin
writeLn('Doing antiban');
case i of
1..6: begin
writeLn('Taking Mini-break');
wait(gaussRangeInt(300000,600000));
if not isLoggedIn() then
begin
players[currentPlayer].login();
wait(gaussRangeInt(300,2000));
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
closePollWindow();
end;
end;
7..11: mouseMovingObject();
12..30: sleepAndMoveMouse(randomRange(100,6000));
31..47: begin
mouseOffClient(Random(4));
Wait(gaussRangeInt(10000,15000));
end;
48..63: Wait(gaussRangeInt(15000,20000));
64..70: pickUpMouse();
71..90: SmallRandomMouse(10 + random(40));
end;
writeLn('Antiban done');
end;
if(i > 700) then
begin
mouseSpeed := gaussRangeInt(18,29);
writeLn('Changing mouse speed');
end;
end;

procedure keyboardHeadless();
begin
repeat
typeSend('1', false); // keyboard Actionbar slot 1 (Shafts)

if productionscreen.isopen(5000) then //i If productionScreen is open within 5 seconds
begin
productionScreen.clickStart(); // Click the start button
if progressScreen.isOpen(5000) then // if progressScreen is open within 5 seconds
begin
writeLn('Making headless arrows!');
AntiBan();
repeat
wait(500);
until (not progressScreen.isOpen()); // Repeat waiting 0.5 second until it's not open anymore
end else
terminateScript();
end else
begin
writeLn('Switching to mouse mode');
exit;
end;

wait(gaussRangeInt(100, 1000)); //waiting between 0.1-1 second to repeat
until false;
end;

procedure mouseHeadless();
var
a: integer;
begin
repeat
tabBackPack.mouseSlot(1, MOUSE_MOVE); //Move mouse to slot 1

if isMouseOverText(['eather Arrow shaft']) then
begin
fastClick(MOUSE_Left); // Left click(Shafts)
end else
terminateScript();
if productionScreen.isOpen(5000) then // If productionScreen is open within 5 seconds
begin
productionScreen.clickStart(); // Click the start button
if progressScreen.isOpen(5000) then // if progressScreen is open within 5 seconds
begin
writeLn('Making headless arrows using failsafe!');
AntiBan();
repeat
wait(500);
until (not progressScreen.isOpen()); // Repeat waiting 0.5 second until it's not open anymore
end else
exit;
end else
terminateScript();
wait(gaussRangeInt(100, 1000)); //waiting between 0.1-1 second to repeat
a := random(100);
until a > 95; //tries to use keyboard again when a is above 95.
writeLn('Trying keyboard Again');
end;

// main loop
begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
declarePlayers();

repeat
if not isLoggedIn() then // If player isn't logged in then
begin
players[currentPlayer].login(); // Log them in
exitTreasure(); // Exit treasure hunter
minimap.clickCompass(); // Make compass north and angle high
mainScreen.setAngle(MS_ANGLE_HIGH);
end;

keyboardHeadless();
mouseHeadless();
wait(gaussRangeInt(100, 1000)) //waiting between 0.1-1 seconds to repeat
until false;
end.


Any suggestions or problems are much appreciated

Taric

2015-02-24 22:54:52

First of all, have a cookie for being one of the few people who remembers to keep their username and password out of their script :p. Second, GRATS ON THE FIRST RELEASE.

You've got a great setup here for a bank standing script. Look into porting it into things other than headless arrows :3

fady

2015-02-24 23:02:46

From: Taric
First of all, have a cookie for being one of the few people who remembers to keep their username and password out of their script :p. Second, GRATS ON THE FIRST RELEASE.


hahahaha, I only remembered because during my research stage, I came across multiple threads where people were told to remove them! :D.

From: Taric
You've got a great setup here for a bank standing script. Look into porting it into things other than headless arrows :3

I want to do that, I'm thinking if I can make it work for Headless to Arrows, I can make it work with almost anything.

Thank you for looking at it! :D

Trollcrank

2015-02-24 23:12:52

Well the first thing I noticed was that it won't be able to log back in.

if not isLoggedIn() then // If player isn't logged in then
begin
players[currentPlayer].login(); // Log them in
exitTreasure(); // Exit treasure hunter
minimap.clickCompass(); // Make compass north and angle high
mainScreen.setAngle(MS_ANGLE_HIGH);
end;
{RIGHT HERE. The login loop is not within the repeat and therefore won't log back in, not sure if intentional}
repeat
{loop here}
until false; //needs a semicolon here :)

until (not progressScreen.isOpen());
This needs a failsafe just in case, you don't want this to be an infinite loop. If it got stuck for whatever reason it would just sit in the lobby doing nothing and it would stop the production of headless arrows. I recommend a timer.

procedure aBarKeyHeadless();
var
ProdScrWait: TTimeMarker;
begin
{your code here}
AntiBan();
ProdScrWait.start();
repeat
wait(500);
until (not progressScreen.isOpen()) or (not isLoggedIn()) or (ProdScrWait.getTime() > 10000);

The rest is awesome, yet simple, for a first script! Everyones' first script turned out better than mine :p

fady

2015-02-24 23:27:27

From: Trollcrank
Well the first thing I noticed was that it won't be able to log back in.


What do you mean it won't be able to log back in? like If the user got disconnected? the reason I left it out of the loop was because I thought the extra log in check would slow it down between repeats, but ill try it with the log in part within the loop. Thanks

From: Trollcrank
This needs a failsafe just in case, you don't want this to be an infinite loop. If it got stuck for whatever reason it would just sit in the lobby doing nothing and it would stop the production of headless arrows. I recommend a timer.


I have a fail safe so it doesn't just loop endlessly, but it just terminates the script if the progress screen doesnt come up within 5 seconds of clicking start

I would like to have it try again when that happens. A timer would be a good addition to exit the procedure and go back to the main loop, Thank you!!

Trollcrank

2015-02-24 23:36:35

From: fady
What do you mean it won't be able to log back in? like If the user got disconnected?

Alright, as of right now it will spawn the client login and begin the loop. But if for whatever reason it logs out(like cuz of internet connection) it won't log back in because it is not in the repeat…until

I tested the script and it ended up executing anyways due to the mouseovertext failsafe, so it doesn't have to be changed after all
From: fady

I have a fail safe for this, but it just terminates the script if the progress screen doesnt come up within 5 seconds of clicking start

Darn, didn't see that *facepalm*

Edit: The loggin loop won't slow it down, it is a very fast check. I also can't really think of anything for you to add/change actually. Except maybe some wait random ranges which would be completely optional.

fady

2015-02-25 00:01:56

Oh, I'll def add it in the loop then! Thank you.

3Garrett3

2015-02-25 12:54:22

From: fady
Oh, I'll def add it in the loop then! Thank you.


The login portion that Trollcrank is talking about is also referred to as "the 6 hour fix". When you put that code inside of your loop and you get disconnected after 6 hours, it will notice that you're logged out and SRL handles the re-opening of SMART for you, then it logs back in with your code.

So when you see someone say "Runs past the 6 hour mark!" on their script, it's because they have that code in their loop (like you will now). So if someone ever has 1M arrows to make, your script won't get disconnected at 6 hours and do nothing.

fady

2015-02-25 13:13:25

From: 3Garrett3
The login portion that Trollcrank is talking about is also referred to as "the 6 hour fix". When you put that code inside of your loop and you get disconnected after 6 hours, it will notice that you're logged out and SRL handles the re-opening of SMART for you, then it logs back in with your code.

So when you see someone say "Runs past the 6 hour mark!" on their script, it's because they have that code in their loop (like you will now). So if someone ever has 1M arrows to make, your script won't get disconnected at 6 hours and do nothing.


OHHHHH!!!! that would make sense!! I wanted to look into doing that, but it wasn't really on my to-do list, because i didnt think anyone would need to use this for more than 6 hours, but 1M arrows would lol. I guess I dont have to look after all! :D

Thanks for clearing that up for me!