SRL Archive - OSR Help

Type mismatch at line ***


TehNeonFishy

2012-06-10 19:01:56

So I'm following YoHoJo's guide video 2 part 1 and I ran into this error even though my code is exactly the same as his. The error is

[Error] (108:3): Type mismatch at line 107
Compiling failed.


Line 107 is the 'End;' underneath the invcount part. I've tried searching for an answer but to no avail, anyone have any ideas?

Program PowerChopper;

//{$DEFINE SMART}
{$i SRL\SRL.simba}
//{$i SRL\SRL\Misc\Stats.simba}

Const
SRLStats_Username = '';
SRLStats_Password = '';
BreakEvery = 120;
BreakFor = 5;
Version = '1.0';
NumbOfPlayers = 1;
StartPlayer = 0;

procedure DeclarePlayers;
var i:integer;
begin
NumberOfPlayers(NumbOfPlayers);
CurrentPlayer := StartPlayer;
for i := 0 to NumbOfPlayers-1 do
Players[i].BoxRewards := ['XP'];

with Players[0] do
begin
Name := '';
Pass := '';
Active := True;
end;

end;

Procedure StatsGuise (wat:String);
Begin
Status(wat);
Disguise(wat);
End;

Function CheckAndClick(UpText, Option:String; X,Y:Integer; RClick:Boolean):Boolean;
Begin
MMouse(x, y, 5, 5);
If WaitUptext(UpText, 1500+Random(500)) Then
Begin
Result:= True;
GetMousePos(x, y);
If RClick Then
Begin
Mouse(x, y, 0, 0, False);
Result:= WaitOption(Option, 2000);
If Result Then FFlag(0);
End Else
Begin
Mouse(x, y, 0, 0, True);
Wait(100+Random(50));
FFLag(0);
End;
End;
End;

Procedure Antiban;
Begin
Case Random(250) Of
0: Begin StatsGuise('AntiBan') GameTab(tab_Stats) HoverSkill('Woodcutting', False) GameTab(28) End;
1: Begin StatsGuise('AntiBan') SleepAndMoveMouse(7000 + Random(500)); End;
2: Begin StatsGuise('AntiBan') GameTab(tab_Inv) ExamineInv; GameTab(28); End;
3: Begin StatsGuise('AntiBan') RandomAngle(1); End;
4: Begin StatsGuise('AntiBan') GameTab(tab_Stats); Wait(3000 + Random(500)); GameTab(28) End;
5: Begin StatsGuise('AntiBan') GameTab(tab_Stats) HoverSkill('random', False); GameTab(28) End;
End;
End;

Procedure FailSafe(Reason:String);
Begin
Players[CurrentPlayer].Loc:=Reason;
Logout;
Stats_Commit;
//ProgressReport;
TerminateScript;
End;

Function ChopTree:Boolean;
Var
seX, seY, PlusOne, TreeCounter:Integer;
Begin
PlusOne := InvCount +1;
If FindObjCustom(seX, seY, ['Chop', 'down', 'p d'], [1581857, 1450014, 1912107, 1318172], 10) Then
Begin
StatsGuise('Tree sighted.');
GetMousePos(seX, seY);

Case Random(2) Of
1: Mouse(seX, seY, 5, 5, 1);
2: Begin
Mouse(seX, seY, 5, 5, 0);
WaitOption('Chop', 500);
End;
End;

Repeat
MarkTime(TreeCounter)
Antiban;
Wait(100);
If InvCount=PlusOne Then
Writeln('We got one');
Until InvCount=PlusOne Or TimeFromMark(TreeCounter) > 7000

End;
End;





Begin
SetupSRL;
DeclarePlayers;
Repeat
ChopTree;
Until(false);
End.

CephaXz

2012-06-10 19:04:11

Probably because of this line:

Until (InvCount=PlusOne) Or (TimeFromMark(TreeCounter) > 7000);

EDIT: Put your MarkTime(TreeCounter) outside of repeat..until

TehNeonFishy

2012-06-10 19:06:27

Ah nice, how the hell did I miss that.

Thanks :D

CephaXz

2012-06-10 19:08:08

Good luck following the tutorial and scripting :D

TehNeonFishy

2012-06-10 19:33:07

Thanks :D

With the same code I get a "Exception: Range check error at line 286" after it's chopped the tree and the invcount should go up. It also opens up a inventory tab in Simba and points to ExistsItem, any ideas on what is causing that? =/

CephaXz

2012-06-10 19:34:24

Could you post the full script?

TehNeonFishy

2012-06-10 19:39:06

I believe it's something to do with InvCount as ExistsItem is called for the count as far as I can gather.

Program PowerChopper;

//{$DEFINE SMART}
{$i SRL\SRL.simba}
//{$i SRL\SRL\Misc\Stats.simba}

Const
SRLStats_Username = '';
SRLStats_Password = '';
BreakEvery = 120;
BreakFor = 5;
Version = '1.0';
NumbOfPlayers = 1;
StartPlayer = 0;

procedure DeclarePlayers;
var i:integer;
begin
NumberOfPlayers(NumbOfPlayers);
CurrentPlayer := StartPlayer;
for i := 0 to NumbOfPlayers-1 do
Players[i].BoxRewards := ['XP'];

