SCAR Code:
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- » Mouse Flag & Chat Routines --//
//-----------------------------------------------------------------//
// * function IsMoving(WaitTime: Integer): Boolean; // * by Bullzeye95 & Nava2
// * function Flag: Boolean; // * by PPLSUQBAWLZ/Odie533
// * function FlagPresent: Boolean; // * by Mutant Squirrle
// * function FlagDistance: Integer; // * by PPLSUQBAWLZ/Odie533
// * Function MFF(ax, ay, xmod, ymod: Integer):Boolean; // * by WT-Fakawi
// * Function MFNF(ax, ay, xmod, ymod: Integer):Boolean; // * by WT-Fakawi
// * procedure FFlag(Distance: Integer); // * by Wizzup? / WT-Fakawi.
// * procedure MouseFlag(cx, cy, rx, ry, FlagDist: Integer); // * by RsN edit by EvilChicken!
// * procedure SetChat(state: String; chat: Integer); // * by Wizzup? modded by WT-Fakawi and Starblaster100
// * procedure SetAllChats(Pub, Priv, Clan, Trade, Assist: string); // * by ZephyrsFury
// * procedure ChatsOff; // * by Starblaster100
{*******************************************************************************
function IsMoving(WaitTime: Integer): Boolean;
By: Bullzeye95; Edits by Nava2
Description: Checks if the currently loaded player is moving. Uses Minimap,
ignoring all dots which can move without the player moving.
Nava2 edit: Added try..finally, also changed to work with SMART,
as well added WaitTime Parameter.
*******************************************************************************}
function IsMoving(WaitTime: Integer): Boolean;
var
BMP, BMP2, I, H, x, y: Integer;
ReplaceCols: TIntegerArray;
P: TPointArray;
DC: HDC;
begin
WaitTime := Max(100, WaitTime);
try
DC := GetTargetDC;
ReplaceCols:= [65536, 16711422, 12961221, 14869218, 16777215, 15527148, 195836, 56797, 60909, 52428,
13816530, 982782, 1310462, 62965, 2105598, 395004, 789758, 3553023, 217, 188, 241,
206, 233, 64768, 58880, 51456, 49152, 44800, 61440, 16215571, 9716750, 13129742];
BMP:= BitmapFromString(100, 100, '');
BMP2:= BitmapFromString(100, 100, '');
SafeCopyCanvas(GetClientCanvas, GetBitmapCanvas(BMP), MMCX - 50, MMCY - 50, MMCX + 50, MMCY + 50, 0, 0, 100, 100);
H := High(ReplaceCols);
for I:= 0 to H do
FastReplaceColor(BMP, ReplaceCols[i], 0);
wait(WaitTime);
SafeCopyCanvas(GetClientCanvas, GetBitmapCanvas(BMP2), MMCX - 50, MMCY - 50, MMCX + 50, MMCY + 50, 0, 0, 100, 100);
SetTargetDC(GetBitmapDC(BMP2));
for I:= 0 to H do
begin
FindColorsTolerance(P, ReplaceCols[i], 0, 0, 99, 99, 0);
for x:= 0 to High(P) do
FastSetPixel(BMP2, P[x].x, P[x].y, FastGetPixel(BMP, P[x].x, P[x].y));
end;
Result:= not FindBitmapIn(BMP, x, y, 0, 0, 100, 100);
finally
SetTargetDC(DC);
FreeBitmap(BMP);
FreeBitmap(BMP2);
end;
end;
{*******************************************************************************
function FlagPresent: Boolean;
By: Mutant Squirrle
Description: T/F depending on flag exist.
*******************************************************************************}
function FlagPresent: Boolean;
var
x, y: integer;
begin
Result := FindColor(x, y, 255, MMX1, MMY1, MMX2, MMY2);
end;
{*******************************************************************************
function FlagDistance: Integer;
By: PPLSUQBAWLZ/Odie533
Description: Returns distance in pixels your char dot is from flag on mini-map
*******************************************************************************}
function FlagDistance: Integer;
var
x, y: Integer;
begin
If findcolor(x, y, 255, MMX1, MMy1, MMX2, MMY2) Then
Result := Distance(MMCX, MMCY, x + 1, y + 14);
end;
{*******************************************************************************
Function MFF(ax, ay, xmod, ymod: Integer):Boolean;
By: WT-Fakawi
Description: If the flag is not present it will click at (ax, ay) increasing by
(xmod, ymod) 5 times or until the flag appears.
*******************************************************************************}
Function MFF(ax, ay, xmod, ymod: Integer):Boolean;
var
TT, i, xx, yy, x, y, BreakOutTime: Integer;
begin
if (not LoggedIn) then Exit;
if (not (FlagPresent)) then
begin
xx := ax - xmod;
yy := ay - ymod;
MarkTime(BreakOutTime);
for i := 0 to 4 do
begin
xx := xx + xmod;
yy := yy + ymod;
if rs_OnMiniMap(xx, yy) then
Mouse(xx, yy, 2, 2, True)
else
Continue;
Wait(50);
MarkTime(TT);
repeat
Wait(10);
if FindColor(x, y, 255, MMx1, MMy1, MMx2, MMy2) then
begin
Result := True
Exit;
end;
Wait(Random(100));
until TimeFromMark(TT) > 3000;
end;
Result := False;
end;
end;
{*******************************************************************************
Function MFNF(ax, ay, xmod, ymod: Integer):Boolean;
By: WT-Fakawi
Description: Like MFF except it will click even if the flag is present when the
function is called.
*******************************************************************************}
Function MFNF(ax, ay, xmod, ymod: Integer):Boolean;
var
TT, i, xx, yy, x, y: Integer;
begin
Result := False;
if (not LoggedIn) then Exit;
xx := ax - xmod;
yy := ay - ymod;
for i := 0 to 4 do
begin
xx := xx + xmod;
yy := yy + ymod;
if rs_OnMiniMap(xx, yy) then
Mouse(xx, yy, 2, 2, True)
else
Continue;
Wait(50);
MarkTime(TT);
repeat
Wait(100);
if FindColor(x, y, 255, MMx1, MMy1, MMx2, MMy2) then
begin
Result := True;
Exit;
end;
Wait(Random(100));
until TimeFromMark(TT) > 3000;
end;
end;
{*******************************************************************************
procedure FFlag(Distance: Integer);
By: Wizzup? / WT-Fakawi / ZephyrsFury
Description: Waits until Flag is within "Distance" distance.
*******************************************************************************}
function FFlag(Dist: Integer): Boolean;
var
Tx, Ty, M, D1, D2: Integer;
begin
Result := False;
M := GetSystemTime;
while (FindColor(Tx, Ty, 255, MMX1, MMY1, MMX2, MMY2)) do
begin
D1 := Distance(Tx + 1, Ty + 14, MMCX, MMCY);
if (D1 <= Dist) then
begin
Result := True;
Exit;
end;
Wait(20);
if (GetSystemTime - M > 10000) then
begin
if (D1 = D2) then Exit;
D2 := D1;
M := GetSystemTime;
end;
if (Random(20) = 0) then IdleTime(500, 1000, 0.01);
if SRL_Procs[SRL_AntiBan] <> nil then
SRL_Procs[SRL_AntiBan]();
end;
end;
{*******************************************************************************
function Flag: Boolean;
By: PPLSUQBAWLZ/Odie533
Description: Waits while flag exists.
*******************************************************************************}
function Flag: Boolean;
begin
Result := FFlag(0);
end;
{
var
timeout, x, y: Integer;
begin
if (FindColor(x, y, 255, MMX1, MMY1, MMX2, MMY2)) then
begin
Result := True;
repeat
Wait(100);
if (SRL_Procs[srl_AntiBan] <> nil) then
SRL_Procs[srl_AntiBan]();
timeout := timeout + 1;
until (not FindColor(x, y, 255, MMX1, MMY1, MMX2, MMY2)) or (timeout > 300);
end;
end; }
{*******************************************************************************
procedure MouseFlag(cx, cy, rx, ry, FlagDist: Integer);
By: RsN edit by EvilChicken!
Description: Mouse and Flag combined into one easy procedure.
*******************************************************************************}
procedure MouseFlag(cx, cy, rx, ry, FlagDist: Integer);
var
i: Integer;
begin
if (not LoggedIn) then Exit;
Mouse(cx, cy, rx, ry, True);
while (not FlagPresent) and (i < 10) do
begin
Wait(100);
Inc(i);
end;
FFlag(FlagDist);
Wait(300 + Random(200));
end;
{*******************************************************************************
procedure SetChat(state: String; chat: Integer);
By: Wizzup? modded by WT-Fakawi and Starblaster100
Description: Sets Chat to desired state
*******************************************************************************}
procedure SetChat(state: string; chat: Integer);
var
x, y, mx, my, Color: Integer;
begin
case chat of
1: mx := 145;
2: mx := 200;
3: mx := 260;
4: mx := 320;
5: mx := 373;
else
begin
srl_Warn('SetChat', 'chat(' + IntToStr(chat) + ') does not exist.', warn_AllVersions);
Exit;
end;
end;
State := LowerCase(State);
case State of
'on': Color := 65280;
'off': Color := 255;
'hide': Color := 16776960;
'friends': Color := 65535;
else srl_Warn('SetChat', state + ' does not exist.', warn_AllVersions);
end;
State := Capitalize(State);
if not FindColor(x, y, Color, mx - 10, 486, mx + 10, 506) then
begin
Mouse(mx, my, 8, 8, False);
Wait(450 + Random(175));
ChooseOption(State);
end;
end;
{*******************************************************************************
procedure SetAllChats(Pub, Priv, Clan, Trade, Assist: string);
By: ZephyrsFury
Description: Sets all the chats to a particular state in one simple procedure.
Leave the parameter as '' if you wish to leave the chat as it is:
Example: SetAllChats('on', 'friends', '', 'off', '');
*******************************************************************************}
procedure SetAllChats(Pub, Priv, Clan, Trade, Assist: string);
var
States: TStringArray;
II: Integer;
begin
if (not(LoggedIn)) then Exit;
States := ['', Pub, Priv, Clan, Trade, Assist];
for II := 1 to 5 do
begin
if (States[II] = '') then Continue;
States[II] := Lowercase(States[II]);
if ((II <> 1) and (States[II] = 'hide')) or ((States[II] <> 'on') and
(States[II] <> 'friends') and (States[II] <> 'off') and (States[II] <> 'hide')) then
begin
srl_Warn('SetAllChats', 'ChatState ''' + States[II] + ''' does not exist for chat ''' + IntToStr(II) + ''' ', warn_AllVersions);
Continue;
end;
SetChat(States[II], II);
end
end;
{*******************************************************************************
procedure ChatsOff;
By: Starblaster100
Description: Sets all Chats to off.
*******************************************************************************}
Procedure ChatsOff;
var
i: Integer;
Begin
For i := 1 to 5 do
SetChat('off', i);
end;
SCAR Code:
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- » Login Routines --//
//-----------------------------------------------------------------//
// * function RSReady: Boolean; // * by ZephyrsFury
// * Procedure LoginScreenMusic(State: Variant); // * by Wizzup?
// * procedure Login_SetAudio(Volume, SFX, Area: Integer; SMSetting: (Stereo, Mono, NoChange) ); // * by ZephyrsFury
// * procedure Login_SetGraphics(Brightness: Integer; vl, rr, gd, td, ia, fl, gt, cs: string); // * by ZephyrsFury
// * procedure SetAutoingDefaults; // * by ZephyrsFury
// * procedure Logout; // * by Starblaster100 and Raymond
// * procedure LoginPlayer; // * by SRL Developers
// * procedure RandomNextPlayer(Active: Boolean); // * by Dankness, Ron and Raymond
// * procedure NextPlayer(Active: Boolean); // * by Dankness, Ron and Raymond
// * procedure CheckUserNicks; // * by Sumilion, Raymond and Nava2
{ var SRL_Logs: Integer;
Description: Variables needed for some login functions. }
{ var RandomPlayer, GraphicsSet: Boolean;
Description: Variables needed for some login functions. }
var
SRL_Logs: Integer;
RandomPlayer, GraphicsSet: Boolean;
procedure NextPlayer(Active: Boolean); forward;
procedure RandomNextPlayer(Active: Boolean); forward;
{*******************************************************************************
function RSReady: Boolean;
By: ZephyrsFury
Description: Returns true if we are ready to auto (on loginscreen or logged in).
Useful for waiting until RS has fully loaded.
*******************************************************************************}
function RSReady: Boolean;
begin
Result := (LoggedIn) or (GetColor(520, 146) = 4038981);
end;
{*******************************************************************************
Procedure LoginScreenMusic(State: Variant);
By: Wizzup?
Description: Takes Boolean(True, False) or Integer(1..5) as arguments.
1 or True = Off, 5 or False = Max.
1 2 3 4 5
<-o---o---o---o---o->
*******************************************************************************}
Procedure LoginScreenMusic(State: Variant);
Var
RealState: Variant;
x: Extended;
Begin
if (LoggedIn) then Exit;
if (CountColor(7750, 346, 356, 416, 369) <> 119) and (GetColor(520, 135) = 4038981) then
begin
TypeByte(vk_Escape);
Wait(100);
end;
if (CountColor(7750, 346, 356, 416, 369) <> 119) then Exit;
Case VarType(State) Of
11: RealState := (State + 1) * 4;
3: If InRange(State, 1, 5) Then
RealState := State - 1;
Else
RealState := 0;
End;
x := (425.0 - 337.0) * RealState / 4.0 + 339.0;
If CountColorTolerance(1647966, Round(x) - 5, 375, Round(x) + 5, 385, 20) < 5 Then
If CountColorTolerance(991349, Round(x) - 5, 375, Round(x) + 5, 385, 20) < 5 Then
Mouse(Round(x), RandomRange(375, 385), 0, 0, True);
End;
{*******************************************************************************
procedure Login_SetAudio(Volume, SFX, Area: Integer; SMSetting: (Stereo, Mono, NoChange) );
By: ZephyrsFury
Description: Sets audio options through the login screen.
Use: Enter the desired Setting for the desired Option. Make option 0 for no change.
EG. Login_SetAudio(1, 5, 2, NoChange);
1 2 3 4 5
Volume, SFX, Area: <-o---o---o---o---o->
*******************************************************************************}
procedure Login_SetAudio(Volume, SFX, Area: Integer; SMSetting: TSMSetting);
var
II, Tx, Ty, T: Integer;
Pts: TIntegerArray;
begin
if (LoggedIn) then Exit;
TypeByte(vk_Escape);
T := GetSystemTime;
while (CountColor(7750, 346, 373, 416, 386) <> 119) and (GetSystemTime - T < 5000) do
Wait(100);
if (CountColor(7750, 346, 373, 416, 386) = 119) then
MouseBox(334, 362, 426, 371, 1)
else
Exit;
Wait(100);
Pts := [Volume, SFX, Area];
for II := 0 to 2 do
begin
if (Pts[II] = 0) then Continue;
if (not(InRange(Pts[II], 0, 5))) then
begin
srl_Warn('Login_SetAudio', 'Points must be between 0 and 5', warn_AllVersions);
Continue;
end;
Tx := 337 + Round((425 - 337) * (Pts[II] - 1) / 4);
Ty := Round(3.5 * II * II + 46.5 * II + 245);
if (GetColor(Tx, Ty) <> 1121100) then
Mouse(Tx + 2, Ty - 14, 0, 0, True);
Wait(50);
end;
if (GetColor(337, 389) = 181) and (SMSetting = Stereo) then
Mouse(421, 385, 10, 10, True)
else
if (GetColor(426, 389) = 181) and (SMSetting = Mono) then
Mouse(332, 385, 10, 10, True);
Wait(100);
TypeByte(vk_Escape);
end;
{*******************************************************************************
procedure Login_SetGraphics(Brightness: Integer; vl, rr, gd, td, ia, fe, gt, cs: string);
By: ZephyrsFury
Description: Sets graphic options in the login screen.
Use: Enter the desired Setting for the desired Option.
Leave as 0 for no change of brightness and '' for no change in anything else.
Parameter Option Setting
Brightness Brightness 1 - 4 (0 for no change)
vl Visible Levels Current / All
rr Remove Roofs Always / Selectively
gd Ground Decoration Off / On
td Texture Detail Low / High
ia Idle Animations Few / Many
fe Flickering Effects Off / On
gt Ground Textures Few / Many
cs Chracter Shadows Off / On
1 2 3 4
Brightness: <---o---o---o---o--->
EG. Login_SetGraphics(2, 'current', '', 'off', 'low', 'few', '', 'few', 'off');
For Autoing:
Login_SetGraphics(4, 'current', 'always', 'off', 'low', 'few', 'off', 'few', 'off');
*******************************************************************************}
procedure Login_SetGraphics(Brightness: Integer; vl, rr, gd, td, ia, fe, gt, cs: string);
var
Settings, PosSettings, OptionName: TStringArray;
II, T, W, tCol, x, y, mSpeed: Integer;
TB: TBox;
P: TPoint;
begin
if (LoggedIn) then Exit;
Settings := [vl, rr, gd, td, ia, fe, gt, cs];
PosSettings := ['Current', 'All', 'Always', 'Selectively', 'Off', 'On', 'Low',
'High', 'Few', 'Many', 'Off', 'On', 'Few', 'Many', 'Off', 'On'];
OptionName := ['Visible levels', 'Remove roofs', 'Ground decoration', 'Texture detail',
'Idle animations', 'Flickering effects', 'Ground textures', 'Character shadows'];
TypeByte(vk_Escape);
T := GetSystemTime;
while (CountColor(7750, 346, 373, 416, 386) <> 119) and (GetSystemTime - T < 5000) do
Wait(100);
if (CountColor(7750, 346, 373, 416, 386) = 119) then
MouseBox(321, 338, 443, 346, 1)
else
Exit;
mSpeed := MouseSpeed;
MouseSpeed := 25;
Wait(100);
if (Brightness > 4) then
srl_Warn('Login_SetGraphics', 'Brightness must be between 0 and 4', warn_AllVersions)
else
if (Brightness <> 0) then
begin
P := Point(89 + (Brightness - 1) * 21, 266);
if (GetColor(P.x, P.y) <> 1121100) then
Mouse(P.x - 3, P.y - 17, 6, 6, True);
end;
for II := 0 to 7 do
begin
TB.x1 := 67 + 130 * ((II + 1) mod 5);
TB.y1 := 245 + 60 * ((II + 1) div 5);
TB.x2 := TB.x1 + 109;
TB.y2 := TB.y1 + 15;
if (not(InStrArrEx(Capitalize(Settings[II]), [PosSettings[II * 2], PosSettings[II * 2 + 1]], W))) then
begin
srl_Warn('Login_SetGraphics', 'Invalid Setting: ' + Settings[II] + ' for Option: ' + OptionName[II] + '.', warn_AllVersions);
Continue;
end;
tCol := (W mod 2) * 16777088 + 127;
if (not(FindColor(x, y, tCol, TB.x1, TB.y1, TB.x2, TB.y2))) then
begin
Mouse(TB.x1 + 10, TB.y1 + 3, 10, 7, True);
if (FindColor(x, y, tCol, TB.x1, TB.y2 + 1, TB.x2, TB.y2 + 1 + 51)) then
Mouse(x, y, 10, 7, True)
else
MouseBox(TB.x1 + 10, TB.y1 + 3, TB.x2 - 40, TB.y2 - 3, 1);
end;
end;
Wait(100);
TypeByte(vk_Escape);
MouseSpeed := mSpeed;
end;
{*******************************************************************************
procedure SetAudioOff;
By: ZephyrsFury
Description: Sets the Audio to off (1 for each bar). Works logged in and out.
*******************************************************************************}
procedure SetAudioOff;
begin
if (LoggedIn) then
SetAudio(1, 1, 1, NoChange)
else
Login_SetAudio(1, 1, 1, NoChange);
end;
{*******************************************************************************
procedure SetAutoingDefaults;
By: ZephyrsFury
Description: Sets the graphic options for best SRL compatibility. Works both logged in and out.
*******************************************************************************}
procedure SetAutoingDefaults;
begin
if (LoggedIn) then
SetGraphics(4, 'current', 'always', 'off', 'low', 'few', 'off', 'few', 'off')
else
Login_SetGraphics(4, 'current', 'always', 'off', 'low', 'few', 'off', 'few', 'off');
end;
{*******************************************************************************
procedure Logout;
By: Starblaster100 / Raymond
Description: Logs you out.
*******************************************************************************}
function Logout: Boolean;
var
c, i: Integer;
begin
Result := (not (LoggedIn));
if Result = True then
Exit;
if GameTab(14) = False then
Exit;
Wait(200 + Random(100));
while (LoggedIn) and (c < 10) do
begin
Inc(c);
if(ClickText('here', UpChars, MIX1, MIY1, MIX2, MIY2, True))then
for i := 0 to 10 do
begin
Wait(1000);
if not(LoggedIn)then
begin
Result := True;
Exit;
end;
end;
end;
end;
{*******************************************************************************
procedure LoginPlayer;
By: SRL Developers
Description: Logs in the Player[CurrentPlayer]. Detects most Client Login Errors
*******************************************************************************}
procedure LoginPlayer;
var
Mark, Attempts: Integer;
Actions: TVariantArray;
RetryLogin: Boolean;
label
ProcStart;
begin
ActivateClient;
Wait(100);
TypeByte(vk_Escape);
if (GetColor(207, 409) = 238301) then //At Click To Play screen
begin
Wait(1000 + Random(3000));
MouseBox(249, 419, 521, 445, 1);
MarkTime(Mark);
while (TimeFromMark(Mark) < 30000) and (not(LoggedIn)) do
Wait(1000 + Random(1000));
end;
if (not(RSReady)) then
begin
MarkTime(Mark);
while (not(RSReady)) do
begin
Wait(100);
if (TimeFromMark(Mark) > 180000) then
begin
WriteLn('It has been 3 minutes and Runescape is not yet ready... Terminating.');
TerminateScript;
end;
end;
WriteLn('Welcome to Runescape.');
end;
LoginScreenMusic(True);
if (not(GraphicsSet)) then
begin
SetAutoingDefaults;
GraphicsSet := True;
end;
ProcStart:
if (not(LoggedIn)) then
begin
if (not(Players[CurrentPlayer].Active)) then
begin
WriteLn('Player is not Active...');
NextPlayer(False);
Exit;
end;
Wait(900 + random(60));
//Click 'Log In' on main menu
while (GetColor(343, 175) <> 7750) do //while (GetColor(343, 174) <> 7750) do
begin
MouseBox(360, 180, 400, 185, 1);
Wait(100 + Random(100));
end;
//Type Username
Mouse(315, 272, 10, 5, True);
while (CountColor(7750, 311, 269, 452, 284) > 13) do
begin
TypeByte(VK_BACK);
Wait(50 + Random(50));
end;
for Mark := 0 to 3 do
begin
TypeByte(VK_BACK);
Wait(50 + Random(50));
end;
Wait(100 + Random(200));
WriteLn(Capitalize(Players[CurrentPlayer].Name));
TypeSend(Players[CurrentPlayer].Name);
Wait(100+random(50));
//Type Password
Mouse(315, 334, 10, 5, True);
while (CountColor(7750, 311, 337, 452, 352) > 13) do
begin
TypeByte(VK_BACK);
Wait(50 + Random(50));
end;
for Mark := 0 to 3 do
begin
TypeByte(VK_BACK);
Wait(50 + Random(50));
end;
Wait(100 + Random(200));
TypeSend(Players[CurrentPlayer].Pass);
Wait(500 + Random(300));
if GetColor(315, 239) = 197552 then //Check for pvp warning and click
MouseBox(434, 416, 481, 425, 1);
MarkTime(Mark);
repeat
SetLength(Actions, 0);
if (TimeFromMark(Mark) > 60000) then
Actions := ['One minute has passed...', 0, 2, 'NextPlayer', 'Login Failed']
else
case (CountColor(12509695, 288, 205, 475, 247)) of //Number of text colour points
// Actions := ['WriteLn Text', TimeToWait, NumberOfRetries, 'FinalAction', 'PlayerStatus'];
760: Actions := ['Too many incorrect logins.', 5 * 60000, 2, 'NextPlayer', ''];
536: Actions := ['Login limit exceeded. Please wait 1 minute and try again.', 60000, 2, 'NextPlayer', ''];
711: Actions := ['Your account has been disabled', 0, 0, 'NextPlayer', 'Acc Disabled'];
598: Actions := ['Invalid Username / Password', 0, 2, 'NextPlayer', 'Wrong User/Pass'];
787: Actions := ['Not a Members Account', 0, 0, 'NextPlayer', 'Non-member'];
408: Actions := ['World is full.', 5000, 20, 'Terminate', ''];
669: Actions := ['Your account is already logged in', 5000, 0, 'RandomNextPlayer', ''];
555: Actions := ['The Server is being updated.', 60000, 4, 'Terminate', 'Server Updating'];
218: Actions := ['Error Connecting.', 20000, 9, 'Terminate', 'Error Connecting'];
335: Actions := ['Unable to connect Login Server offline.',(20000) + Random(6000), 4, 'Terminate', 'Login Server Offline'];
512: Actions := ['RuneScape has been updated. Script Terminated.', 0, 0, 'Terminate', 'RS Updated'];
489: Actions := ['Connection timed out.', 0, 4, 'Terminate', 'Connection Timed Out'];
737: Actions := ['You are standing in a members-only area.', 0, 0, 'NextPlayer', 'In Mems-Only Area'];
//10: Actions := ['Error loading your profile.', 5000, 10, 'NextPlayer', 'Profile Loading Failed']; // Error loading your profile. Will attempt to re-login 5 more times.)
//11: Actions := ['Login server rejected session.', 1000, 10, 'NextPlayer', 'Login Serv. Rejected']; // Login server rejected session.
end;
if (Length(Actions) > 0) then
begin
WriteLn(Actions[0]);
Wait(Actions[1] + Random(100));
if (Actions[2] <> 0) then
if (Attempts < Actions[2]) or (Actions[2] = -1) then
begin
RetryLogin := True;
Break;
end;
if (Actions[4] <> '') then
Players[CurrentPlayer].Loc := Actions[4];
case Actions[3] of
'NextPlayer': NextPlayer(False);
'RandomNextPlayer': RandomNextPlayer(True);
'Terminate': TerminateScript;
end;
Exit;
end;
Wait(100);
until (GetColor(207, 409) = 238301) or (LoggedIn);
if (RetryLogin) then
begin
RetryLogin := False;
Inc(Attempts);
goto ProcStart;
end;
if (GetColor(207, 409) = 238301) then
begin
Wait(500 + Random(1000));
MouseBox(249, 419, 521, 445, 1);
end;
MarkTime(Mark);
while (TimeFromMark(Mark) < 30000) and (not(LoggedIn)) do
Wait(1000 + Random(1000));
end;
if (LoggedIn) then
begin
PlayerStartTime := (GetSystemTime div 1000); // PlayerStartTime
if Length(Players[CurrentPlayer].NickTPA) < 2 then
begin;
Writeln('Creating the NickTPA.');
if Players[CurrentPlayer].Nick <> '' then
Players[CurrentPlayer].NickTPA := CreateTPAFromText(Players[CurrentPlayer].Nick, UpChars)
else
begin;
Writeln('Nickname isn''t set, taking the username instead..');
Players[CurrentPlayer].NickTPA := CreateTPAFromText(Players[CurrentPlayer].Name, UpChars);
end;
end;
AddToSRLLog('Current player: ' + Capitalize(Players[CurrentPlayer].Name));
end;
end;
{*******************************************************************************
procedure RandomNextPlayer(Active: Boolean);
By: Dankness based on WT-Fawki's NextPlayer and modified by Ron and by Raymond
Description: Picks Random Player that is Active and Logs in
*******************************************************************************}
procedure RandomNextPlayer(Active: Boolean);
var
LastPlayer: Integer;
begin
WriteLn('NextPlayer');
LastPlayer := CurrentPlayer;
Players[CurrentPlayer].Active := Active;
Logout;
PlayerCurTime := (GetSystemTime div 1000);
Players[CurrentPlayer].Worked := Players[CurrentPlayer].Worked +
((PlayerCurTime - PlayerStartTime) / 60);
repeat
if (AllPlayersInactive) then Wait(5000);
if (PlayersActive = 1) then Break;
CurrentPlayer := Random(HowManyPlayers);
Wait(100);
until (Players[CurrentPlayer].Active) and (LastPlayer <> CurrentPlayer);
SRL_Logs := SRL_Logs + 1;
LoginPlayer;
end;
{*******************************************************************************
procedure NextPlayer(Active: Boolean);
By: Dankness and modified by Ron and by Raymond
Description: Logs in the next player.
Boolean: True - Current player is ok. False - Current player is false.
*******************************************************************************}
procedure NextPlayer(Active: Boolean);
begin
if RandomPlayer then
RandomNextPlayer(Active)
else
begin
WriteLn('NextPlayer(Active: ' + BoolToStr(Active)+ ');');
Players[CurrentPlayer].Active := Active;
Logout;
if (SRL_Procs[srl_OnNextPlayer] <> nil) then
SRL_Procs[srl_OnNextPlayer]();
PlayerCurTime := (GetSystemTime div 1000);
Players[CurrentPlayer].Worked := Players[CurrentPlayer].Worked +
((PlayerCurTime - PlayerStartTime) / 60);
CurrentPlayer := (CurrentPlayer + 1) mod Length(Players);
while Players[CurrentPlayer].Active = False do
begin
CurrentPlayer := (CurrentPlayer + 1) mod Length(Players);
if (AllPlayersInactive) then Wait(5000); // Everybody False. Endless Loop.
end;
SRL_Logs := SRL_Logs + 1;
LoginPlayer;
end;
end;
{*******************************************************************************
procedure CheckUserNicks;
By: Sumilion, Raymond, and Nava2
Description: Checks if all nicks are set correct.
*******************************************************************************}
procedure CheckUserNicks;
var
I, II: Integer;
Wrong, FWrong: Boolean;
WarnStrings: TStringArray;
begin
WarnStrings := ['Please fill in your nickname.', 'Please Uncapitalise your nickname.',
'Dont use the first letter in your nick.', 'Dont use spaces in your Nick.',
'Nick does NOT match the name.'];
for i := 0 to HowManyPlayers - 1 do
for II := 0 to 4 do
begin
case II of
0: Wrong := (Players[i].Nick = '');
1: Wrong := (Players[i].Nick <> LowerCase(Players[i].Nick));
2: Wrong := (Pos(Players[i].Nick, LowerCase(Players[i].Name)) = 1);
3: Wrong := (Pos(' ', Players[i].Nick) > 0);
4: Wrong := (Pos(LowerCase(Players[i].Nick), Capitalize(LowerCase(Players[i].Name))) = 0);
end;
if Wrong then
begin;
Writeln('--');
Writeln('WARNING: ' + WarnStrings[II] + ' with player: ' + Players[i].Name);
FWrong := True;
end;
end;
if FWrong then
begin
Writeln('');
//Writeln('For more information, visit [url]http://www.villavu.com/forum/showthread.php?t=5410');[/url]
end;
end;