SRL Archive - OSR Help

Help Trying To Make A Script


deanironman

2012-06-26 19:49:10

I really need help this is my first time scripting and i have no freaking idea how to do this some help would really be appreciated. Im trying to make the player fish in the fishing guild (Lobsters) Thank bank and repeat this is what i got so far. Any help would be great !



program GuildFisherLobbs
{$DEFINE SMART}
{$i srl/srl.simba}
{$i sps/sps.simba}
const
{==========Smart Setup==========}
World = 0; // Input the runescape world number right here for it to select. You may leave it as 0 if you would like it to select a random world.
MEMBERS = False; // Select False if you are not a member. Select True if you are a member.
SIGNED = True; // Select True if you are using single account. Select False if not.
{===============================}
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := ''; //Your Runescape username goes right here.
Players[0].Pass := ''; //Your Runescape password goes right here.
Players[0].Active := True; //Set to True if you want to use this player. Set to False to disable this player.
Players[0].Pin := ''; //Put your Bank PIN here. Leave blank if you don't have a Bank PIN.
end;
procedure Cage;
var x, y: integer;
begin
if FindObj(x, y,)'in'8482403, 10),then //This will have the script find an object of your choice
begin
Mouse(x, y, 0, 0, true);
ChooseOption('ine');
wait(1500+random(1000)); // This will make the script wait for a certain time
until (InvFull);
end;
procedure WalkToBank;
begin
if (InvFull) then
begin
SetupSRL;
SPS_Setup(RUNESCAPE_SURFACE, ['0_0']);
ToBank := [Point(253, 153), Point(184, 161)];
SPS_WalkPath(ToBank);
end;
procedure BankRawLobster;
begin
WriteLn('Looking for bank.'); // Writes in the Debug Box
if FindBank('vwb') then // Finds the bank
begin
WriteLn('We have found the bank.');
if OpenBank('vwb', False, True) then // Opens the bank
begin
WriteLn('Proceeding to bank Lobs');
DepositAll; // Deposits All items in Inventory
CloseBank; // Closes the bankscreen
WriteLn('Banking completed. Proceeding to Rest.');
RestUntil(100); // Rests character
end;
end;
end;

deanironman

2012-06-26 23:04:06

Please someone help.

(s)okkr7

2012-06-26 23:11:01

If you could actually tell someone what's wrong, that'd help.

NKN

2012-06-26 23:17:39

Please post the code in Simba tabs, it makes it much easier to read.

What problems are you having?

x[Warrior]x3500

2012-06-26 23:35:46

MANY compiling issues. i would recommend skimming through the beginner tut section for all of these fixes. us just telling you them wont teach u anything, and u will keep on making the same mistakes

deanironman

2012-06-27 23:42:53

I did i followed this - http://villavu.com/forum/showthread.php?t=84726
Theres compiling errors that I dont even know.

deanironman

2012-06-27 23:44:00

if FindObj(x, y,)'in'8482403, 10),then //This will have the script find an object of your choice
syntax error. Thats just one of the mistakes..

riwu

2012-06-28 05:58:04

