SRL Archive - OSR Help

Basic srl question


Footy

2012-06-22 09:33:23

As practice for making code and stuff, I'm making a script that uses Camelot teleport repeatedly. I have everything figured out, but I want my time between loops to be a random number between two numbers. How do I do that?
Thanks!

J J

2012-06-22 09:39:01

You can use Wait() to wait.
Then you need to put a number between the brackets, you want a random number between two numbers which can be achieved by using RandomRange(X, Y).
X being the lowest number, Y being the highest number.

Example:
Wait(RandomRange(1000, 2000))

P1ng

2012-06-22 09:40:40

RandomRange(MinNumber,MaxNumber)

or MinNumber + Random(Number)

Used like this -

Wait(RandomRange(1000,2000));
Wait(1000 + Random(1000));

Both of those lines of code will wait between 1-2sec (or 1000 to 2000 milliseconds).

EDIT: Ninja'd :P

Footy

2012-06-22 09:42:46

Thanks! Also, is getting my script to detect random events(RS) difficult? I'm still very new to this.

P1ng

2012-06-22 09:44:27

SRL has two built in functions for finding randoms

FindNormalRandoms;
FindNonInventoryRandoms;

There are some random events that can't be solved but for the most part these work really well.

Footy

2012-06-22 09:49:27

So if that is my script, how would Iinsert it? I don't need it to solve, logout would be fine.

program CamTele;

var

*x, y:integer;



begin

*repeat

FindColorSpiralTolerance(x, y, 6102593, 674, 268, 694, 284, 10);

**movemouse(x, y);

**clickmouse(x, y, 1);

**wait(randomrange(2000, 2500));

**until(false);

end. *******

Footy

2012-06-22 09:50:33

Sorry, it copied weird. I think the stars are spaces

P1ng

2012-06-22 09:55:58

put something like

if FindNormalRandoms or FindNonInventoryRandoms then
begin
LogOut;
TerminateScript;
end;

into your mainloop or wherever (i'd recommend making a procedure instead which you then call in your mainloop).

This will check wherever you place this for a 'normal' random or 'non-inventory' random and if they are found it will log out your player and then completely stop your script.

Try using the 'edit' button at the bottom of your posts, saves double-posting which is a no-no on the SRL forums.

EDIT: Steer well clear of movemouse(x, y); and clickmouse(x, y, 1); They are horribly likely to get you banned if this is for actual runescape.

for moving the mouse use MMouse(x,y,randx,randy);
for moving and clicking use Mouse(x,y,randx,randy,clicktype);
and for click where your mouse already is use ClickMouse2(clicktype);

These movements are MUCH more human-like and will avoid your impending ban by using the others.

Footy

2012-06-22 10:03:32

Sorry about that. Whenever I try procedures, I get an error saying it expects a semicolon on my main loop begin. Do you know how to fix that? Sorry for all the questions…

J J

2012-06-22 10:11:32

From: Foooty
Sorry about that. Whenever I try procedures, I get an error saying it expects a semicolon on my main loop begin. Do you know how to fix that? Sorry for all the questions…

You need to post your full script if you want to fix that, it can have multiple reasons. You probably forgot to put a ; or and end; somewhere in the procedures/functions above your mainloop.

P1ng

2012-06-22 10:12:10

means you need to put a semicolon on the line before it so if you have


procedure DoSomething;
begin
if FindSomething then
DoThis else
DoThisOtherThing;
end

begin
DoSomething;
end.

That will give you an error on the begin in your mainloop, but if you look to the line above it (the one with the end on it) it doesn't have a semicolon. Put a semicolon there and it should work nicely.

Also, if you are using SRL functions in your script don't forget to add the include and put SetupSRL; at the beginning of your mainloop.

Footy

2012-06-22 10:15:59

Here's my script right now, I still have to fix that moving mouse and click thing
program CamTele;

var

x, y:integer;



Procedure Teleport;

begin

repeat

FindColorSpiralTolerance(x, y, 6102593, 674, 268, 694, 284, 10);

movemouse(x, y);

clickmouse(x, y, 1);

wait(randomrange(2000, 2500));

until(false);

end



Procedure Random

begin

if findnormalrandoms or findnoninventoryrandoms then

begin

logout;

terminatescript;

end

end





begin

Repeat

Teleport

Random

until(false);

end.

P1ng

2012-06-22 10:20:58

Every line you have written in that code with end on it (apart from the absolute last end) needs to have a semicolon (;) at the end of it.

every time you write an end write it like this end;

The ONLY exception to this is the begin and end of your mainloop, which Simba already has written in for you. Your scripts mainloop will end with a full-stop (period [ . ]).

Footy

2012-06-22 10:25:25

Lol thanks. It's still not compiling though. It's saying findnormalrandoms is an unknown identifier. Any ideas why?

J J

2012-06-22 10:28:07

Slightly edited your code to make it compile and make it do what you wanted it to do.
program CamTele;
{$i srl/srl.simba}

Procedure Teleport;
var
x, y:integer;

begin
repeat
if FindColorSpiralTolerance(x, y, 6102593, 674, 268, 694, 284, 10) then
begin
movemouse(x, y);
clickmouse(x, y, 1);
wait(randomrange(2000, 2500));
end;
until(false);
end;

Procedure Randoms;
begin
if findnormalrandoms or findnoninventoryrandoms then
begin
logout;
terminatescript;
end;
end;

begin
Repeat
Teleport;
Randoms;
until(false);
end.

You need to include srl.simba by using {$i srl/srl.simba}
This basicly includes a file to Simba which has many useful stuff in it such as FindNormalRandoms.

Let us know if you have any questions. All :ninja:'ing eachother

P1ng

2012-06-22 10:28:32

If your script uses any SRL functions (which I highly recommend you use, they are infinitely helpful) you must include SRL.

This means putting {$i SRL\SRL.Simba} at the beginning of your code (just after the program CamTele; line)

Also in this include are the functions MMouse, Mouse, ClickMouse2 which I mentioned earlier, these are much more human-like and will avoid Jagex' ban system unlike your current MoveMouse and ClickMouse, I recommend you replace those with the aforementioned.

EDIT: Haha, ninja'd again ;) Feel free to PM myself or J J (he is a bit more experienced than I am, but for these errors we both seem to be able to help). for any further help you require.

Footy

2012-06-22 10:34:04

Sweet, it finally compiles! Thanks so much guys! One last thing, with mouse, what do I enter for rx and ry?

P1ng

2012-06-22 10:36:58

they are integers for how much to randomise the x and y co-ords that your mouse will move to.

I highly recommend this: http://villavu.com/forum/showthread.php?t=58935 for a read, it answers the issues we have already covered plus many, many more.

Footy

2012-06-22 10:40:31

Alright. I'll check that out. Thanks guys!

EDIT: Everythings looking good, but I have one more question… In this script, I used findcolorspiraltolerance to pick a random pixel on the teleport button, so i wasnt always clicking the same pixel, is there a different way to pick a random pixel in an area? Because the pixels might not always be the same color.