Bonfield
2008-10-09 20:13:28
hi i am trying to make a script that train mage, range and combat at the tutors in lumbridge
so far i have created the magic part but i have a problem where everything id fine for the first player but when the second player logs in for some reason it doesnt claim the runes causeing the script to mess up, i have been looking for this error for the past 2 days and i cant find it so i thought i would ask for some help
anyways here is the script
so far i have created the magic part but i have a problem where everything id fine for the first player but when the second player logs in for some reason it doesnt claim the runes causeing the script to mess up, i have been looking for this error for the past 2 days and i cant find it so i thought i would ask for some help
anyways here is the script
program New;
{.Include SRL\SRL\Misc\Smart.Scar}
{.Include SRL\SRL.Scar}
{.Include SRL\SRL\Reflection\Reflection.Scar}
const
WorldToUse = 108;
MouseSpeedz = 15;
VersionNumber = 1;
DebugScript = true;
var
x, y, AttDummy, LvlsGained, p: Integer;
procedure DeclarePlayers;
begin
SRLID := 'srlid';
SRLPassword := 'pass';
HowManyPlayers := 5;
CurrentPlayer := 1;
NumberOfPlayers(HowManyPlayers);
Players[0].Name := 'user';
Players[0].Pass := 'pass';
Players[0].Nick := 'nick';
Players[0].Active := True;
end;
procedure AntiBan; forward;
procedure Proggie; forward;
Procedure SaveScreenshotEx(s : string); // credits to mastaraymond
var
TempBMP : integer;
TempS : String;
begin;
Temps := s;
While FileExists(Temps) do
begin;
Temps := ExtractFilePath(s) + Copy(ExtractFileName(Temps),1,LastPos('.',ExtractFileName(Temps))-1) + '2' + ExtractFileExt(s);
Writeln(Temps);
end;
TempBMP := BitmapFromString(765,503,'');
Try
CopyClientToBitmap(TempBMP,0,0,765,503);
SaveBitmap(TempBMP, Temps);
Except
end;
FreeBitmap(TempBMP);
end;
procedure LvlUp;
{var
PhotoNum: integer; }
begin
if not (LoggedIn) then Exit;
begin
if FindNPCChatText('just advanced', Nothing) then
{begin
for PhotoNum := 1 to 100 do
if not FileExists(ScriptPath + 'Level Up ' + IntToStr(PhotoNum) + '.bmp') then
begin
SaveScreenshotEx(ScriptPath + 'Level Up ' + IntToStr(PhotoNum) + '.bmp');
writeln('screenshot save at'+ScriptPath + 'Level Up ' + IntToStr(PhotoNum) + '.bmp');
end;
end; }
Inc(LvlsGained);
inc(reportVars[2]);
end;
end;
function LoadTutorPath: TPointArray;
begin
case Random(10) of
0: Result := [Point(3222, 3217), Point(3235, 3221), Point(3227, 3232),
Point(3221, 3243), Point(3212, 3249)];
1: Result := [Point(3222, 3217), Point(3236, 3217), Point(3234, 3230),
Point(3222, 3240), Point(3213, 3247), Point(3212, 3249)];
2: Result := [Point(3222, 3217), Point(3234, 3221), Point(3229, 3233),
Point(3221, 3247), Point(3212, 3249)];
3: Result := [Point(3221, 3217), Point(3236, 3223), Point(3224, 3233),
Point(3221, 3247), Point(3212, 3249)];
4: Result := [Point(3221, 3217), Point(3236, 3220), Point(3227, 3233),
Point(3220, 3247), Point(3212, 3250)];
5: Result := [Point(3222, 3217), Point(3236, 3220), Point(3228, 3233),
Point(3218, 3245), Point(3212, 3249)];
6: Result := [Point(3221, 3218), Point(3231, 3217), Point(3234, 3228),
Point(3223, 3237), Point(3219, 3246), Point(3212, 3249)];
7: Result := [Point(3221, 3217), Point(3235, 3217), Point(3231, 3231),
Point(3221, 3241), Point(3212, 3249)];
8: Result := [Point(3222, 3218), Point(3236, 3222), Point(3224, 3232),
Point(3222, 3245), Point(3212, 3250)];
9: Result := [Point(3222, 3218), Point(3236, 3215), Point(3230, 3230),
Point(3221, 3243), Point(3212, 3249)];
end;
end;
function WalkToPathTile(Tile: TPoint; Randomness: Integer): boolean;
var
wTile: TPoint;
t: Integer;
begin
if not LoggedIn then Exit;
Tile.X := RandomRange(Tile.X - Randomness, Tile.X + Randomness);
Tile.Y := RandomRange(Tile.Y - Randomness, Tile.Y + Randomness);
wTile := TileToMM(Tile);
while not TileOnMM(Tile) do
Wait(100 + Random(200));
if not TileOnMM(Tile) then
begin
Result := False;
Writeln('Tile not on MM!');
Exit;
end;
Result := True;
Mouse(wTile.x, wTile.y, 0, 0, true);
t := getsystemtime;
Result := (GetSystemTime - t) < 60000;
end;
function WalkPath(Path: TPointArray; FlagDist: Integer): boolean;
var
i: integer;
begin
if not LoggedIn then Exit;
if not WalkToPathTile(Path[i], 2) then
Exit;
for i := 0 to High(Path) do
begin
if i < High(Path) then
begin
while not TileOnMM(Point(Path[i + 1].x, Path[i + 1].y)) do
Wait(100 + Random(100));
Wait(200 + Random(700));
WalkToPathTile(Path[i + 1], 1);
end
else
FFlag(FlagDist);
Wait(400 + Random(200));
end;
result := true;
end;
function InLumby: boolean;
var
x, y, WallColorDTM, WaterSymbolColor, WallColor: integer;
begin
if not (LoggedIn) then Exit;
if not (WaterSymbolColor > 0) then
begin
if FindSymbol(x, y, 'water') then
begin
WaterSymbolColor := GetSymbolColor(x, y, 'water');
Wait(1000);
result := InLumby;
Exit;
end
else
begin
result := false;
Exit;
end;
end;
if FindColor(x, y, WaterSymbolColor, MMX1, MMY1, MMX2, MMCY) then
if FindColor(x, y, WaterSymbolColor, MMX1, MMCY, MMX2, MMY2) then
begin
result := true;
if (WallColor = 0) or (not (FindColor(x, y, WallColor, MMX1, MMY1, MMX2, MMY2))) then
begin
WallColorDTM:=DTMFromString('78DA632C64626098C580025EBF7CCB6004A41' +
'981F83F103082D4CC46555394950557030260357388503317554D' +
'A18D08A69A794498339F0873161061CE42FCE60000BBA7183D');
if FindDTM(WallColorDTM, x, y, MMX1, MMY1, MMX2, MMY2) then
begin
WallColor := GetColor(x, y);
end;
FreeDTM(WallColorDTM);
end;
end;
end;
function ToTutor: boolean;
begin
if not LoggedIn then Exit;
LoadTutorPath Result := WalkPath(LoadTutorPath, 10);
AntiBan;
FindNormalRandoms;
if Result then
Writeln('Walked to Tutor!');
end;
procedure ClaimRunes;
var
TheNPC: TNPC;
P: TPoint;
begin
if not LoggedIn then Exit;
MakeCompass('E');
GameTab(4);
FindNPC('Magic Tutor', TheNPC) P := TheNPC.MS;
Mouse(P.x, P.y, 5, 5, false);
wait(200 + random(100) +randomrange(10,70));
ChooseOption('laim');
wait(randomrange(600,1800)+ random(1200)+ random(45));
ClickToContinue;
if FindNPCChatText('work with the', true) then
begin
Writeln('Cannot Claim Runes');
repeat
Wait(1000);
until not(LoggedIn)
nextplayer(true);
proggie;
end;
AntiBan;
FindNormalRandoms;
end;
function FindDummy(var fx, fy: Integer): boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
i, j, arL, arL2: Integer;
P: TPoint;
R, G, B: Integer;
H, S, L: Extended;
X, Y, Z: Extended;
begin
if not LoggedIn then Exit;
if not (FindColorsTolerance(arP, 9072991, MSX1, MSY1, MSX2, MSY2, 43)) then
begin
Writeln('Failed to Find the Color of the Dummy.');
Exit;
end;
arC := GetColors(arP);
arUC := arC;
ClearSameIntegers(arUC);
arL := High(arUC);
arL2 := High(arC);
for i := 0 to arL do
begin
ColorToRGB(arC[i], R, G, B);
if (R >= 74) and (R <= 115) and (G >= 88) and (G <= 137) and (B >= 108) and (B <= 167) then
begin
ColorToHSL(arC[i], H, S, L);
if (H >= 59.36) and (H <= 59.94) and (S >= 18.46) and (S <= 22.63) and (L >= 36.06) and (L <= 54.92) then
begin
ColorToXYZ(arC[i], X, Y, Z);
if (X >= 9.21) and (X <= 22.64) and (Y >= 9.72) and (Y <= 23.96) and (Z >= 15.84) and (Z <= 39.51) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;
end;
end;
SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 10, 10);
arL := High(ararP);
for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then
Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
if (IsUpText('Attack')) then
begin
Result := True;
Break;
end;
end;
if (i = arL + 1) then
begin
Writeln('Could not Find Dummy.');
Exit;
end;
GetMousePos(fx, fy);
end;
procedure AttackDummy;
begin
if not LoggedIn then Exit;
repeat
FindDummy(x, y);
Mouse(x, y, 10, 10, true);
LvlUp;
FindNormalRandoms;
AntiBan;
if FindBlackChatMessage('can only use Magic') then
begin
Writeln('error with runes');
repeat
Wait(1000);
until not(LoggedIn)
nextplayer(true);
proggie;
end;
until (FindBlackChatMessage('do not have enough'));
Writeln('Ran out of Runes Next Player');
begin
repeat
Wait(1000);
until not(LoggedIn);
nextplayer(true);
end;
ReportVars[0]:=ReportVars[0] + 30;
AttDummy := AttDummy + 30;
SRLRandomsReport;
Proggie;
end;
function NeedToTeleportHome: boolean;
begin
if not (LoggedIn) then exit;
if not (inlumby) then result := true;
end;
procedure TeleportHome;
var
TheNPC: TNPC;
begin
GameTab(7);
Wait(200 + Random(500));
MouseBox(563, 231, 577, 246, 1);
FindNormalRandoms;
Wait((RandomRange(1000, 4575)) + Random(2500)+Random(40))
if FindBlackChatMessage('need to Wait') then
begin
Writeln('need to wait longer until teleport');
begin
repeat
Wait(1000);
until not(LoggedIn);
end;
Proggie;
end;
end;
function AutoCastSpell: string; // credits to lee lok hin for help
var
TBmp, x, y: integer;
begin
if not (LoggedIn) then Exit;
for p := 2 downto 0 do
begin
try
FreeBitmap(TBmp);
except
end;
case p of
2: TBmp:= BitmapFromString(5, 5, 'z78DA65CC410EC0200' +
'844D12B0D65602F7AFF33D9D659B4CA8290F7131CDD1C6019A81D' +
'1E083C637FCF7EFBB74A760FB279490E575D1F9627072FD5F79EF' +
'44D1E8E');
1: TBmp:= BitmapFromString(5, 5, 'z78DA65C9310EC0200' +
'C43D12B252410757453B8FF911072874878F8C333805C1908AC87' +
'6D22C89033AD6E6A3A677D29B7F7E19F37CAED2CE57777D85BDF0' +
'DC1282049');
0: TBmp:= BitmapFromString(8, 8, 'z78DA333531713476323533' +
'713131320001434C12226B0A56892C6E0184E62E9824B22E4C592' +
'76767236703641259172E35B874E19275730542174CF5A49A4FAA' +
'FB49081F70780200F1E3548A');
end;
GameTab(1);
MouseBox(653, 315, 715, 351, 1);
Wait(random(1000))
if (not FindBitmapToleranceIn(Tbmp, x, y, MIX1, MIY1, MIX2, MIY2, 50)) then
if P = 0 then
Exit
else
continue;
case p of
2: Result := 'earth strike';
1: Result := 'water strike';
0: Result := 'wind strike';
end;
Writeln(inttostr(p)) if p = 0 then
begin
Writeln('using wind strike') MouseBox(576, 234, 588, 243, 1);
Exit;
Wait(1000 + Random(500));
end;
if p = 1 then
begin
Writeln('using water strike') MouseBox(617, 235, 629, 246, 1);
Exit;
Wait(1000 + Random(500));
end;
if p = 2 then
begin
Writeln('using earth strike') MouseBox(657, 235, 670, 245, 1);
Exit;
Wait(1000 + Random(500));
end;
Wait((RandomRange(250, 1750)) + Random(1500))
end;
FreeBitmap(TBmp);
end;
procedure StaffCheck;
begin
end;
function GameTabEx(tabnumber: Integer): boolean;
var
c, t, tx, ty: Integer;
begin
if not (LoggedIn) then Exit;
if ((Tabnumber < 1) or (TabNumber > 15)) then
begin
srl_Warn('GameTab', IntToStr(tabnumber) + ' is not a valid GameTab', warn_AllVersions);
Result := False;
Exit;
end;
if not TabExists(tabnumber) then
begin
Result := False;
Exit;
end;
if tabnumber <> GetCurrentTab then
case Tabnumber of
1: MouseBox(528, 171, 554, 198, 3);
2: MouseBox(564, 171, 589, 198, 3);
3: MouseBox(598, 171, 622, 198, 3);
4: MouseBox(630, 171, 653, 198, 3);
5: MouseBox(663, 171, 687, 198, 3);
6: MouseBox(696, 171, 720, 198, 3);
7: MouseBox(729, 171, 760, 198, 3);
8: MouseBox(564, 469, 590, 499, 3);
9: MouseBox(597, 469, 622, 499, 3);
10: MouseBox(629, 469, 656, 499, 3);
11: MouseBox(662, 469, 689, 499, 3);
12: MouseBox(696, 469, 721, 499, 3);
13: MouseBox(729, 469, 758, 499, 3);
14: MouseBox(743, 3, 762, 23, 3);
15: MouseBox(527, 469, 555, 499, 3);
end;
while not (GetCurrentTab = tabnumber) and (c < 4) do
begin
GetMousePos(tx, ty);
Mouse(tx, ty, 0, 0, True);
Inc(c);
Wait(Random(100));
end;
t := GetCurrentTab;
Result := (t = tabnumber);
if t <> Tabnumber then
srl_Warn('GameTab', 'Failed to switch to tab ' + IntToStr(tabnumber), warn_AllVersions);
end;
procedure AntiBan; //credits to Hy
var
opx, opy, Deg, mousx, mousy, mx, my: integer;
CombatSkillz: TStringArray;
LolSkill: string;
begin
if not LoggedIn then Exit;
CombatSkillz := ['attack', 'strength', 'defence', 'magic', 'Range', 'hitpoints'];
LolSkill := CombatSkillz[Random(high(CombatSkillz))];
case Random(150) of
0, 6, 8, 12, 13, 18, 28, 38, 48:
begin
if Random(30) >= 2 then
IdleTime(500 + Random(500), 500, 0.4)
else if Random(4) <> 0 then
MMouse(Random(766), Random(504), 0, 0)
else
SleepAndMoveMouse(500 + Random(3000));
GetMousePos(mousx, mousy);
Wait(60 + Random(60));
if Random(3) <> 0 then
begin
if IsUpText('ptions') then
begin
GetMousePos(opx, opy);
Mouse(opx, opy, 0, 0, False);
if ChooseOption('xamine') then
end;
end;
end;
2:
begin
if Random(20) = 0 then
HoverSkill(LolSkill, False)
else
HoverSkill('Random', False);
end;
7, 11:
begin
MouseSpeed := MouseSpeedz + Random(5) - Random(5);
Writeln('MouseSpeed changed to: ' + IntToStr(MouseSpeed) + '.');
end;
9:
begin
FTWait(RandomRange(1, 30));
end;
10:
begin
GameTabEx(1 + Random(6));
Wait(Random(100));
Writeln('Switched to GameTab ' + IntToStr(GetCurrentTab) + '.');
Wait(100 + Random(6000));
GameTabEx(4);
FindNormalRandoms;
end;
50:
begin
Deg := 1 + Random(357);
MakeCompass(IntToStr(Deg));
Writeln('Moved Compass to Degrees ' + IntToStr(Deg) + '.');
end;
69:
begin
MMouse(Random(MSX2), Random(MSY2), 0, 0);
Wait(50 + Random(500));
if IsUpText('ptions') then
begin
GetMousePos(opx, opy);
Mouse(opx, opy, 0, 0, False);
if ChooseOption('xamine') then
Writeln('Examined something...')
else
Writeln('Faled to Examine an Object.');
end;
end;
72:
if Random(4) = 0 then
begin
GameTabEx(13);
Wait(Random(2000));
MouseBox(715, 284, 728, 435, 1);
Wait(40 + Random(3000));
if FindColorTolerance(mx, my, 65280, 562, 270, 661, 450, 5) then
begin
Mouse(mx + Random(125), my + Random(8), 0, 0, True);
Wait(Random(3000));
end
else
begin
MouseBox(562, 268, 711, 449, 1);
Wait(Random(5000));
end;
FindNormalRandoms;
end;
78:
if Random(5) = 0 then
begin
SetAngle(True);
Wait(RandomRange(1, 30));
SetAngle(False);
end;
79:
begin
FTWait(RandomRange(1, 20));
end;
end;
end;
procedure PlayerStats; {From Dankness}
var
Active: string;
var
i: Integer;
begin
if Players[CurrentPlayer].Active = True then
Active := 'True'
else
Active := 'False';
AddToReport('');
AddToReport(' # : Nick = A. ');
for I := 0 to HowManyPlayers - 1 do
begin
if Players[i].Active = True then
Active := 'T'
else
Active := 'F';
AddToReport(' ' + Inttostr(I) + ' : ' + Players[i].Nick + ' = ' + Active + '. - MLvl :' + ' ' + inttostr(Players[i].level[6]) + ' ' + 'W: ' + IntToStr(Players[i].Worked) + ' min ');
end;
AddToReport('<~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>');
end;
procedure Proggie;
var
ExpGained: integer;
begin
case p of
0:
begin
ExpGained := AttDummy * 8;
ReportVars[1]:=AttDummy * 8;
end;
1:
begin
ExpGained := AttDummy * 12;
ReportVars[1]:= AttDummy * 12;
end;
2:
begin
ExpGained := AttDummy * 16;
ReportVars[1]:= AttDummy * 16;
end;
end;
SRLRandomsReport;
AddToReport ('/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\');
AddToReport ('| --> L.A.M.E. Reborn '+inttostr(VersionNumber)+' <-- Progress Report --> by Bonfield <-- |');
AddToReport ('<~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>');
AddToReport('***Worked for '+TimeRunning+' ***');
AddToReport('***Casted '+InttoStr(AttDummy)+' spells***');
AddToReport('***Gained '+IntToStr(ExpGained)+' experience***');
AddToReport('***Gained '+IntToStr(LvlsGained)+' levels***');
PlayerStats;
end;
procedure ScriptTerminate;
begin
Proggie;
end;
function PlayersInactive: boolean;
var
i: integer;
begin
for i := 0 to HowManyPlayers - 1 do
if Players[i].Active then exit;
result:= true;
end;
procedure SetupSMART;
begin
SmartSetupEx(WorldToUse, false, true, False);
Wait(100);
SetTargetDC(SmartGetDC);
Wait(2000);
end;
procedure RunOnce;
begin
SetupSRL
ScriptID := '1047';
SetupSMART;
DeclarePlayers;
ClearDebug;
Wait(2000 + Random(500));
LoginPlayer;
end;
Procedure RepeatMe;
begin
repeat
FindNormalRandoms;
GetAllLevels;
SetAngle(true);
ClaimRunes;
AutoCastSpell;
AttackDummy;
if not(LoggedIn) then
begin
NextPlayer(True);
GetAllLevels;
SetAngle(true);
ClaimRunes;
AutoCastSpell;
AttackDummy;
end;
until (PlayersInactive)
end;
begin
RunOnce;
RepeatMe;
end.