with Players[0] do
begin
Name := '';
Pass := '';
Active := True;
end;

end;

Procedure StatsGuise (wat:String);
Begin
Status(wat);
Disguise(wat);
End;

Function CheckAndClick(UpText, Option:String; X,Y:Integer; RClick:Boolean):Boolean;
Begin
MMouse(x, y, 5, 5);
If WaitUptext(UpText, 1500+Random(500)) Then
Begin
Result:= True;
GetMousePos(x, y);
If RClick Then
Begin
Mouse(x, y, 0, 0, False);
Result:= WaitOption(Option, 2000);
If Result Then FFlag(0);
End Else
Begin
Mouse(x, y, 0, 0, True);
Wait(100+Random(50));
FFLag(0);
End;
End;
End;

Procedure Antiban;
Begin
Case Random(250) Of
0: Begin StatsGuise('AntiBan') GameTab(tab_Stats) HoverSkill('Woodcutting', False) GameTab(28) End;
1: Begin StatsGuise('AntiBan') SleepAndMoveMouse(7000 + Random(500)); End;
2: Begin StatsGuise('AntiBan') GameTab(tab_Inv) ExamineInv; GameTab(28); End;
3: Begin StatsGuise('AntiBan') RandomAngle(1); End;
4: Begin StatsGuise('AntiBan') GameTab(tab_Stats); Wait(3000 + Random(500)); GameTab(28) End;
5: Begin StatsGuise('AntiBan') GameTab(tab_Stats) HoverSkill('random', False); GameTab(28) End;
End;
End;

Procedure FailSafe(Reason:String);
Begin
Players[CurrentPlayer].Loc:=Reason;
Logout;
Stats_Commit;
//ProgressReport;
TerminateScript;
End;

Function ChopTree:Boolean;
Var
seX, seY, PlusOne, TreeCounter:Integer;
Begin
PlusOne := InvCount +1;
If FindObjCustom(seX, seY, ['Chop', 'down', 'p d'], [1581857, 1450014, 1912107, 1318172], 10) Then
Begin
StatsGuise('Tree sighted.');
GetMousePos(seX, seY);

Case Random(2) Of
1: Mouse(seX, seY, 5, 5, True);
2: Begin
Mouse(seX, seY, 5, 5, False);
WaitOption('Chop', 500);
End;
End;

Repeat
MarkTime(TreeCounter)
Antiban;
Wait(100);
If InvCount=PlusOne Then
Writeln('We got one');
Until (InvCount=PlusOne) Or (TimeFromMark(TreeCounter) > 7000);

End;
End;

Begin
SetupSRL;
DeclarePlayers;
Repeat
ChopTree;
Until(false);
End.

CephaXz

2012-06-10 19:48:09

I tried it out with smart, and it works fine for me. Maybe you need to update simba, not sure though.

TehNeonFishy

2012-06-10 19:49:34

My java is old, version 6 update 30 or something, but that was because I read the newest java could cause problems. I'll edit after I update Java and see if that's the problem.

CephaXz

2012-06-10 19:50:56

From: TehNeonFishy
My java is old, version 6 update 30 or something, but that was because I read the newest java could cause problems. I'll edit after I update Java and see if that's the problem.


Don't update Java. Just try updating simba or srl and see if there's a new update.

TehNeonFishy

2012-06-10 19:53:24

Nope, no updates available for anything. Trying the script on SMART now, it's the only other thing I could think of.

CephaXz

2012-06-10 19:55:41

Make the tree chopping into a procedure instead of function.


Procedure ChopTree;
Var
seX, seY, PlusOne, TreeCounter:Integer;
Begin
PlusOne := InvCount +1;
If FindObjCustom(seX, seY, ['Chop', 'down', 'p d'], [1581857, 1450014, 1912107, 1318172], 10) Then
Begin
StatsGuise('Tree sighted.');
GetMousePos(seX, seY);

Case Random(2) Of
1: Mouse(seX, seY, 5, 5, True);
2: Begin
Mouse(seX, seY, 5, 5, False);
WaitOption('Chop', 500);
End;
End;

Repeat
MarkTime(TreeCounter)
Antiban;
Wait(100);
If InvCount=PlusOne Then
Writeln('We got one');
Until (InvCount=PlusOne) Or (TimeFromMark(TreeCounter) > 7000);

End;
End;

And I got this from searching the forum
Error: Out Of Range at line 2XXX
I'm not sure why this happens, but go to your MSI folder (Simba/Includes/MSI) and delete your Player.txt file and try again. Everything should work fine.


Btw, if you use smart and want to login automatically. You need to fill up the user and pass. And add LoginPlayer; after declareplayers

TehNeonFishy

2012-06-10 20:05:02

Have done, on the deleting Players.txt part, I don't even seem to have that file.

EDIT: and now my Simba crashes after running the script. =/
Thanks for the login code, was trying to figure it out. xD

Is there a way to detect if SMART is already open?

CephaXz

2012-06-10 20:08:52

Oh well. Maybe wait for someone that knows about this error then. Have no idea what is it since it's not happening to me. Have to go back to studies now. Good luck :p

TehNeonFishy

2012-06-10 20:14:04

No problem, turns out it works in SMART anyway. It's just when in a browser.

Thanks for your help and good luck with your studies. :D