Fixed punctuation, syntax and standards. U still need to work out the mainloop.
program GuildFisherLobbs;                //missing semicolon
{$DEFINE SMART}
{$i srl/srl.simba}
{$i sps/sps.simba}
{const
{==========Smart Setup==========}
{World = 0; // Input the runescape world number right here for it to select. You may leave it as 0 if you would like it to select a random world.
MEMBERS = False; // Select False if you are not a member. Select True if you are a member.
SIGNED = True; // Select True if you are using single account. Select False if not.
{===============================}
//dont really need these, just set them at the mainloop, wont affect anything anyway.

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := ''; //Your Runescape username goes right here.
Players[0].Pass := ''; //Your Runescape password goes right here.
Players[0].Active := True; //Set to True if you want to use this player. Set to False to disable this player.
Players[0].Pin := ''; //Put your Bank PIN here. Leave blank if you don't have a Bank PIN.
end;

procedure Cage;
var x, y: integer;
begin
repeat //u need a repeat if u want to do a loop
if FindObj(x, y,'in',8482403, 10) then //This will have the script find an object of your choice
begin
Mouse(x, y, 0, 0, true);
ChooseOption('ine');
wait(1500+random(1000)); // This will make the script wait for a certain time
end; //and a end if u have a begin
until (InvFull);
end;

procedure WalkToBank;
var
ToBank: TPointArray; //declare ur variables
begin
if (InvFull) then
begin
//SetupSRL; do it once at the start
SPS_Setup(RUNESCAPE_SURFACE, ['0_0']);
ToBank := [Point(253, 153), Point(184, 161)];
SPS_WalkPath(ToBank);
end;
end;

procedure BankRawLobster;
begin
WriteLn('Looking for bank.'); // Writes in the Debug Box
if FindBank('vwb') then // Finds the bank
begin
WriteLn('We have found the bank.');
if OpenBank('vwb', False, True) then // Opens the bank
begin
WriteLn('Proceeding to bank Lobs');
DepositAll; // Deposits All items in Inventory
CloseBank; // Closes the bankscreen
WriteLn('Banking completed. Proceeding to Rest.');
RestUntil(100); // Rests character
end;
end;
end;

begin
Smart_Server := 1;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
DeclarePlayers;
LogInPlayer;
//the rest of ur procedures here
end.

P1ng

2012-06-28 06:51:44

Any time you post code on SRL please use
 PUT YOUR CODE IN HERE 
this will make it 100 times easier for those trying to help you read (no spaces between the simba and the square brackets).

Now, I haven't looked through your whole code, but I would start off by recommending you read alot more tutorials from the beginner and maybe even the intermediates section to try and get a grasp on what it is you are actually doing with each line.

For example -
if FindObj(x, y,)'in'8482403, 10),then

For every open parenthesis ( or [ there should be a closed parenthesis ) or ]
No more and no less.
Between each variable stated in the function (the function being FindObj in this case) there needs to be a comma , to distinguish between them.
There need be no extra commas after the function or anywhere else on the line apart from separating variables.

should be -
 if FindObj(x, y, 'in', 8482403, 10) then

I didn't scan the rest of the code but I assume there will be other similar errors and that this isn't just a one-off.

Have a look at these tutorials, they helped me out a great deal when I was starting out and they might be able to help you, too. I found myself reading these along with a few others several times before I had my first compiling script that I completely understood what was happening line-by-line.

The Beginners Simba Tutorial and SRL/Simba Standards

deanironman

2012-06-28 15:58:01

Ok now how do i make it constantly repeat that and i get another error while compiling. I press compile then a new tab comes up this to be exact-

{$DEFINE SRL_SMART}
{$DEFINE SMART};
{.loadlib libsmart}

function IsKeyDown(C:Byte): Boolean;
begin
Result := SmartIsKeyDown(C);
end;

procedure MoveMouse(x, y: Integer);
begin
SmartMoveMouse(x, y);
end;

procedure HoldMouse(x, y: Integer; button : integer);
begin
if button = mouse_left then
SmartHoldMousePlus(x,y,1)
else if button = mouse_middle then
SmartHoldMousePlus(x,y,2)
else if button = mouse_right then
SmartHoldMousePlus(x,y,3)
else
raiseexception(ercustomerror,'Unknown mouse button in SmartHoldMousePlus');
end;

procedure ReleaseMouse(x, y: Integer; button : integer);
begin
if button = mouse_left then
SmartReleaseMousePlus(x,y,1)
else if button = mouse_middle then
SmartReleaseMousePlus(x,y,2)
else if button = mouse_right then
SmartReleaseMousePlus(x,y,3)
else
raiseexception(ercustomerror,'Unknown mouse button in SmartReleaseMousePlus');
end;

procedure KeyUp(key: Byte);
begin
If Key = 13 Then
Key := 10;
SmartReleaseKey(key);
end;

procedure KeyDown(key: Byte);
begin
If Key = 13 Then
Key := 10;
SmartHoldKey(key);
end;

procedure SendKeys(S: String; keywait{$IFNDEF SIMBAMAJOR980}, keymodwait{$ENDIF}: integer);
begin
SmartSendKeys(S);
end;

function FindAndSetTarget(TitlePrefix: String; SetAsTarget: Boolean): Boolean;
var
T : TSysProcArr;
I : Integer;
begin
T := GetProcesses;
for I := High(T) downto 0 do
if Pos(TitlePrefix, T.Title) <> 0 then
begin
Result := True;
if SetAsTarget then SetTarget(T);
Exit;
end;
end;

procedure GetRealMousePos(var X, Y : Integer);
var
KMTarget, ITarget : Integer;
begin
KMTarget := GetKeyMouseTarget;
ITarget := GetImageTarget;
FindAndSetTarget('Public SMART', True);
GetTClient.IOManager.GetMousePos(X, Y);
FreeTarget(GetImageTarget);
SetKeyMouseTarget(KMTarget);
SetImageTarget(ITarget);

// These are not universial offsets, but works somewhat for some Windows themes.
X := X - 8;
Y := Y - 25;
end;

procedure GetMousePos(var x, y: Integer);
begin
SmartGetMousePos(x, y);
end;

function IsRealMouseInBox(B : TBox): Boolean;
var
P : TPoint;
begin
GetRealMousePos(P.X, P.Y);
Result := PointInBox(P, B);
end;

function GetColor(x, y: Integer): Integer;
begin
result:= SmartGetColor(x, y);
end;

procedure SmartSetTarget;
begin
SetTargetArray(SmartImageArray, 765,503);
end;

function FindWindow(Title: String): Boolean;
begin
result:= true;
end;

procedure ActivateClient;
begin
end;

function FindWindowBySize(Width, Height: Integer): Boolean;
begin
result:= true;
end;

{procedure SmartSaveSettings(v: TVariantArray);
var
i: Integer;
ts: TStringArray;
begin
ts := ['server', 'members', 'signed', 'sd', 'DC', IncludePath + 'SRL/SRL/misc/smartINI.ini'];
for i := 0 to 4 do
WriteINI('SMART', ts, v, ts[5]);
end; }

procedure SmartSetupEx(Server: integer; members, signed, superdetail: boolean);
var
prefix: string;
begin
prefix := ReadINI('World' + IntToStr(Server), 'Prefix', IncludePath + 'SRL/SRL/misc/worlds.ini');
if(prefix = '')then
begin
writeln('Invalid world number or corrupted world list. Please review your settings');
TerminateScript;
end;
SmartSetup('http://'+prefix+'.runescape.com/', 'plugin.js?param=o0,a' + IntToStr((Integer(not(Signed)) + 1) * Integer(not((SuperDetail and Signed)))) + ',m' + IntToStr(Integer(Members)), 765, 503, 's');
//SmartSaveSettings([Server, Members, Signed, SuperDetail, SmartGetDC]);
end;

{function SmartLastSettings: TStringArray;
var
i: Integer;
ts: TStringArray;
begin
ts := ['server', 'members', 'signed', 'sd', 'DC', IncludePath + 'SRL/SRL/Misc/smartINI.ini'];
SetLength(Result, 5);
for i := 0 to 4 do
Result := ReadINI('SMART', ts, ts[5]);
end; }


It says-[Error] C:\Simba\Includes\SRL/SRL/misc/smart.simba(3:16): 'BEGIN' expected at line 2
Compiling failed.

Benny

2012-06-28 16:02:39

put it like this:
{$DEFINE SRL_SMART}
{$DEFINE SMART};
{.loadlib libsmart}

function IsKeyDown(C:Byte): Boolean;
begin
Result := SmartIsKeyDown(C);
end;

procedure MoveMouse(x, y: Integer);
begin
SmartMoveMouse(x, y);
end;

procedure HoldMouse(x, y: Integer; button : integer);
begin
if button = mouse_left then
SmartHoldMousePlus(x,y,1)
else if button = mouse_middle then
SmartHoldMousePlus(x,y,2)
else if button = mouse_right then
SmartHoldMousePlus(x,y,3)
else
raiseexception(ercustomerror,'Unknown mouse button in SmartHoldMousePlus');
end;

procedure ReleaseMouse(x, y: Integer; button : integer);
begin
if button = mouse_left then
SmartReleaseMousePlus(x,y,1)
else if button = mouse_middle then
SmartReleaseMousePlus(x,y,2)
else if button = mouse_right then
SmartReleaseMousePlus(x,y,3)
else
raiseexception(ercustomerror,'Unknown mouse button in SmartReleaseMousePlus');
end;

procedure KeyUp(key: Byte);
begin
If Key = 13 Then
Key := 10;
SmartReleaseKey(key);
end;

procedure KeyDown(key: Byte);
begin
If Key = 13 Then
Key := 10;
SmartHoldKey(key);
end;

procedure SendKeys(S: String; keywait{$IFNDEF SIMBAMAJOR980}, keymodwait{$ENDIF}: integer);
begin
SmartSendKeys(S);
end;

function FindAndSetTarget(TitlePrefix: String; SetAsTarget: Boolean): Boolean;
var
T : TSysProcArr;
I : Integer;
begin
T := GetProcesses;
for I := High(T) downto 0 do
if Pos(TitlePrefix, T[I].Title) <> 0 then
begin
Result := True;
if SetAsTarget then SetTarget(T[I]);
Exit;
end;
end;

procedure GetRealMousePos(var X, Y : Integer);
var
KMTarget, ITarget : Integer;
begin
KMTarget := GetKeyMouseTarget;
ITarget := GetImageTarget;
FindAndSetTarget('Public SMART', True);
GetTClient.IOManager.GetMousePos(X, Y);
FreeTarget(GetImageTarget);
SetKeyMouseTarget(KMTarget);
SetImageTarget(ITarget);

// These are not universial offsets, but works somewhat for some Windows themes.
X := X - 8;
Y := Y - 25;
end;

procedure GetMousePos(var x, y: Integer);
begin
SmartGetMousePos(x, y);
end;

function IsRealMouseInBox(B : TBox): Boolean;
var
P : TPoint;
begin
GetRealMousePos(P.X, P.Y);
Result := PointInBox(P, B);
end;

function GetColor(x, y: Integer): Integer;
begin
result:= SmartGetColor(x, y);
end;

procedure SmartSetTarget;
begin
SetTargetArray(SmartImageArray, 765,503);
end;

function FindWindow(Title: String): Boolean;
begin
result:= true;
end;

procedure ActivateClient;
begin
end;

function FindWindowBySize(Width, Height: Integer): Boolean;
begin
result:= true;
end;

{procedure SmartSaveSettings(v: TVariantArray);
var
i: Integer;
ts: TStringArray;
begin
ts := ['server', 'members', 'signed', 'sd', 'DC', IncludePath + 'SRL/SRL/misc/smartINI.ini'];
for i := 0 to 4 do
WriteINI('SMART', ts[i], v[i], ts[5]);
end; }

procedure SmartSetupEx(Server: integer; members, signed, superdetail: boolean);
var
prefix: string;
begin
prefix := ReadINI('World' + IntToStr(Server), 'Prefix', IncludePath + 'SRL/SRL/misc/worlds.ini');
if(prefix = '')then
begin
writeln('Invalid world number or corrupted world list. Please review your settings');
TerminateScript;
end;
SmartSetup('http://'+prefix+'.runescape.com/', 'plugin.js?param=o0,a' + IntToStr((Integer(not(Signed)) + 1) * Integer(not((SuperDetail and Signed)))) + ',m' + IntToStr(Integer(Members)), 765, 503, 's');
//SmartSaveSettings([Server, Members, Signed, SuperDetail, SmartGetDC]);
end;

{function SmartLastSettings: TStringArray;
var
i: Integer;
ts: TStringArray;
begin
ts := ['server', 'members', 'signed', 'sd', 'DC', IncludePath + 'SRL/SRL/Misc/smartINI.ini'];
SetLength(Result, 5);
for i := 0 to 4 do
Result[i] := ReadINI('SMART', ts[i], ts[5]);
end; }

deanironman

2012-06-28 16:41:23

{$DEFINE SRL_SMART}
{$DEFINE SMART};
{.loadlib libsmart}

function IsKeyDown(C:Byte): Boolean;
begin
Result := SmartIsKeyDown(C);
end;

procedure MoveMouse(x, y: Integer);
begin
SmartMoveMouse(x, y);
end;

procedure HoldMouse(x, y: Integer; button : integer);
begin
if button = mouse_left then
SmartHoldMousePlus(x,y,1)
else if button = mouse_middle then
SmartHoldMousePlus(x,y,2)
else if button = mouse_right then
SmartHoldMousePlus(x,y,3)
else
raiseexception(ercustomerror,'Unknown mouse button in SmartHoldMousePlus');
end;

procedure ReleaseMouse(x, y: Integer; button : integer);
begin
if button = mouse_left then
SmartReleaseMousePlus(x,y,1)
else if button = mouse_middle then
SmartReleaseMousePlus(x,y,2)
else if button = mouse_right then
SmartReleaseMousePlus(x,y,3)
else
raiseexception(ercustomerror,'Unknown mouse button in SmartReleaseMousePlus');
end;

procedure KeyUp(key: Byte);
begin
If Key = 13 Then
Key := 10;
SmartReleaseKey(key);
end;

procedure KeyDown(key: Byte);
begin
If Key = 13 Then
Key := 10;
SmartHoldKey(key);
end;

procedure SendKeys(S: String; keywait{$IFNDEF SIMBAMAJOR980}, keymodwait{$ENDIF}: integer);
begin
SmartSendKeys(S);
end;

function FindAndSetTarget(TitlePrefix: String; SetAsTarget: Boolean): Boolean;
var
T : TSysProcArr;
I : Integer;
begin
T := GetProcesses;
for I := High(T) downto 0 do
if Pos(TitlePrefix, T.Title) <> 0 then
begin
Result := True;
if SetAsTarget then SetTarget(T);
Exit;
end;
end;

procedure GetRealMousePos(var X, Y : Integer);
var
KMTarget, ITarget : Integer;
begin
KMTarget := GetKeyMouseTarget;
ITarget := GetImageTarget;
FindAndSetTarget('Public SMART', True);
GetTClient.IOManager.GetMousePos(X, Y);
FreeTarget(GetImageTarget);
SetKeyMouseTarget(KMTarget);
SetImageTarget(ITarget);

// These are not universial offsets, but works somewhat for some Windows themes.
X := X - 8;
Y := Y - 25;
end;

procedure GetMousePos(var x, y: Integer);
begin
SmartGetMousePos(x, y);
end;

function IsRealMouseInBox(B : TBox): Boolean;
var
P : TPoint;
begin
GetRealMousePos(P.X, P.Y);
Result := PointInBox(P, B);
end;

function GetColor(x, y: Integer): Integer;
begin
result:= SmartGetColor(x, y);
end;

procedure SmartSetTarget;
begin
SetTargetArray(SmartImageArray, 765,503);
end;

function FindWindow(Title: String): Boolean;
begin
result:= true;
end;

procedure ActivateClient;
begin
end;

function FindWindowBySize(Width, Height: Integer): Boolean;
begin
result:= true;
end;

{procedure SmartSaveSettings(v: TVariantArray);
var
i: Integer;
ts: TStringArray;
begin
ts := ['server', 'members', 'signed', 'sd', 'DC', IncludePath + 'SRL/SRL/misc/smartINI.ini'];
for i := 0 to 4 do
WriteINI('SMART', ts, v, ts[5]);
end; }

procedure SmartSetupEx(Server: integer; members, signed, superdetail: boolean);
var
prefix: string;
begin
prefix := ReadINI('World' + IntToStr(Server), 'Prefix', IncludePath + 'SRL/SRL/misc/worlds.ini');
if(prefix = '')then
begin
writeln('Invalid world number or corrupted world list. Please review your settings');
TerminateScript;
end;
SmartSetup('http://'+prefix+'.runescape.com/', 'plugin.js?param=o0,a' + IntToStr((Integer(not(Signed)) + 1) * Integer(not((SuperDetail and Signed)))) + ',m' + IntToStr(Integer(Members)), 765, 503, 's');
//SmartSaveSettings([Server, Members, Signed, SuperDetail, SmartGetDC]);
end;

{function SmartLastSettings: TStringArray;
var
i: Integer;
ts: TStringArray;
begin
ts := ['server', 'members', 'signed', 'sd', 'DC', IncludePath + 'SRL/SRL/Misc/smartINI.ini'];
SetLength(Result, 5);
for i := 0 to 4 do
Result := ReadINI('SMART', ts, ts[5]);
end; }
-[Error] (3:16): 'BEGIN' expected at line 2
Compiling failed..
Help? Please try compiling it yourself and see if its working because this is just throwing me off completely

P1ng

2012-06-28 20:56:17

Please post the actual code you have written here since editing it (i assume you implemented my suggestion throughout the code?) I can run through the script and edit your standards and fix up lines of code like in my last post, but if you read the tutorials I linked you to you will be able to do it yourself.

So far you are posting the include that the script is having an error with, post your script instead as I'm sure the include is not the problem

riwu

2012-06-29 02:25:37

All the codes u posted have no mainloop, i have added it for u in Post#8 but u did not use it.
A mainloop is…the most crucial part of ur script that determines what ur script is going to do, and in what order, it looks like this:

program new;
{$DEFINE SMART}
{$i srl/srl.simba}
{$i sps/sps.simba}

procedure a;
begin
action1;
end;

procedure b;
begin
action2;
end;

//and so on...
//all ur tons of procedures must be placed in between the program and the mainloop

begin //here is the mainloop, notice that the mainloop does not have a "procedure name", it begins with a "begin".
Smart_Server := 1;
Smart_Members := True;
Smart_Signed := True; //all these are basic procedures that almost every script has
Smart_SuperDetail := False; //and is added at the start of the main loop
SetupSRL;
DeclarePlayers;
LogInPlayer;

repeat //after all the basic procedures, put ur custom procedures in the order that u want it to perform
b;
a;
until (AllPlayersInactive);

end. //and it ends with a fullstop rather than semicolon

deanironman

2012-06-29 13:33:36

This is so complicated lol i dont know how you guys do this XD. I am so confused.

deanironman

2012-06-29 13:38:00

So is everything i did wrong because all i wanted is for the script to fish lobsters than drop…..

x[Warrior]x3500

2012-06-29 13:47:50

well everything was fixed for u above by riwu. now u have to finish the script (main loop).

Brandon

2012-06-29 14:00:19

Your script is a bit primitive in that it has no failsafes really. Also you shouldn't SetupSPS in a function like that.
SetupSPS after SetupSRL; That way it doesn't keep setting up if you placed that function in a loop.

To use Simba tags type
  Place your code here.. then type 
. Remove the Spaces inbetween the Simba brackets. These are BBCodes.


procedure Cage;
var x, y: integer;
begin
repeat //u need a repeat if u want to do a loop
if FindObj(x, y,'in',8482403, 10) then //This will have the script find an object of your choice
begin
Mouse(x, y, 0, 0, true);
ChooseOption('ine');
wait(1500+random(1000)); // This will make the script wait for a certain time
end; //and a end if u have a begin
until (InvFull);
end;

procedure WalkToBank;
var
ToBank: TPointArray; //declare ur variables
begin
if (InvFull) then
begin
ToBank := [Point(253, 153), Point(184, 161)];
SPS_WalkPath(ToBank);
end;
end;

procedure BankRawLobster;
begin
WriteLn('Looking for bank.'); // Writes in the Debug Box
if FindBank('vwb') then // Finds the bank
begin
WriteLn('We have found the bank.');
if OpenBank('vwb', False, True) then // Opens the bank
begin
WriteLn('Proceeding to bank Lobs');
DepositAll; // Deposits All items in Inventory
CloseBank; // Closes the bankscreen
WriteLn('Banking completed. Proceeding to Rest.');
RestUntil(100); // Rests character
end;
end;
end;

begin
Smart_Server := 1;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
SPS_Setup(RUNESCAPE_SURFACE, ['0_0']);
DeclarePlayers;
LogInPlayer;

Repeat
//Place all the functions you want to run over and over here.. This is known as the main loop.
Cage;
WalkToBank;
BankRawLobster;
Until(AllPlayersInActive);
end.