Log in

View Full Version : Exception in Script: Access violation



Silent
07-10-2011, 06:05 AM
So I finally started making my first script. It's going to be a smither, but I haven't even gotten very far and I'm getting an Access Violation. I searched the forums before posting this, but I didn't find anything that helped. :(

Here is my code:
program GeneralSmith;
{$i srl/srl/misc/smart.scar}
{$i srl/srl.scar}
{$i SRL/SRL/core/SPS/SPS.simba}

procedure DeclarePlayers;
begin
HowManyPlayers := 1; //Set total amount of players
NumberOfPlayers(HowManyPlayers); // SRL procedure. Don't touch.
CurrentPlayer := 0; // Player to start with, should always be 0.

Players[0].Name := ''; // Username
Players[0].Pass := ''; // Password
Players[0].Nick := ''; // 3-4 lowercase letters from username; used for random event detection
Players[0].Active := True; // Set to true if you want to use Player 0
Players[0].Pin := ''; // Leave blank if the player doesn't have a bank pin
end;
procedure WalkingFrom(SPS_WalkPath: TPointArray);
var
BankToanvil: TPointArray;
BankToGe: TPointArray;

begin
SPS_Areas :=['10_2', '10_3'];
BankToAnvil := [Point(4378, 1360), Point(4374, 1398)];
BankToGe:= [Point(4378, 1360), Point(4371, 1315),
Point(4333, 1302), Point(4304, 1283),
Point(4285, 1256), Point(4285, 1200),
Point(4281, 1165), Point(4289, 1153)];
begin
case WalkingFrom(SPS_WalkPath) of
BankToAnvil:
begin
Writeln('To the Anvil!');
SPS_WalkPath(BankToAnvil);
Writeln('Made it...');
else
Writeln('Blast walking failed.')
Exit;
end
end
end

begin
// Setting up SMART
Smart_Server := 152;
Smart_Members := False;
Smart_Signed := True;
Smart_SuperDetail := False;

ClearDebug;
SetupSRL;
DeclarePlayers; // Calling players
LoginPlayer; // Logging in...
end.

I realize I'm probably just using something wrong, but I'm still pretty new to this. The error I get in the debug is simply:

Exception in Script: Access violation
Help? If it's just a stupid mistake I made feel free to point it out quickly. I don't mind if people are harsh, I just want to figure this out and get it resolved.

KingKong
07-10-2011, 06:41 AM
change this line: procedure WalkingFrom(Path: String);

and it should be 'BankToAnvil' (notice the quotes)

TomTuff
07-10-2011, 06:44 AM
your case statement is missing an end.

KingKong
07-10-2011, 06:46 AM
your case statement is missing an end.

^ that too, and also since you're using only two paths, you should stick with the if...else statement.

Silent
07-10-2011, 06:55 AM
change this line: procedure WalkingFrom(Path: String);

and it should be 'BankToAnvil' (notice the quotes)
Thank you. I knew it was something stupid


your case statement is missing an end.
:duh:


^ that too, and also since you're using only two paths, you should stick with the if...else statement.

Good idea. I'm still having a little trouble with this, so I'll probably just go back to that until it gets bigger, if it does that is.

masterBB
07-10-2011, 11:27 AM
You should also put ; after every end, else your code won't compile. Also there were some mistakes. Don't have a pc with simba right now, so couldn't test but this would be more logical:

procedure WalkingFrom(Path: String);
var
BankToanvil: TPointArray;
BankToGe: TPointArray;

begin
SPS_Areas :=['10_2', '10_3'];
BankToAnvil := [Point(4378, 1360), Point(4374, 1398)];
BankToGe:= [Point(4378, 1360), Point(4371, 1315),
Point(4333, 1302), Point(4304, 1283),
Point(4285, 1256), Point(4285, 1200),
Point(4281, 1165), Point(4289, 1153)];
if(Path = 'BankToAnvil') then
begin
Writeln('To the Anvil!');
if(SPS_WalkPath(BankToAnvil)) then
Writeln('Made it...')
else
begin
Writeln('Blast walking failed.');
Exit;
end;
end else
writeln('the path wasn`t BankToAnvil...');
end;

Notice the changes? If you have any questions feel free to ask them here.