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!
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!
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:
Simba Code:Wait(RandomRange(1000, 2000))
RandomRange(MinNumber,MaxNumber)
or MinNumber + Random(Number)
Used like this -
Simba Code: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
Thanks! Also, is getting my script to detect random events(RS) difficult? I'm still very new to this.
SRL has two built in functions for finding randoms
Simba Code:FindNormalRandoms;
FindNonInventoryRandoms;
There are some random events that can't be solved but for the most part these work really well.
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. *******
Sorry, it copied weird. I think the stars are spaces
put something like
Simba Code: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.
Last edited by P1ng; 06-22-2012 at 01:59 PM.
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...
means you need to put a semicolon on the line before it so if you have
Simba Code: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.
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.
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 [ . ]).
Lol thanks. It's still not compiling though. It's saying findnormalrandoms is an unknown identifier. Any ideas why?
Slightly edited your code to make it compile and make it do what you wanted it to do.
Simba Code: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'ing eachother
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 againFeel 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.
Sweet, it finally compiles! Thanks so much guys! One last thing, with mouse, what do I enter for rx and ry?
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.
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.
Last edited by Footy; 06-22-2012 at 09:09 PM.
There are currently 1 users browsing this thread. (0 members and 1 guests)