Log in

View Full Version : Access Violation Help



Timothegreat
07-23-2011, 05:44 PM
I get an access violation right after running this procedure. I am wondering if anyone has any insight into what may cause this

This is inside one of my personal reflection scripts that is properly setup and has all includes declared

procedure RightClickHuman;
var
Humans: TPlayerArray;
HumanTile: TTile;
HumanPos: TPoint;
ChooseOne: integer;
begin
if not LoggedIn then exit;
Humans:= GetAllPlayers;
Humans:= SortPlayers(Humans);
if (Humans[0] = NULL_PLAYER)then exit;
for ChooseOne:= 0 to High(Humans)do
begin
HumanTile:= Humans[ChooseOne].Tile;
if TileOnMS(HumanTile,0)then break;
end;
HumanPos:= TileToMS(HumanTile,0);
if not(Distance(HumanPos.X,HumanPos.Y,0,0) < 10)then
begin
Mouse(HumanPos.X,HumanPos.Y,4,4,False);
wait(500+random(500));
end;
if (Random(1) = 0) then
begin
SleepAndMoveMouse(500+random(500));
end;
end;

Thanks!


Edit: Got new info about it... only happens when run at the beginning of a script it seems

Brandon
07-23-2011, 05:56 PM
Umm this happens alot with reflection 2.. Example of the error I always get!



R_ClickInterface(R_GetChildInterface(Parent, Child), 1); //This will give the error your getting..

ChildInterface:= R_GetChildInterface(Parent, Child); //Splitting the functions into two parts fixes this error..
R_ClickInterface(ChildInterface, 1);
That is how I usually fix these errors.. I split the functions and then I call one inside the other.. Reason I do this is because in C++, you can't *declare* a function inside a function which you might be doing so I guess simba gives an error for that.

Try declaring a different variable instead of using Humans:= SortPlayers(Humans).. try GroupPlayers:= SortPlayers(Humans)..

Etc.. Stuff like that fixes it.

Edit: I Figured out why u get that error at the beginning of a script.. You have to include these and do this:



{.include SRL\SRL\misc\SMART.SCAR}
{.include SRL\SRL.scar}
{.include reflection\reflection.simba}

procedure RightClickHuman;
var
Humans: TPlayerArray;
HumanTile: TTile;
HumanPos: TPoint;
ChooseOne: integer;
begin
if not LoggedIn then exit;
Humans:= GetAllPlayers;
Humans:= SortPlayers(Humans);
if (Humans[0] = NULL_PLAYER)then exit;
for ChooseOne:= 0 to High(Humans)do
begin
HumanTile:= Humans[ChooseOne].Tile;
if TileOnMS(HumanTile,0)then break;
end;
HumanPos:= TileToMS(HumanTile,0);
if not(Distance(HumanPos.X,HumanPos.Y,0,0) < 10)then
begin
Mouse(HumanPos.X,HumanPos.Y,4,4,False);
wait(500+random(500));
end;
if (Random(1) = 0) then
begin
SleepAndMoveMouse(500+random(500));
end;
end;

begin
//When you don't setup reflection and servers n stuff, you get that smart error you got on line 82.
Smart_Server := 131;
Smart_Members := True;
Smart_Signed := True;
SetupSRL;
SetupReflectionEx(True);
if not(RSReady)then
Repeat
wait(5000);
Until(RSReady);

RightClickHuman;

end.

Timothegreat
07-23-2011, 06:01 PM
Thanks! that seems to have fixed it lol, seems simple but stupid if you ask me


What should i use for the height of a tile for a NPC or player?