SRL Archive - OSR Help

Need Basic Help


Keasbey

2013-02-13 07:03:09

I've read a few tutorials, I understand them no problem, but when it comes to actually piecing bits of code together on my own, I get some weird errors.
Right now I'm trying to make a simple fletching script, for now I just want to make maple shieldbow's , will work on adding the rest of them once I have my skeleton for my script complete. At the moment I've gotten only as far as depositing everything in the inventory on startup, and I recieve an error when I try to compile with my main loop, which isn't making sense to me.

The script I have so far is at the bottom, but I also need a few simple questions answered:

1) What is the code for exiting a program/ending the script? For example, in the code below i want to put " if result:=false " then the result would be the script exiting.
2) What is the code for 6hr relog? Is there a general code for this? ( such as procedure declareplayers )


Program Stringing;
{$DEFINE SMART}
{$i srl/srl.simba}

//Login at draynor bank

Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name :='';
Players[0].Pass :='';
Players[0].Pin :='';
Players[0].Nick :='';
//Players[0].WorldInfo:=[44]; //If You Want A Home World
Players[0].Active:=True; //Don't Touch
WORLDSWITCHERENABLED:=False; //Don't Touch
end;

Function Clearinv: Boolean;
Var
db: string;
Begin
if findbank(db)then
Result := true;
Wait(RandomRange(100,350));
depositall;
end



begin;
ActivateClient;
SetUpSRL;
DeclarePlayers;
Clearinv;
end.

riwu

2013-02-13 07:19:09

To terminate a script, call TerminateScript.
To exit out of a routine, call Exit.

The script automatically terminates when the codes in the main program has been executed.


Function ClearInv: Boolean;
begin
Result := findbank('db');
if not Result then
Exit; //or terminateScript
Wait(RandomRange(100,350));
depositall;
end;

begin
//codes
if not ClearInv then
TerminateScript;
end.

Keasbey

2013-02-13 07:57:46

From: riwu
To terminate a script, call TerminateScript.
To exit out of a routine, call Exit.

The script automatically terminates when the codes in the main program has been executed.


Function ClearInv: Boolean;
begin
Result := findbank('db');
if not Result then
Exit; //or terminateScript
Wait(RandomRange(100,350));
depositall;
end;

begin
//codes
if not ClearInv then
TerminateScript;
end.


Thank you so much!

i luffs yeww

2013-02-13 08:00:20

From: Keasbey
Thank you so much, for the first part ( where you added " if not result " ) does SRL assume that the result will be true?


Well SRL itself doesn't do the compiling, but no. He sets Result to the result of FindBank, and if it's not True, then it will Exit the function.

And just to add some information, at the start of a function, Result is set to False.

Kevin

2013-02-13 12:46:30

As for your second question relating to the six hour log.
You will need to add

Smart_FixSpeed := TRUE;
SRL_SixHourFix := TRUE;
somewhere in your initialization of the program. That will tell your script to check for Runescape declaring your session has ended at a login attempt. However, for it to reach that point, you will have to tell your client to
loginPlayer;
at some point in time it is logged out. For example, in one of my scripts I have a generic failure method I wrote and call whenever all my failsafes fail and the script should shutdown. I simply call this:
procedure FailOutOfCode(message: String);
begin
If(not (LoggedIn)) then
begin
LogInPlayer;
end else
begin
WriteLn(message);
FreeMyDTMs;
Logout;
TerminateScript;
end;
end;
and it verifies first whether it's loggedin, at which point it will login the player (and bypass the six hour fix).

However, it's also possible to get around the issue in other manners, such as something along the lines of:
repeat
//do all your normal code runtime stuff
until(not loginplayer);
LoginPlayer returns true if currently logged in OR if it was logged out and could log in, and that can also run your six hour fix.

Keasbey

2013-02-13 13:51:16

Thanks so much for the help guys, I have to admit that you guys are helping a lot as I understand more of where things go and how to piece them together now.
Wrote the code up to the point of withdrawing supplies now :P
I can honestly see scripting becoming a hobby of mine as I often wonder what to do when I'm not at school/the gym to occupy my time haha.

Edit: What are the functions/procedures that aren't supposed to be used because they look too robotic?

Sjoe

2013-02-13 15:02:11

From: Keasbey
Thanks so much for the help guys, I have to admit that you guys are helping a lot as I understand more of where things go and how to piece them together now.
Wrote the code up to the point of withdrawing supplies now :P
I can honestly see scripting becoming a hobby of mine as I often wonder what to do when I'm not at school/the gym to occupy my time haha.

Edit: What are the functions/procedures that aren't supposed to be used because they look too robotic?


Avoid using Movemouse, and clickmouse . instead use MMouse and ClickMouse2 (they are SRL functions)
Using SRL functions are safe! Just check the function list on the leftside of Simba or includes in C:\Program files\Simba\Includes\SRL\


And make sure u use before SetupSRL;

Smart_FixSpeed := TRUE;
SRL_SixHourFix := TRUE;
SetupSRL; // This after the six hour fix