SCAR Code:
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- » Login Routines --//
//-----------------------------------------------------------------//
// * procedure Logout; // * by Starblaster100 and Raymond
// * procedure LoginPlayer; // * by WT-Fakawi / Raymond
// * procedure RandomNextPlayer(Active: Boolean); // * by Dankness, Ron and Raymond
// * procedure NextPlayer(Active: Boolean); // * by Dankness, Ron and Raymond
// * procedure CheckUserNicks; // * by Sumilion and Raymond
{ var SRL_Logs, SRL_Attempts: Integer;
Description: Variables needed for some login functions. }
var
SRL_Logs, SRL_Attempts: Integer;
RandomPlayer: Boolean;
procedure NextPlayer(Active: Boolean); forward;
{*******************************************************************************
procedure Logout;
By: Starblaster100 / Raymond / Fixed By BobboHobbo
Description: Logs you out.
*******************************************************************************}
function Logout: Boolean;
var
c, i: Integer;
begin
Result := (not (LoggedIn));
if Result = True then
Exit;
Wait(200 + Random(100));
while (LoggedIn) or (c < 10) do
begin
Inc(c);
MouseBox(744, 4, 759, 18, 1);
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: WT-Fakawi / Raymond / Fixed By NaumanAkhlaQ
Description: Logs in the Player[CurrentPlayer]. Detects most Client Login Errors
*******************************************************************************}
Function LoginPlayer : boolean;
Label Check;
Var
TriesXX : Integer;
Options : TStringArray;
Actions : TVariantArray;
I : Integer;
OneActive : Boolean;
LastPlayer : Integer;
begin
Result := False;
OneActive := False;
if LoggedIn = False then
begin;
if (not (Players[CurrentPlayer].Active)) then
begin;
WriteLn('Current player is not Active...');
Repeat
For I := 0 to HowManyPlayers - 1 do
if players[i].Active = true then
OneActive := True;
if OneActive = True then
Break;
Wait(60000);
until false
end
else
Begin
MouseBox(337, 162, 425, 177, 1);
Repeat
Wait(100+Random(200));
Until(GetColor(364, 260) = 6063521);
MMouse(364, 260, 14, 4);
TypeSend(Players[CurrentPlayer].Name);
MMouse(374, 327, 15, 5);
TypeSend(Players[CurrentPlayer].Pass);
Begin
MouseBox(342, 356, 408, 374, 1);
Repeat
Wait(300+Random(400));
TriesXX := TriesXX + 1;
Until(GetColor(11, 25) = 24577) Or (TriesXX > 60);
If TriesXX > 60 Then Goto Check
else
Wait(2000+Random(3000));
Mouse(377, 352, 100, 10, True);
Wait(2000+Random(3000));
WriteLn('Sucessfully LoggedIn!');
end;
end;
Check : Options := ['nter your','already','nvalid','excee','full','offl','rror','ontact','reject','reload',
'updat','disabled','member','incorrect'];
For I := 0 to High(Options) do
If FindTextTpa(12509695, 10, 279, 182, 482, 222, Options[i], StatChars, Nothing) Then
begin;
OneActive := True;
Break;
end;
If OneActive Then
Begin
SetLength(Actions,2);
Case Options[i] of
'reload' : begin; //Runescape updated
WriteLn('ERROR. RuneScape has been updated. Script Terminated.');
Terminatescript;
end;
'disabled' : begin; //Your account has been disabled..
WriteLn('Your account has been disabled');
Players[CurrentPlayer].loc := 'DISABLED';
NextPlayer(False);
Exit;
end;
'member' : begin; // You need a Members account...
WriteLn('You need a Members account...');
Players[CurrentPlayer].loc := 'Non-Member';
NextPlayer(False);
exit;
end;
'already' : begin //Account already logged in
Actions := ['Your account is already logged in',0];
LastPlayer := CurrentPlayer;
repeat
CurrentPlayer := (CurrentPlayer + 1) mod HowManyPlayers;
Wait(200);
until (Players[CurrentPlayer].Active) and (CurrentPlayer <> LastPlayer);
end;
'nvalid' : begin;// Invalid Username. 3 attempts. If fails, username/pass incorrect
Actions := ['Invalid Username \ Password',0];
Inc(SRL_Attempts);
if SRL_Attempts > 3 then
begin;
Players[CurrentPlayer].Loc := 'Login ERROR';
SRL_Attempts := 0;
Nextplayer(False);
Exit;
end;
end;
'excee' : Actions := ['Login attempts exceeded. Please wait 1 minute and try again.',60000];
'offl' : Actions := ['Unable to connect Login Server offline.',(20000) + Random(6000)]; // Unable to connect. Login Server offline.
'nter your': Actions := ['Enter your username and password',0];//Login failed
'full' : Actions := ['World is full.',5000]; //World is full =]
'rror' : Actions := ['Error Connecting.',10000]; //Error, connection timed out?
'ontact' : Actions := ['Error loading your profile.',2000]; // Error loading your profile. Will attempt to re-login 5 more times.)
'reject' : Actions := ['Login server rejected session.',1000]; // Login server rejected session.
'updat' : Actions := ['The Server is being updated.',60000]; // The Server is being updated. Please wait 1 minute.
'incorrect': Actions := ['To many incorrect logins.',60000 * 5]; //Wrong logins baby.
end;
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 isnt set, taking the username instead..');
Players[CurrentPlayer].NickTPA := CreateTPAFromText(Players[CurrentPlayer].Name, UpChars);
end;
end;
WriteFileString(TheFile, Chr(13) + 'Current player: '+ UpperCase(Players[CurrentPlayer].Name) + Chr(13)); //* Save NAME to file
end;
end;
Begin
Wait(1);
WriteLn('Logged Player In');
end;
Exit;
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
CurrentPlayer := Random(HowManyPlayers);
Wait(100);
until (Players[CurrentPlayer].Active) and (CurrentPlayer <> LastPlayer);
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);
var
I : integer;
OneActive : Boolean;
begin
if RandomPlayer then
RandomNextPlayer(Active)
else
begin
WriteLn('NextPlayer');
Players[CurrentPlayer].Active := Active;
Logout;
PlayerCurTime := (GetSystemTime div 1000);
Players[CurrentPlayer].Worked := Players[CurrentPlayer].Worked +
((PlayerCurTime - PlayerStartTime) / 60);
CurrentPlayer := (CurrentPlayer + 1) mod HowManyPlayers;
while Players[CurrentPlayer].Active = False do
begin
OneActive := False;
CurrentPlayer := (CurrentPlayer + 1) mod HowManyPlayers;
for I := 0 to HowManyPlayers - 1 do
if Players[I].Active then
OneActive := True;
if OneActive = False then
Wait(60000); // Everybody False. Endless Loop.
end;
SRL_Logs := SRL_Logs + 1;
LoginPlayer;
end;
end;
{*******************************************************************************
procedure CheckUserNicks;
By: Sumilion / Raymond
Description: Checks if all nicks are set correct.
*******************************************************************************}
procedure CheckUserNicks;
var
CorrectString: string;
i: Integer;
Wrong : Boolean;
Str : String;
begin
for i := 0 to HowManyPlayers - 1 do
begin
Wrong := False;
if (Players[i].Nick = '') then
begin
Wrong := True;
Str := 'WARNING : Please fill in your nickname.';
end;
if (Players[i].Nick <> LowerCase(Players[i].Nick)) then
begin
Wrong := True;
Str := 'WARNING : Please Uncapitalise your nickname.';
end;
if (pos(Players[i].Nick, LowerCase(Players[i].Name)) = 1) then
begin
Wrong := True;
Str := 'WARNING : Dont use the first letter in your nick.';
end;
if (pos(' ', Players[i].Nick) > 0) then
begin
Wrong := True;
Str := 'WARNING : Dont use spaces in your Nick.';
end;
CorrectString := Capitalize(Players[i].Name);
if not (Pos(LowerCase(Players[i].Nick), CorrectString) > 0) then
begin
Wrong := true;
Str := 'WARNING : Nick does NOT match the name.';
end;
if Wrong then
begin;
Writeln('--');
Writeln(Str);
if (Length(Players[i].Name) > 0) then
Writeln('Warning occured with player : ' + Players[i].Name);
Writeln('For more information, visit http://www.villavu.com/forum/showthread.php?t=5410');
end;
end;
end;