SRL Archive - OSR Help

First Script help!


matt112200

2012-03-06 08:44:32

Hey guys,

Got quite interested in Simba scripting so followed some tutorials and went to make the script below.

Only problem is when I run it it just logs out!

The aim is for it to search tools in my house then grab watering cans and get the demon butler to bank them.

Any advice would be greatly appreciated :). (Be gentle it's my first script!)

program WaterCan;
{$DEFINE SMART}
{$DEFINE CRASHSMART}
{$i SRL\SRL.simba}
{$i SPS\SPS.simba}

var x,y,c1,r1,sx,sy,antibans:integer;
BColor:TIntegerArray;
Options: Array of String;

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name := 'Name'; // Username?
Players[0].Pass := 'Pass'; // Password?
Players[0].Nick := 'ick'; // 3 letters of your username (not the first letter)
Players[0].Active := True;
end;

Function FindObjOnScreen(Up:Array of String;Color,Tolerance:Integer;MC2:Variant;Hmod,Smod:Extended): Boolean;
var
X,Y:Integer;
CTS,I,T: Integer;
TPA: TPointArray;
begin
repeat
Result := False;
CTS := GetColorToleranceSpeed;

ColorToleranceSpeed(2);

SetColorSpeed2Modifiers(Hmod,Smod);

FindColorsSpiralTolerance(MSCX, MSCY, TPA,(10923844), MSX1, MSY1, MSX2, MSY2, Tolerance);
ColorToleranceSpeed(CTS);

if (Length(TPA) < 1) then
Exit;

MMouse(TPA[0].X, TPA[0].Y, 5, 5);
if WaitUpTextMulti(Up, 400) then
begin
GetMousePos(X, Y);
ClickMouse2(MC2);
Result := false;
Exit;
end;
Until(Result = True);
end;

Function ChatText(): Boolean;
var
X, Y : Integer;
begin
if (not(FindColor(X, Y, 0, 7, 460, 69, 474))) then

If FindText(x, y, 'ore', SMALLCHARS, MCX1, MCY1, MCX2, MCY2) Then
Mouse(x, y, 1, 1, True);
Wait(500+Random(50));
If FindText(x, y, 'atering can', SMALLCHARS, MCX1, MCY1, MCX2, MCY2) Then
Mouse(x, y, 1, 1, True);
end;
Function ButlerBank: Boolean;
var
Bx,By:integer;
begin
FindObj(x, y,'butler', 8290940, 5);
Writeln('Found the Butler');
Mouse(Bx,By,0,0,false);
Wait(100+random(100));
ChooseOptionMulti(['alk']);
Wait(1000+random(400))
if FindText(X, Y, 'more', NPCCHARS, MCX1, MCY1, MCX2, MCY2) then
begin
Result := True;
MMouse(X, Y + 2, Random(Length('More') * 5), 4);
Mouse(X, Y + 2, Random(Length('Take To Bank') * 5), 4, True);
MMouse(260,473,5,0); //older mouse script needs replacing to correct co ords
Wait(500+random(500));
If WaitUptext('ontinue',300) then
begin
Writeln('Payment Time');
MouseBox(221,458,293,473,1);
Wait(700);
TypeSend('2');
Wait(2500+random(500));
Mouse(Bx,By,0,0,false);
Wait(100+random(100));
ChooseOptionMulti(['talk']);
end;
wait(500);
TypeSend('26');
Wait(1000+random(500));
end;
begin
Writeln('No Butler for us');
TerminateScript;
end;
end;
Procedure Antiban;
Begin

Case Random(100) Of
1: HoverSkill('construction', False);
2: HoverSkill('random', False);
3: Boredhuman;
4: Wait(2500 + random(4500));
5: HoverSkill('smithing', False);
6: PickUpMouse;
7: RandomMovement;
8: RandomRClick;
end;
end;

Procedure MiniBreaker;
Begin

Case Random (160) Of
1: Wait(40000 + random(7400));
2: Wait(25500 + random(8550));
3: Wait(60040 + random(6759));
4: Wait(20400 + random(2549));
end;
end;
procedure FindToolsAndSearch;
var
Lx,Ly, Vx, Vy, Time:integer;
begin
FindObjOnScreen(['earch', 'tools', 'ools'],8290940,1,True,1.73,0.01);
Repeat
ChatText();
until (invfull);
ButlerBank;
Antiban;
TerminateScript;
end;
begin
Smart_Members := True;
Smart_Server := 1;
SetupSRL;
DeclarePlayers;
if not(LoggedIn) then
LogInPlayer;
while not(LoggedIn) do
Repeat
ChatText;
until (invfull);
ButlerBank;
Antiban;
ExitToLobby;
end.

Nebula

2012-03-06 17:31:41

I think your problem is in the main loop.


begin
Smart_Members := True;
Smart_Server := 1;
SetupSRL;
DeclarePlayers;
if not(LoggedIn) then
LogInPlayer;
while not(LoggedIn) do //Since you ARE logged in, the script skips over this.
Repeat
ChatText;
until (invfull);
ButlerBank; //The script can't find the butler, so it just Goes straight to the lobby
Antiban;
ExitToLobby;
end.

Littellj

2012-03-06 23:00:59

Nice script, Maybe if you want some extra practice, Have it walk to a bell you have in your house, then pull it! :)\

