SRL Archive - OSR Help

login HELP please!


leia

2013-03-05 00:03:18

I have looked through all of yohojo's videos. I have followed his guides. I have redone everything like 3 times. But every time I try to run the test scripts or any other script, the login.simba script appears and says there is an "unknown identifier" error. I don't know what's wrong. Please help!

YoHoJo

2013-03-05 00:07:14

Post the script you have in simba taggs like so:
[simba] code here [/sima]

And post the error you are getting.

We can't help unless we see the exact script and error.

leia

2013-03-05 00:14:16

ok sorry :[ here is the Login.simba script:

(*
Login
=====

The Login include contains all the functions to succesfully log you in and out
of the game and/or the lobby.

.. contents::

*)


const
SM_Color = 8115338;

{ var SRL_Logs: Integer;
var RandomPlayer, GraphicsSet: Boolean;
Description: Variables needed for some login functions. }
var
SRL_Logs: Integer;
RandomPlayer, GraphicsSet, AllowPVP: Boolean;

procedure NextPlayer(Active: Boolean); forward;
procedure RandomNextPlayer(Active: Boolean); forward;

const
UBx1 = 279; // Username tBox - in use now
UBy1 = 180;
UBx2 = 486;
UBy2 = 190;

PBx1 = 279; // Password tBox - in use now
PBy1 = 225;
PBx2 = 486;
PBy2 = 240;

GBx1 = 230; // greeting box in final screen
GBy1 = 330;
GBx2 = 660;
GBy2 = 400;

WDx1 = 88; // window box (to enter game) "click here to play"
WDy1 = 450;
WDx2 = 545;
WDy2 = 473;

WHITE_TEXT = 16777215; // white text color
MESSAGE_BOX = 11452366; // The "helpful message" box color
INFO_BOX = 7428416; // Blue information box color
LOGIN_COLOR = 6865381; // Login button color
ERROR_BOX = 2044518; // Error box (comes up on incorrect pw/un or banned acc

const //GetScreen
LOGIN_TA_X1 = 210; //Text check area
LOGIN_TA_Y1 = 54;
LOGIN_TA_X2 = 556;
LOGIN_TA_Y2 = 228;

LOGIN_TEXTCOLOUR = 12378347; //Colour of text



(*
LobbyScreen
~~~~~~~~~~~

.. code-block:: pascal

function LobbyScreen: Boolean;

Returns true if we are at the Lobby Screen

.. note::

by IceFire908 & Bionicle1800

Example:

.. code-block:: pascal

// wait for the Lobby Screen to appear!
while (not LobbyScreen) do
Wait(100 + Random(400));

*)
function LobbyScreen: Boolean;
begin
Result := InRange(GetLobbyTab, L_PlayerInfo, L_Options);
end;

(*
TakeIPScreen
~~~~~~~~~~~~

.. code-block:: pascal

procedure TakeIPScreen();

Saves a screenshot of the last logged in IP address to the SRL logs folder.

.. note::

by Harry & Coh3n

Example:

.. code-block:: pascal

TakeIPScreen();
*)
procedure TakeIPScreen();
var
tmpPath: string;
begin
if ((not lobbyScreen()) or (SRL_DisableIPLog)) then
exit;

tmpPath := SRL_SavePath;
SRL_SavePath := tmpPath + 'IPLogs/'; // so TakeScreen saves to the right directory

takeScreen('IP Log');

SRL_SavePath := tmpPath; // reset
end;

(*
RSReady
~~~~~~~

.. code-block:: pascal

function RSReady: Boolean;

Returns true if we are ready to auto (on loginscreen or logged in).
Useful for waiting until RS has fully loaded.

.. note::

by ZephyrsFury - Edited by [J]ustin

Example:

.. code-block:: pascal

while (not RSReady) do
SleepAndMoveMouse(100 + Random(500));

*)
function RSReady: Boolean;
var
x, y: Integer;
begin
Result := True;
if (not Result) then
begin
ImageResetClientArea;
Result := (GetColor(745, 17) = 16645629) or FoundBar; // X button in top right && Navigation Bar.
SRL_ResetNavBar;
end;
if (GetColor(755, 43) = 16645629) then // X button on resizeable client
begin
WriteLn('You are using the "Resizeable" screen option in RS.');
WriteLn('Changing to "Fixed" screen option.');
Mouse(735, 44, 2, 2, mouse_Left);
Wait(600 + Random(800));
if FindBitMapToleranceIn(SRL_OPTIONS_BITMAP, x, y, 130, 40, 640, 265, 5) then
begin
Mouse(200, 270, 5, 5, mouse_Left); //Fixed button
Wait(1200 + Random(1200)); //Wait while the screen changes
Mouse(621, 71, 3, 3, mouse_Left); //Close the Options interface
Wait(600 + Random(240));
end
else
begin
WriteLn('Unable to find Options Screen.');
WriteLn('Please manually change to "Fixed" screeb size');
TerminateScript;
end;
end;
if (FindBitMapToleranceIn(SRL_OPTIONS_BITMAP, x, y, 130, 40, 640, 265, 5)) then
begin
Writeln('Failed to close Options Interface. Please report on Villavu Forum');
TerminateScript; //Failsafe if we fail to close the Interface for some reason
end;
end;

(*
Login_SetAudio
~~~~~~~~~~~~~~

.. code-block:: pascal

procedure Login_SetAudio(Volume, SFX, Area: Integer; SMSetting: TSMSetting);

Sets audio options through the login screen.
Use: Enter the desired Setting for the desired Option. Make option 0 for no change.

.. note::

by ZephyrsFury, fixed by Markus

Example:

.. code-block:: pascal

Login_SetAudio(1, 5, 2, NoChange);

*)
procedure Login_SetAudio(Volume, SFX, Area: Integer; SMSetting: TSMSetting);
var
II, Tx, Ty, T, AudioMask,x,y: Integer;
Pts: TIntegerArray;
begin
if (LoggedIn) then Exit;
AudioMask := BitmapFromString(28, 3, 'beNrLyMAKGBgYJ85Y' + //gfx slice but too lazy
'dOfmw4VrdgPZaFJAdOniSSDacug8miwuAFSWWVAJVL9kzWqgsUA2X' + // to fuck this entire function around
'CPENKBUZXs3BBFjJsRAoPPguoAOhhsLJCEGerjZQRxsbaaFbgQAUH' +
'JlGA==');
TypeByte(vk_Escape);
T := GetSystemTime;
while (not(FindBitmapToleranceIn(AudioMask, X, Y, 717, 458, 760, 498, 10))) and (GetSystemTime - T < 5000) do
Wait(100);
if (FindBitmapToleranceIn(AudioMask, X, Y, 717, 458, 760, 498, 10)) then
Mouse(X, Y, 20, 20, mouse_left)
else
begin
FreeBitmap(AudioMask);
Exit;
end;
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;
if Pts[II] = 1 then Tx:=32 else
//Tx := 337 + Round((425 - 337) * (Pts[II] - 1) / 4);
Tx := 319 * (PTS[II] - 1) * 32; //why do hard if we can do easy -.-
Ty := round(II * 22.5) + 397; { I THINK this is the formula, but I don't care. }
{ Ty := //Round(3.5 * II * II + 46.5 * II + 245);}
if (GetColor(Tx, Ty) = 1315860) then
Mouse(Tx - 10, Ty - 0, 10, 5, mouse_left); {bit of randomness never hurts }
Wait(50);
end;
if (GetColor(527, 433) = 4473924) and (SMSetting = Mono) then //if set at stereomode
Mouse(527, 433, 10, 10, mouse_left)
else
if (GetColor(527, 411) = 499676) and (SMSetting = Stereo) then
Mouse(527, 411, 10, 10, mouse_left);
Wait(100);
TypeByte(vk_Escape);
FreeBitmap(AudioMask);
end;

(*
Login_SetGraphics
~~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure Login_SetGraphics(Brightness: Integer);

Sets graphic options in the login screen.

.. note::

by ZephyrsFury, fixed by Markus

Example:

.. code-block:: pascal

Login_SetGraphics(4);

*)
procedure Login_SetGraphics(Brightness: Integer);
var
T, x, y, tx, ty, graphicsslice, i: Integer;
P: TPoint;
begin
if (LoggedIn) then Exit;
graphicsslice := BitmapFromString(28, 3, 'beNrLyMAKGBgYJ85Y' +
'dOfmw4VrdgPZaFJAdOniSSDacug8miwuAFSWWVAJVL9kzWqgsUA2X' +
'CPENKBUZXs3BBFjJsRAoPPguoAOhhsLJCEGerjZQRxsbaaFbgQAUH' +
'JlGA==');
TypeByte(vk_Escape);
T := GetSystemTime;
while (not(FindBitmapToleranceIn(graphicsslice, X, Y, 717, 458, 760, 498,10))) and (GetSystemTime - T < 5000) do
Wait(100);
if (FindBitmapToleranceIn(graphicsslice, X, Y, 717, 458, 760, 498, 10)) then
Mouse(X, Y, 20, 20, mouse_left)
else
begin
FreeBitmap(graphicsslice);
Exit;
end;
Wait(100);
if not (GetColor(340, 115) = SM_Color) then
for i := 0 to 2 do
begin
//Checks for the green arrow, clicks middle of box
Mouse(260, 162, 5, 5, mouse_left);
if WaitColor(340, 115, SM_Color, 0, 2000) then
Break;
if i = 2 then
begin
srl_Warn('SetGraphics', 'Failed to select Safe Mode', warn_Warning);
Exit;
end;
end;
if (Brightness > 4) then
srl_Warn('Login_SetGraphics', 'Brightness must be between 0 and 4', warn_AllVersions)
else
if (Brightness <> 0) then
begin
x := 0;
repeat
P := Point(328 + (Brightness-1) * 32, 222);//coords of some thing
if (GetColor(P.x, P.y) = 1315860) then
begin
Mouse(P.x, P.y, 3, 3, mouse_left);
if WaitColor(P.x, P.Y, 3976149, 1, 1000) then
break;
Inc(x);
end else
break;
until(x >= 5)
end;
repeat
if FindColor(x, y, 14790912, 361,234, 673,373) then //wtf is this
begin
Mouse(x + 10, y + 3, 10, 7, mouse_left);
getmousepos(tx, ty);
Mouse(tx, ty + 10, 4, 4, mouse_left);
wait(300);
end;
until(not(FindColor(x, y, 14790912, 361,234, 673,373)));
Wait(100);
TypeByte(vk_Escape);
FreeBitmap(graphicsslice);
end;

(*
SetAudioOff
~~~~~~~~~~~

.. code-block:: pascal

procedure SetAudioOff;

Sets the Audio to off (1 for each bar). Works logged in and out.

.. note::

by ZephyrsFury

Example:

.. code-block:: pascal

// sounds are annoying, let's turn them off
setAudioOff();
*)
procedure SetAudioOff;
begin
if (LoggedIn) then
SetAudio(1, 1, 1, NoChange)
else
Login_SetAudio(1, 1, 1, NoChange);
end;

(*
SetAutoingDefaults
~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure SetAutoingDefaults;

Sets the graphic options for best SRL compatibility. Works both logged in and out.

.. note::

by ZephyrsFury

Example:

.. code-block:: pascal

procedure SetupScript();
begin
SetAutoingDefaults(); // set the graphics options appropriately
end;

*)
procedure SetAutoingDefaults;
begin
if (LoggedIn) then
FixGraphics
else
Login_SetGraphics(4);
end;

(*
ValidEmail
~~~~~~~~~~

.. code-block:: pascal

function ValidEmail: Boolean;

Recognizes and handles the "Validate Email" screen in RS.

.. note::

by NCDS

Example:

.. code-block:: pascal

if not ValidEmial then
writeLn('Failed to get past verification screen');

*)
function ValidEmail: Boolean;
begin
while (getColor(473, 418) = 1001495) do
begin
//writeln('found email screen');
MouseBox(502, 424, 548, 435, mouse_left);
waitFunc(@lobbyScreen, 75, 3000);
end;
result := lobbyScreen;
end;

(*
ExitToLobby
~~~~~~~~~~~

.. code-block:: pascal

function ExitToLobby: Boolean;

Exits to the Lobby (for breaks?)

.. note::

by Starblaster100, Raymond, IceFire908, & Tarajunky

Example:

.. code-block:: pascal

// world switch!
if (ExitToLobby()) then
SelectWorld(20); // parameters here may be inaccurate

*)
function ExitToLobby: Boolean;
var
x, y, c, i: Integer;
begin
Result := LobbyScreen;
if Result = True then
Exit;
if SRL_HasProc(srl_OnExitToLobby) then
SRL_Procs[srl_OnExitToLobby]();
if (not (GameTab(tab_LogOut))) then
Exit;
Wait(200 + Random(100));
while (LoggedIn) and (c < 10) do
begin
Inc(c);
if(FindText(x, y, 'obb', UpCharsEx, MIX1, MIY1, MIX2, MIY2))then
begin
MouseBox(566, 346, 715, 373, mouse_left);
for i := 0 to 10 do
begin
Wait(1000);
if (not LobbyScreen) then
if validEmail then
begin
Result := True;
Exit;
end;
end;
end else
if(FindText(x, y, 'lick', UpCharsEx, MIX1, MIY1, MIX2, MIY2))then
begin
MouseBox(579, 367, 699, 386, mouse_left);
for i := 0 to 10 do
begin
Wait(1000);
if not(LoggedIn) then
begin
Result := True;
SRL_ResetNavBar;
Exit;
end;
end;
end
end;
end;

(*
LeaveLobby
~~~~~~~~~~

.. code-block:: pascal

function LeaveLobby: Boolean;

Logs you out from lobby screen.

.. note::

by IceFire908

Example:

.. code-block:: pascal

if (LobbyScreen()) then
if (not LeaveLobby()) then
WriteLn('Oh no, we didn''t make it out of the Lobby Screen.');

*)
function LeaveLobby: Boolean;
var
T: LongInt;
begin
T := GetSystemTime;
while ((not (Result)) and ((GetSystemTime - T) < 30000)) do
begin
MouseBox(678, 24, 699, 43, mouse_left);
Wait(RandomRange(1000, 2000));
Result := (not (LobbyScreen));
SRL_ResetNavBar;
end;
end;

(*
Logout
~~~~~~

.. code-block:: pascal

function Logout: Boolean;

Logs you all the way out from ingame.

.. note::

by Starblaster100, Raymond, IceFire908, Tarajunky & NCDS

Example:

.. code-block:: pascal

if (not FindTree()) then
Logout();

*)
function Logout: Boolean;
var
x, y, c, i: Integer;
begin
SRL_ExitedSquealOfFortune := false;

Result := (not (LoggedIn));
if (Result) then
Exit;
if SRL_HasProc(srl_OnLogOut) then
SRL_Procs[srl_OnLogOut]();
if (not (GameTab(tab_LogOut))) then
begin
CloseWindow();
if (not (GameTab(tab_LogOut))) then
Exit;
end;
Wait(200 + Random(100));
while (LoggedIn) and (c < 10) do
begin
Inc(c);
if(FindText(x, y, 'ogin', UpCharsEx, MIX1, MIY1, MIX2, MIY2))then
MouseBox(569, 393, 713, 418, mouse_left)
else
if(FindText(x, y, 'lick', UpCharsEx, MIX1, MIY1, MIX2, MIY2))then
MouseBox(569, 349, 713, 375, mouse_left);

for i := 0 to 10 do
begin
Wait(1000);
if not(LoggedIn) then
begin
Result := True;
SRL_ResetNavBar;
Exit;
end;
end;
end;
end;

(*
LoginPlayerToLob
~~~~~~~~~~~~~~~~

.. code-block:: pascal

function LoginPlayerToLob: Boolean;

Like LoginPlayer but only to the lobbyscreen.

.. note::

by SRL Dev Team

Example:

.. code-block:: pascal

LoginPlayerToLob();
if (not LobbyScreen()) then
LoginPlayerToLob(); // try again!

*)
function LoginPlayerToLob: Boolean;
var
RetryLogin: Boolean;
typtmp, t, w: integer;
Actions: TVariantArray;
Attempts: LongInt;
p: TPoint;
//ATPA: T2dPointArray;
TPA: TPointArray;
Boxes : TIntegerArray;
//B: TBox;
label
ProcStart;
begin
ActivateClient;
Wait(100);
TypeByte(vk_Escape);
Wait(500);

{Check for lobby screen already open/ already logged in}

Result := ((LobbyScreen) or (LoggedIn));
if (Result) then
Exit;

{Check for active player.}

if (not (Players[CurrentPlayer].Active)) then
begin
WriteLn('Player is not Active...');
if (AllPlayersInActive) then
begin
WriteLn('All players not active!');
Exit;
end;
NextPlayer(False);
Exit;
end;

{Wait for the client to finish loading.}

T := GetSystemTime;
repeat
if (RSReady) then
Break;
if ((GetSystemTime - T) > 180000) then
begin
WriteLn('It has been 3 minutes and Runescape is not yet ready... Terminating.');
TerminateScript;
end;
Wait(RandomRange(1000, 2000));
until (False);
WriteLn('Welcome to Runescape.');


{New graphics have changed box}
Case CountColor(LOGIN_TEXTCOLOUR, 198, 192, 567, 259) of
1079: MouseBox(347, 295, 414, 303, mouse_left);
1745: MouseBox(347, 305, 414, 312, mouse_left); { "Available graphics options have been changed..." }
1801: MouseBox(347, 305, 414, 312, mouse_left); { "There was a problem with your current graphics settings..." }
end;

{Click less info if needed.}
{
if (not (SimilarColors(GetColor(382, 11), 14285562, 20))) then //Runescae sword green bead
begin
MouseBox(212, 479, 550, 495, 1); //Less info button
Wait(RandomRange(1000, 2000));
end;
}
{Click Members/free.}

{Members := Players[CurrentPlayer].Member;
if (Length(Players[CurrentPlayer].WorldInfo) > 0) then
Members := Players[CurrentPlayer].WorldInfo[0]; }

ProcStart:

{if (Members) then
I := 1;

if (GetColor(248, 359) <> 1381653) then //Black outline on forgotten pwd button.
begin
FindColors(TPA, 9291999, 10, 370, 675, 475);
ATPA := SplitTPA(TPA, 4);
if (Length(ATPA) > 2) then
begin
if (I = 1) then
I := 0
else
I := 1;
B := GetTPABounds(ATPA[1 + I]); //If demo mode is still up
end
else
if (Length(ATPA) = 2) then
B := GetTPABounds(ATPA[0 + I]) //When there's no demo mode
else
B := IntToBox(210, 424, 367, 446);

with B do
MouseBox(X1 + 20, Y1 + 10, X2 - 20, Y2 + 8, 1);

T := GetSystemTime; //Black outline on forgotten pwd button.
while ((GetSystemTime - T < 3000) and (GetColor(248, 359) <> 1381653)) do
Wait(RandomRange(100, 200));

end; }

{Type in username and pass}

if (loggedIn) then
exit;

for W:= 0 to 1 do
begin
if W = 0 then
Boxes:= [UBX1, UBY1, UBX2, UBY2]
else
Boxes:= [PBX1, PBY1, PBX2, PBY2];

t := (getSystemTime + (60000 * 2));
FindColors(TPA, LOGIN_TEXTCOLOUR, Boxes[0], Boxes[1], Boxes[2], Boxes[3]);
repeat
if (Length(TPA) > 0) then
begin
SortTPAFrom(TPA, Point(Boxes[2], Boxes[1] + (Boxes[3] - Boxes[2]) div 2));
p := point(TPA[0].X + 20, TPA[0].Y);
if (not pointInBox(p, intToBox(Boxes[0], Boxes[1], Boxes[2], Boxes[3]))) then
p := point(UBX2 - (10 + random(10)), p.y);
Mouse(p.x, p.y, 5, 5, mouse_left);
end else
MouseBox(Boxes[0], Boxes[1], Boxes[2], Boxes[3], mouse_left);

typtmp := 0;
while (CountColor(LOGIN_TEXTCOLOUR, Boxes[0], Boxes[1], Boxes[2], Boxes[3]) > 0) do
begin
Inc(typtmp);
TypeByte(VK_BACK);
Wait(50+Random(50));
if (typtmp >= RandomRange(20, 24)) then
Break;
end;
until(not FindColors(TPA, LOGIN_TEXTCOLOUR, Boxes[0], Boxes[1], Boxes[2], Boxes[3]) or (getSystemTime > t));

Wait(100 + Random(200));
if W = 0 then
begin
WriteLn(Capitalize(Players[CurrentPlayer].Name));
TypeSend(Players[CurrentPlayer].Name);
end else
TypeSend(Players[CurrentPlayer].Pass);
Wait(800 + Random(50)); //Should fix the Login -> Spam Recoveries bug
end;

{Check responses}

T := GetSystemTime;
repeat
// so the lobby appears (gets rid of black screen)
if (countColorTolerance(clBlack, 0, 0, 500, 500, 20) > 245000) then
begin
wait(2000 + random(1500));
mouseBox(0, 0, 750, 490, mouse_Move);
end;
SRL_ResetNavBar;
result := validEmail; // To handle "Validate Email" screen
if result then
break;

SetLength(Actions, 0);

if ((GetSystemTime - T) > 60000) then
Actions := ['One minute has passed... Debug: ' + ToStr(CountColor(LOGIN_TEXTCOLOUR, 260, 140, 510, 400)), 0, 5, 'PlayerFalse', 'Login Failed']
else
case (CountColor(LOGIN_TEXTCOLOUR, 260, 140, 510, 400)) of //text colour points
// WriteLn Error Wait for Retrys Action Player[CurrentPlayer].Loc
763, 2348, 2299:
Actions := ['Invalid Username / Password', 0, 2, 'PlayerFalse', 'Wrong User/Pass'];
1088: Actions := ['Your account has been disabled', 0, 0, 'PlayerFalse', 'Acc Disabled'];
951: Actions := ['Your account is already logged in', 5000, 5, 'PlayerTrue', 'Already logged in'];
1239: Actions := ['Not a Members Account', 0, 1, 'PlayerTrue', ''];
364: Actions := ['Error Connecting.', 20000, 9, 'Terminate', 'Error Connecting'];
1057: Actions := ['Too many incorrect logins.', 5 * 60000, 2, 'PlayerFalse', 'Too many logins'];
732: Actions := ['Runescape has been updated.', 0, 0, 'RSUpdate', 'RS Updated'];
591: Actions := ['Client token changed.', 0, 0, 'RSUpdate', 'Client Token Changed'];
1606: Actions := ['Game session expired.', 0, 0, 'RSUpdate', 'Session Expired'];
777: Actions := ['Login limit exceeded.', 20000, 10, '', 'Waiting for login.'];
end;
{Respond}

if (Length(Actions) > 0) then
begin
WriteLn(Actions[0]);
if (Actions[0] <> 'Not a Members Account') then
begin
Wait(1000 + Random(500));
TypeByte(vk_Escape);
end;
Wait(Actions[1] + Random(100));
if (Actions[2] <> 0) then
if (Attempts < Actions[2]) or (Actions[2] = -1) then
begin
if (Actions[0] = 'Not a Members Account') then
begin
Players[CurrentPlayer].Member := False;
if (Length(Players[CurrentPlayer].WorldInfo) > 0) then
Players[CurrentPlayer].WorldInfo[0] := False;
MouseBox(267, 321, 496, 350, mouse_left); //Play free game instead button
Wait(3000 + Random(2000));
Result := True;
Exit;
end;
RetryLogin := True;
Wait(2000 + Random(1000));
Break;
end;
if (Actions[4] <> '') then
Players[CurrentPlayer].Loc := Actions[4];
case Actions[3] of
'PlayerFalse': NextPlayer(False);

'PlayerTrue':
begin
LeaveLobby();
NextPlayer(True);
end;

'Terminate': TerminateScript;

'RSUpdate':
begin
if SRL_HasProc(srl_OnRSUpdate) then
begin
case actions[0] of
'Runescape has been updated.':
begin
Writeln('Runescape has been updated! Waiting 5 minutes to restart SMART!');
Wait(300000);
end;
end;
SRL_Procs[srl_OnRSUpdate]();
Exit;
end;
Writeln('Runescape has been updated! Please restart Simba.');
TerminateScript;
end;
end;
Exit;
end;
Wait(100);
Result := (LobbyScreen) or (LoggedIn);
until (Result);

TakeIPScreen();

{Back to main screen if needed}

if (RetryLogin) then
begin
RetryLogin := False;
Inc(Attempts);
goto ProcStart;
end;

end;

(*
LoginPlayer
~~~~~~~~~~~

.. code-block:: pascal

function LoginPlayer: Boolean;

Logs in the Player[CurrentPlayer]. Detects most Client Login Errors

.. note::

by SRL Dev Team

Example:

.. code-block:: pascal

if (not LoggedIn()) then
begin
WriteLn('Error: Not Logged In! Fixing');
LoginPlayer();
end;

*)
function LoginPlayer: Boolean;
var
RetryLogin: Boolean;
Actions: TVariantArray;
T, Attempts: LongInt;
label
ProcStart;
begin
ProcStart:

if (not (Result)) then {Check if Logged in}
Result := LoggedIn;

if (Result) then
begin
Result := True;
AddToSRLLog('Current player: ' + Capitalize(Players[CurrentPlayer].Name));
SRL_ExitedSquealOfFortune := false;
PlayerStartTime := GetSystemTime; // PlayerStartTime
if SRL_HasProc(srl_OnLogIn) then
SRL_Procs[srl_OnLogIn]();

Exit;
end;

if (not (LoginPlayerToLob)) then {Get to lobby screen}
Exit;

Wait(500 + Random(500));
{World switching}

if Length(Players[CurrentPlayer].WorldInfo) > 0 then
if VariantIsBoolean(Players[CurrentPlayer].WorldInfo[0]) then
Players[CurrentPlayer].Member:= Players[CurrentPlayer].WorldInfo[0];

case Length(Players[CurrentPlayer].WorldInfo) of
1:
if VariantIsInteger(Players[CurrentPlayer].WorldInfo[0]) then
SelectWorld(Players[CurrentPlayer].WorldInfo[0]);

2:
SelectWorld(Players[CurrentPlayer].WorldInfo[1]);

3:
if (Players[CurrentPlayer].WorldInfo[1] = 0) then
SelectWorld(RandomWorld(Players[CurrentPlayer].WorldInfo[0], Players[CurrentPlayer].WorldInfo[2]))
else
SelectWorld(Players[CurrentPlayer].WorldInfo[1]);
end;
{Click Here to Play}

if (LobbyScreen) then
MouseBox(270, 450, 490, 470, mouse_left);

{Check responses}

T := GetSystemTime;
repeat

SetLength(Actions, 0);
if ((GetSystemTime - T) > 60000) then
Actions := ['One minute has passed... Debug: ' + ToStr(CountColor(LOGIN_TEXTCOLOUR, 260, 140, 510, 400)), 0, 0, 'NextPlayer', 'Login Failed']
else
case (CountColor(LOGIN_TEXTCOLOUR, 260, 140, 510, 400)) of //text colour points
// WriteLn Error Wait for Retrys Action Player[CurrentPlayer].Loc
364: Actions := ['Error Connecting.', 20000, 9, 'Terminate', 'Error Connecting'];
850: Actions := ['You need skill total of 1000.', 0, 9, 'PlayerTrue', '1000 skill club'];
1028: Actions := ['You are standing in a members-only area.', 0, 1, 'PlayerFalse', 'In Mems-Only Area'];
1239: Actions := ['Not a Members Account', 0, 1, 'PlayerFalse', 'Non-member'];
777: Actions := ['Login limit exceeded.', 0, 10, '', 'Waiting for login.'];
951: Actions := ['Your account is already logged in', 5000, 5, 'PlayerTrue', 'Already logged in'];
591: Actions := ['Client token changed.', 0, 0, 'RSUpdate', 'Client Token Changed'];
1606: Actions := ['Game session expired.', 0, 0, 'RSUpdate', 'Session Expired'];
-1: Actions := ['You need skill total of 1500.', 0, 9, 'PlayerTrue', '1500 skill club'];
-1: Actions := ['You need 20 combat for PvP', 0, 1, 'PlayerFalse', 'PvP warning'];
end;

if (CountColor(clWhite, 415, 336, 476, 356) = 82) then // HRW login button white colour points
begin
Wait(RandomRange(500, 1000));
if (Length(Players[CurrentPlayer].WorldInfo) > 2) then
begin
if (Players[CurrentPlayer].WorldInfo[2]) then
MouseBox(391, 361, 498, 383, mouse_left)
else begin
MouseBox(263, 362, 372, 383, mouse_left);
Players[CurrentPlayer].WorldInfo := [False, 0, AllowPVP];
RetryLogin := True;
Break;
end;
end
else
if (AllowPVP) then
MouseBox(391, 361, 498, 383, mouse_left)
else
MouseBox(263, 362, 372, 383, mouse_left);
Wait(3000 + Random(2000));
RetryLogin := true;
end;

{Respond}

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
case Actions[0] of
'You are standing in a members-only area.': begin
Players[CurrentPlayer].Member := True;
Players[CurrentPlayer].WorldInfo := [True, 0, AllowPVP];
end;
'You need 20 combat for PvP': Players[CurrentPlayer].WorldInfo := [Players[CurrentPlayer].Member, 0, False];
'Not a Members Account': begin
Players[CurrentPlayer].Member := False;
Players[CurrentPlayer].WorldInfo := [False, 0, AllowPVP];
end;
'Login limit exceeded.': begin
Writeln('Runescape is lagging or we''re logged in too many times. Keep trying!');
Players[CurrentPlayer].WorldInfo := [players[currentPlayer].member, 0, AllowPVP];
Wait(5000+Random(10000));
end;
'You need skill total of 1000.': players[currentPlayer].worldInfo := [players[currentPlayer].member, 0, allowPVP];
end;
RetryLogin := True;
Wait(2000 + Random(1000));
Break;
end;
if (Actions[4] <> '') then
Players[CurrentPlayer].Loc := Actions[4];
case Actions[3] of
'PlayerFalse': NextPlayer(False);
'PlayerTrue':
begin
LeaveLobby();
NextPlayer(True);
end;
'Terminate': TerminateScript;
'RSUpdate':
begin
wait(randomRange(1000, 1500));
typeByte(VK_ESCAPE);
leaveLobby();

if SRL_HasProc(srl_OnRSUpdate) then
begin
SRL_Procs[srl_OnRSUpdate]();
Exit;
end;
Writeln('Runescape has been updated! Please restart Simba.');
TerminateScript;
end;
end;
Exit;
end;
Wait(100);
Result := (LoggedIn);
until (Result);

{Back to lobby screen if needed}

if (RetryLogin) then
begin
RetryLogin := False;
Inc(Attempts);
goto ProcStart;
end;

{Set player start time ect...}

if (Result) then
goto ProcStart;

end;

(*
NextPlayerIndex
~~~~~~~~~~~~~~~

.. code-block:: pascal

function NextPlayerIndex: Integer;

Returns the player number of the next active player.

.. note::

by Dankness, Ron, Raymond & ZephyrsFury

Example:

.. code-block:: pascal

if (NextPlayerIndex() != -1) then
WriteLn('We still have active players!');

*)
function NextPlayerIndex: Integer;
begin
if (AllPlayersInactive) then
begin
Result := -1;
Exit;
end;
Result := (CurrentPlayer + 1) mod Length(Players);
while (Players[Result].Active = False) do
Result := (Result + 1) mod Length(Players);
end;

(*
RandomPlayerIndex
~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function RandomPlayerIndex: Integer;

Returns the player number of a random active player.

.. note::

by Dankness, Ron, Raymond & ZephyrsFury

Example:

.. code-block:: pascal

procedure NextPlayerRandom(Active: Boolean);
begin
Players[CurrentPlayer].Active := Active;
CurrentPlayer := RandomPlayerIndex();
if (CurrentPlayer = -1) then
begin
WriteLn('All players inactive..');
TerminateScript();
end;
end;

*)
function RandomPlayerIndex: Integer;
var
N: Integer;
begin
if (AllPlayersInactive) then
begin
Result := -1;
Exit;
end;
N := Random(Length(Players));
while (Players[N].Active = False) or (N = CurrentPlayer) do
begin
if (PlayersActive = 1) and (N = CurrentPlayer) then Break;
N := Random(Length(Players));
end;
Result := N;
end;

(*
SwitchToPlayer
~~~~~~~~~~~~~~

.. code-block:: pascal

function SwitchToPlayer(PlayerNo: Integer; Active: Boolean): Boolean;

Switches to a specific player, setting the current player's activity to True or False.

.. note::

by Dankness, Ron, Raymond & ZephyrsFury

Example:

.. code-block:: pascal

SwitchToPlayer(1, True);

*)
function SwitchToPlayer(PlayerNo: Integer; Active: Boolean): Boolean;
begin
WriteLn('SwitchToPlayer(PlayerNo: ' + IntToStr(PlayerNo) + ', Active: ' + BoolToStr(Active)+ ');');
Players[CurrentPlayer].Active := Active;
Logout;
if SRL_HasProc(srl_OnNextPlayer) then
SRL_Procs[srl_OnNextPlayer]();
PlayerCurTime := GetSystemTime;
Players[CurrentPlayer].Worked := Players[CurrentPlayer].Worked + (PlayerCurTime - PlayerStartTime);
CurrentPlayer := PlayerNo;
SRL_Logs := SRL_Logs + 1;
LoginPlayer;
Result := LoggedIn;
end;

(*
NextPlayer
~~~~~~~~~~

.. code-block:: pascal

procedure NextPlayer(Active: Boolean);

Logs in the next player that isn't inactive.
Boolean: True - Current player is ok. False - Current player is false.

.. note::

by ZephyrsFury

Example:

.. code-block:: pascal

NextPlayer(True);

*)
procedure NextPlayer(Active: Boolean);
var
srl_PlayerIndexFunc: function: Integer;
cP: Integer;
begin
if (RandomPlayer) then
srl_PlayerIndexFunc := @RandomPlayerIndex
else
srl_PlayerIndexFunc := @NextPlayerIndex;

WriteLn('NextPlayer(' + BoolToStr(Active) + ')');
LogOut;
cP := srl_PlayerIndexFunc();
while (cP = -1) do
begin
cP := srl_PlayerIndexFunc();
if SRL_HasProc(srl_InNextPlayerLoop) then
SRL_Procs[srl_InNextPlayerLoop]();
Wait(5000); //Endless loop
end;

SwitchToPlayer(cP, Active);
end;

(*
RandomNextPlayer
~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure RandomNextPlayer(Active: Boolean);

Logs in a random player that isn't inactive.
Boolean: True - Current player is ok. False - Current player is false.

.. note::

by ZephyrsFury

Example:

.. code-block:: pascal

RandomNextPlayer(True);

*)
procedure RandomNextPlayer(Active: Boolean);
var
tmpBool: Boolean;
begin
tmpBool := RandomPlayer;
RandomPlayer := True;
NextPlayer(Active);
RandomPlayer := tmpBool;
end;

(*
CheckUserNicks
~~~~~~~~~~~~~~

.. code-block:: pascal

procedure CheckUserNicks;

Checks if all nicks are set correct.

.. note::

by Sumilion, Raymond, and Nava2

Example:

.. code-block:: pascal

// make sure the user setup their nicks right..
CheckUserNicks();

*)

// TODO: Remove? Not used?
procedure CheckUserNicks;
var
I, II: Integer;
Wrong, FWrong: Boolean;
WarnStrings: TStringArray;
begin
WarnStrings := ['Please fill in your nickname.',
'Your nickname isn'' found in the players name'];

for i := 0 to HowManyPlayers - 1 do
for II := 0 to 1 do
begin
case II of
0: Wrong := (Players[i].Nick = '');
1: Wrong := (Pos(Players[i].nick, Capitalize(Players[i].name))<1);
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 http://www.villavu.com/forum/showthread.php?t=5410');
end;
end;

here is the error:

[Error] C:\Simba\Includes\SRL/SRL/core/login.simba(167:30): Unknown identifier 'SRL_OPTIONS_BITMAP' at line 166
Compiling failed.
Thank you very much!

YoHoJo

2013-03-05 00:15:50

You have no reason to be opening or clicking run on the login.simba script (if you are).
You just need to download a script from here:
http://villavu.com/forum/forumdisplay.php?f=516

Open it, Fill out the setup properly,and press play.

Then if you get an error, post the script you downloaded, along with the error.

leia

2013-03-05 00:28:33

oh no, I do not run the login script. When I run any other script, this login.simba script automatically opens in another tab and gives me this compile error. That is why I am confused :\ and I've tried with many many scripts.

Stayon

2013-03-05 00:34:14

Are you sure you're filling out your username/password in the correct area? I believe I had that happen to me before when I had the login stuff in the wrong spot lol.

leia

2013-03-05 00:41:19

hmm I don't think I need to fill that out at first right? I mean, I'm trying to test a simple Test Script just to see if smart8 is working right, and the login.simba script opens up with it's error. even with this simple script:

program TestScript;
{$DEFINE SMART8} //Using SMART8 Instead of SMART is very important
{$I SRL/SRL.Simba}

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

with Players[0] do
begin
Name := ''; // Player username
Pass := ''; // Player password
Active := True;
end;
end;

procedure SetupSmartClient;
begin
SRL_SixHourFix := True;
SMART_FixSpeed := True;

ClearDebug;
SetupSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
end;

begin
SetupSmartClient;

WriteLn('Finished, exiting ...');
end.

leia

2013-03-05 00:43:05

I did try putting in a username and password and it gave me the same

[Error] C:\Simba\Includes\SRL/SRL/core/login.simba(167:30): Unknown identifier 'SRL_OPTIONS_BITMAP' at line 166
Compiling failed.
error :[

leia

2013-03-05 01:09:56

Okay I have deduced that it is a Simba>Includes>SRL>SRL>core>login.simba problem. I know that I replaced the original login.simba and two other files in the SRL core because I read somewhere that it had to be done. Maybe this is the problem? if so, is there anyway I can revert the changes without having to reinstall simba?

YoHoJo

2013-03-05 01:10:48

Hmm that script works for me.
Simba> Help> About
What version are you at?

leia

2013-03-05 01:13:57

Simba is released under the GPL license.
You are currently using version: 992
Compiled with FPC version 2.4.4

D:

YoHoJo

2013-03-05 01:17:08

Delete your Simba folder.
Start over.
I have no clue. :D

leia

2013-03-05 01:19:18

aww haha not the solution I was looking for but you are definitely more experienced with this so I will obey. Thanks for your help! I will follow your guide once more after I start over! ;D

leia

2013-03-05 01:34:31

YoHoJo,
So I started over.. now, after setting up Smart8 and running the test script, the globals.simba script[simba>includes>srl>srl>core>globals.simba] pops up and gives me an error:

[Error] C:\Simba\Includes\SRL/SRL/core/globals.simba(696:5): Unknown identifier 'ImageSetClientArea' at line 695

The Mayor

2013-03-05 01:45:45

Does your script run if you use SMART 7.2 rather than SMART8?

YoHoJo

2013-03-05 01:54:10

Simba version?

leia

2013-03-05 02:07:46

992. okay I reinstalled everything again and it successfully executed with smart 7.2. this is a good sign. Thank you everyone. now I need to figure out the rest :\

leia

2013-03-05 02:24:19

oh thank YOU. smart 8 is working now. THANKSS :D