SCAR Code:
{*******************************************************************************
Function OpenWorldScreen: Boolean;
by: Nava2
Description: Opens the world screen. Returns true if world screen is opened.
*******************************************************************************}
function OpenWorldScreen: Boolean;
var
TPA: array [0..1] of TPointArray;
W, TheDC, iTime: Integer;
Box: TBox;
begin
Result := WorldScreen;
if Result then Exit;
W := BitmapFromString(17, 13, 'beNpjYKAb+I8ESBXBNAfTcDwK' +
'CGrBVIPmDEz15GlB1oWVgSfokBUQ1EKM8whqwRV0eIIRv5OIBQByA' +
'K1T');
TheDC := GetTargetDC;
SetTargetDC(GetBitmapDc(w));
FindColorsTolerance(TPA[0], clWhite, 0, 0, 17, 13, 0);
SetTargetDC(TheDC);
FindColorsTolerance(TPA[1], 13158, 305, 239, 368, 272, 3);
if FindTPAinTPA(TPA[0], TPA[1], TPA[0]) then
begin
Box := GetTPABounds(TPA[0]);
Box := IntToBox(Box.x1, Box.y1, Box.x1 + 82, Box.y2);
MouseBox(Box.x1, Box.y1, Box.x2, Box.y2, 1);
iTime := GetTimeRunning + 2000;
while not Result do
begin
if GetTimeRunning > iTime then Exit;
Wait(RandomRange(40, 80));
Result := WorldScreen;
end;
end;
end;
SCAR Code:
function UpdateWorlds: Boolean;
var
worldList: TWorldArray;
str, Path: string;
tsa, tsb: TStringArray;
W, I, H, Time: Integer;
begin
try
Result := True;
Path := AppPath + 'Includes\SRL\SCSS\Worlds.INI';
Writeln('NOTE: Attempting to update the Worlds.INI, please allow the script to access this file.');
Time := GetTimeRunning;
W := RewriteFile(Path, False);
CloseFile(W);
str := GetPage('http://www.runescape.com/slu.ws?order=WMPLA');
Delete(str, 1, Pos('<a href="?order=MWPLA">', str));
Delete(str, 1, Pos('<tr', str) + 3);
tsa := m_Explode(str, '<tr');
SetLength(worldList, High(tsa) + 1);
H := High(tsa);
for I := 0 to H do
with worldList[I] do
begin
tsb := m_Explode(tsa[I], '<td');
if High(tsb) <= 7 then
begin
Writeln('Skipping world ' + IntToStr(I + 1) + ' because explosion didn''t return enough values');
Continue;
end;
PlayerNo := StrToIntDef(Copy(tsb[2], 2, Pos(' Players', tsb[2]) - 2), 2000);
case Uppercase(Between('"', '"', tsb[3])) of
'US': Location := 'United States';
'NL': Location := 'Netherlands';
'CA': Location := 'Canada';
'AU': Location := 'Australia';
'SE': Location := 'Sweden';
'FI': Location := 'Finland';
'GB': Location := 'Great Britain';
'NZ': Location := 'New Zealand';
'DK': Location := 'Denmark';
'BE': Location := 'Belguim';
'BR': Location := 'Brazil';
'MX': Location := 'Mexico';
'IE': Location := 'Ireland';
'NO': Location := 'Norway';
else
Writeln('Location: ' + Between('"', '"', tsb[3]) + ' unknown. Please notify someone of this.');
end;
Prefix := Between('http://', '.runescape', tsb[1]);
if Prefix = '' then
Prefix := Replace(Lowercase(Between('>' + #10, #10 + #10, tsb[1])), ' ', '');
Number := StrToIntDef(Replace(Prefix, 'world', ''), -1);
if Number = -1 then
Writeln(tsb[1] + ' || ' + Prefix);
Activity := Between('>', '<', tsb[4]);
if Activity = '-' then
Activity := '';
LootShare := Between('title="', '"', tsb[5]) = 'Y';
QuickChat := Between('title="', '"', tsb[6]) = 'Y';
PvP := Between('title="', '"', tsb[7]) = 'Y';
Members := Between('>', '<', tsb[8]) = 'Members';
end;
//Writeln('Writing to the INI File. T: ' + IntToStr(GetTimeRunning - W));
WriteINI('Worlds', 'Count', IntToStr(High(worldList) + 1), Path);
WriteINI('Worlds', 'High', IntToStr(worldList[High(worldList)].Number) + #13#10, Path);
H := High(worldList);
for I := 0 to H do
with worldList[I] do
begin
Str := 'World' + IntToStr(Number);
DeleteINI(Str, '', Path);
WriteINI(Str, 'Prefix', Prefix, Path);
WriteINI(Str, 'Activity', Activity, Path);
WriteINI(Str, 'Members', BoolToStr(Members), Path);
//WriteINI(Str, 'Flag', fla + 'Flag', Path);
WriteINI(Str, 'Location', Location, Path);
WriteINI(Str, 'LootShare', BoolToStr(LootShare), Path);
WriteINI(Str, 'QuickChat', BoolToStr(QuickChat), Path);
WriteINI(Str, 'PvP', BoolToStr(PvP) + #13#10, Path);
end;
Writeln('Parsed Worlds Page into Worlds.INI. Took ' + IntToStr(GetTimeRunning - Time) + ' ms.');
except
Result := False;
SRL_Warn('UpdateWorlds', ExceptionToString(ExceptionType, ExceptionParam), Warn_AllVersions);
end;
end;
{*******************************************************************************
procedure LoadWorldArrays;
by: Narcle; Edits by Nava2
Description: Loads the world array into WorldArray from Worlds.ini
*******************************************************************************}
// Edit: Changed to use Members as a boolean to go w/ the previous Parser function.. Also added StrToBool; As well as try..except
procedure LoadWorldArrays;
var
i, H, Hw: integer;
begin
try
H := StrToInt(ReadINI('Worlds', 'High', AppPath + 'includes\SRL\SCSS\worlds.ini'));
except
Writeln('LoadWorldArrays: Could not load world arrays, attempting to rewrite Worlds.INI');
if not UpdateWorlds then
begin
SRL_Warn('LoadWorldArrays', 'Could not Load World arrays, please download mixster''s world parser, and replace Worlds.ini', Warn_AllVersions);
Exit;
end;
end;
for i := 1 to H do
begin
if not (ReadINI('World' + IntToStr(i), 'Prefix', AppPath + 'includes\SRL\SCSS\worlds.ini') = '') then
begin
SetArrayLength(WorldArray, Length(WorldArray)+1);
Hw := High(WorldArray);
WorldArray[Hw].Number := i;
WorldArray[Hw].Prefix := ReadINI('World' + IntToStr(i), 'Prefix', AppPath + 'includes\SRL\SCSS\worlds.ini');
WorldArray[Hw].Members := StrToBool(ReadINI('World' + IntToStr(i), 'Members', AppPath + 'includes\SRL\SCSS\worlds.ini'));
WorldArray[Hw].LootShare := StrToBool(ReadINI('World' + IntToStr(i), 'Lootshare', AppPath + 'includes\SRL\SCSS\worlds.ini'));
WorldArray[Hw].QuickChat := StrToBool(ReadINI('World' + IntToStr(i), 'Quickchat', AppPath + 'includes\SRL\SCSS\worlds.ini'));
WorldArray[Hw].PVP := StrToBool(ReadINI('World' + IntToStr(i), 'PvP', AppPath + 'includes\SRL\SCSS\worlds.ini'));
end;
end;
end;