Goodluck

matt112200

2012-03-07 02:51:09

Thanks for the help guys. Modified the code slightly and will test later when at home.

program WaterCan;
{$DEFINE SMART}
{$DEFINE CRASHSMART}
{$i SRL\SRL.simba}
{$i SPS\SPS.simba}

var x,y,c1,r1,sx,sy,antibans:integer;
BColor:TIntegerArray;
Options: Array of String;

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name := 'Name'; // Username?
Players[0].Pass := 'Pass'; // Password?
Players[0].Nick := 'ick'; // 3 letters of your username (not the first letter)
Players[0].Active := True;
end;

Function FindObjOnScreen(Up:Array of String;Color,Tolerance:Integer;MC2:Variant;Hmod,Smod:Extended): Boolean;
var
X,Y:Integer;
CTS,I,T: Integer;
TPA: TPointArray;
begin
repeat
Result := False;
CTS := GetColorToleranceSpeed;

ColorToleranceSpeed(2);

SetColorSpeed2Modifiers(Hmod,Smod);

FindColorsSpiralTolerance(MSCX, MSCY, TPA,(10923844), MSX1, MSY1, MSX2, MSY2, Tolerance);
ColorToleranceSpeed(CTS);

if (Length(TPA) < 1) then
Exit;

MMouse(TPA[0].X, TPA[0].Y, 5, 5);
if WaitUpTextMulti(Up, 400) then
begin
GetMousePos(X, Y);
ClickMouse2(MC2);
Result := false;
Exit;
end;
Until(Result = True);
end;

Function ChatText(): Boolean;
var
X, Y : Integer;
begin
if (not(FindColor(X, Y, 0, 7, 460, 69, 474))) then
FindObjOnScreen(['earch', 'tools', 'ools'],8290940,1,True,1.73,0.01);
If FindText(x, y, 'ore', SMALLCHARS, MCX1, MCY1, MCX2, MCY2) Then
Mouse(x, y, 1, 1, True);
Wait(500+Random(50));
If FindText(x, y, 'atering can', SMALLCHARS, MCX1, MCY1, MCX2, MCY2) Then
Mouse(x, y, 1, 1, True);
end;
Function ButlerBank: Boolean;
var
Bx,By:integer;
begin
if FindObj(565, 341,'butler', 8290940, 5) then //added co ords to help find butler when next to you also modified to type only if he is found

Writeln('Found the Butler');
Mouse(Bx,By,0,0,false);
Wait(100+random(100));
ChooseOptionMulti(['alk']);
Wait(1000+random(400))
if FindText(X, Y, 'more', NPCCHARS, MCX1, MCY1, MCX2, MCY2) then
begin
Result := True;
MMouse(X, Y + 2, Random(Length('More') * 5), 4);
Mouse(X, Y + 2, Random(Length('Take To Bank') * 5), 4, True);
MMouse(260,473,5,0); //older mouse script needs replacing to correct co ords
Wait(500+random(500));
If WaitUptext('ontinue',300) then
begin
Writeln('Pay Butler');
MouseBox(221,458,293,473,1);
Wait(700);
TypeSend('2');
Wait(2500+random(500));
Mouse(Bx,By,0,0,false);
Wait(100+random(100));
ChooseOptionMulti(['talk']);
end;
wait(500);
TypeSend('26');
Wait(1000+random(500));
end;
begin
Writeln('No Butler for us');
TerminateScript;
end;
end;
Procedure Antiban;
Begin

Case Random(100) Of
1: HoverSkill('construction', False);
2: HoverSkill('random', False);
3: Boredhuman;
4: Wait(2500 + random(4500));
5: HoverSkill('smithing', False);
6: PickUpMouse;
7: RandomMovement;
8: RandomRClick;
end;
end;

Procedure MiniBreaker;
Begin

Case Random (160) Of
1: Wait(40000 + random(7400));
2: Wait(25500 + random(8550));
3: Wait(60040 + random(6759));
4: Wait(20400 + random(2549));
end;
end;
procedure FindToolsAndSearch;
var
Lx,Ly, Vx, Vy, Time:integer;
begin
Repeat
ChatText();
until (invfull);
ButlerBank;
Antiban;
TerminateScript;
end;
begin
Smart_Members := True;
Smart_Server := 1;
SetupSRL;
DeclarePlayers;
if not(LoggedIn) then
LogInPlayer;
Repeat
ChatText;
until (invfull);
ButlerBank;
Antiban;
ExitToLobby;
end.

cool13bro

2012-03-15 22:56:37

Wow, lol.. you did all that after watching tuts. After watching countless tuts and reading a bunch, I still can't find out how to simply attack a monster and then wait for the monster to respawn again.

Sin

2012-03-15 23:00:36


SMALLCHARS
I found that a bit ironic ;P