SRL Archive - OSR Help

Trying to make a really simple script. Need help please


yamahablasta

2014-02-25 22:10:38

I'm trying to make my first script for a private server called fatality, I couldn't find a better place to post this, its probably in the wrong section, but anyways.

Since its for a server that can't use UpText and if LoggedOut, I need to go about using colors and such to check these things im assuming.

So theres a color I Need to click on, so im using
FindColorTolerance(var x,y: integer; color x1,y1,x2,y2 tol:integer): boolean

Will this find the color and set my x,y variables so that I can click on their cords?
I understand how to use the color picker, but I just get a large number, what is x1,y1,x2,y2 for, I don't even know what to enter for these,
I tried FindColorTolerance(X,Y,8777431,1); But it gave me a crappy error, all of the documentation for this is gone, so I cant really find anything out about it.
Can you guys help me get started? Thanks - Andy

Ian

2014-02-25 22:26:09

Yes, if it finds the color it will set the x and y to the coords of the color.
You can then move the mouse to it and left click it with

mouse(point(x, y), MOUSE_LEFT, MOUSE_HUMAN);

x1,y1,x2,y2 are the coords that mark the area where Simba will look for your color.

Think about it as two points like this forming a box:

1----|
| |
| |
|----2
1 is X1, Y1
2 is X2, Y2

Good luck! Also, the beginner's tutorial section is a great place to find scripting resources :)

Foundry

2014-02-25 22:30:44

From: yamahablasta
I'm trying to make my first script for a private server called fatality, I couldn't find a better place to post this, its probably in the wrong section, but anyways.

Since its for a server that can't use UpText and if LoggedOut, I need to go about using colors and such to check these things im assuming.

So theres a color I Need to click on, so im using
FindColorTolerance(var x,y: integer; color x1,y1,x2,y2 tol:integer): boolean

Will this find the color and set my x,y variables so that I can click on their cords?
I understand how to use the color picker, but I just get a large number, what is x1,y1,x2,y2 for, I don't even know what to enter for these,
I tried FindColorTolerance(X,Y,8777431,1); But it gave me a crappy error, all of the documentation for this is gone, so I cant really find anything out about it.
Can you guys help me get started? Thanks - Andy


As for the first question: Yes, the x and y will contain the x and y coordinate if the color is found.
Second Question: You should take a look at The Mayors tutorial here. You will want to look at the section called variable types.

yamahablasta

2014-02-25 23:21:46

Ok, So here's where I'm at, It activates the client(pulls it to front) then does nothing. I've tried many colors and nothing changes. I tried it with the color tolerance function as well with the same result, So I feel like there must be a problem with my code, can someone take a look please,

program ThievesStuff;

Const
Mart = 9170145;

Procedure Thieve;
var X,Y : Integer;
begin

if (FindColor(X,Y,2642530,0,0,520,340)) then
begin
MoveMouse(X,Y);
Sleep(1000);
ClickMouse(X,Y,0);
end;
end;

begin
Sleep(250);
ActivateClient;
repeat
Sleep(3000);
Thieve;
until(Random(3) = 4);
end.

yamahablasta

2014-02-25 23:30:32

Now I got it to click using almost the exact same code.. but now its clicking at 0,0 no matter what. The X,Y is always 0,0 for some reason
The part I really don't understand is that im getting the output 'no' but im never getting 'inloop' eventhough its moving the mouse to 0,0… how is that even possbile
program ThievesStuff;

Const
Mart = 9170145;

Procedure Thieve;
var X,Y : Integer;
begin
Writeln('no')
if (FindColor(X,Y,2642786,0,0,750,500)) then
Writeln('in loop');
MoveMouse(X,Y);
Sleep(1000);
ClickMouse(X,Y,0);
end;


begin
Sleep(250);
ActivateClient;
repeat
Sleep(3000);
Thieve;
until(Random(3) = 4);
end.

Ian

2014-02-25 23:49:16

From: yamahablasta
Now I got it to click using almost the exact same code.. but now its clicking at 0,0 no matter what. The X,Y is always 0,0 for some reason
The part I really don't understand is that im getting the output 'no' but im never getting 'inloop' eventhough its moving the mouse to 0,0… how is that even possbile
program ThievesStuff;

Const
Mart = 9170145;

Procedure Thieve;
var X,Y : Integer;
begin
Writeln('no')
if (FindColor(X,Y,2642786,0,0,750,500)) then
Writeln('in loop');
MoveMouse(X,Y);
Sleep(1000);
ClickMouse(X,Y,0);
end;


begin
Sleep(250);
ActivateClient;
repeat
Sleep(3000);
Thieve;
until(Random(3) = 4);
end.


It goes to 0,0 because that's the default x and y and because FindColor never finds the color that never gets changed. Try using FindColorTolerance and playing around with the tolerance (start @ 5 or so, raise if needed. 255 is max)

yamahablasta

2014-02-25 23:52:08

Ok, ill mess with it, you guys are great btw

Edit- While you guys are here, how can I use the KeyDown method, to move camera to top, how can I send Arrow key up, or any key. I've tried KeyDown('a'); just to get started somewhere, but I get this exception "Exception in Script: Expected variable of type "UInt16", got "AnsiChar"" I need to be able to use enter, and arrow keys

edit2(lol) - The problem is the if loops, they are never getting triggered. I cant even get it to trigger with a simple black color like 283 on a black screen…
this is what my if loop looks like, is there something im doing wrong?

Procedure LowHp;
begin
if FindColorTolerance(junk1,junk2,283,700,20,700,40,5) then
begin
SendKeys('::master enter',100,100);
end;
end;

yamahablasta

2014-02-26 00:14:29

The problem is the colors, its not detecting them correctly. I have to make the tolerance so high that it cant tell the difference between black and red..

And how do I get the ability to use precoded methods like TypeSend(''); that's awesome, I saw it in another script and he didn't include it.

yamahablasta

2014-02-26 20:54:08

All problems resolved.. Private server ran OpenGL graphics by default, I was able to switch to DirectX :D