SRL Archive - Jr. Member General Help and Discussion

Help with Smart Parameters


Sawyer

2014-05-09 21:14:01

I am trying to load SMART in other languages other than english, and have switched the URL to the other language; however, I cannot figure out how to change the SMART Params to function correctly. I do not know what is causing an error, and any explanation of the parameters function is greatly appreciated. Thanks.

rj

2014-05-09 21:24:26

can you post your smart parameters

Sawyer

2014-05-09 21:26:08

From: Robert
can you post your smart parameters

I am doing something incorrectly. I wish to understand the function to correct it and be able to use it to help me learn Deutsch and such. Basically, all I have done is switch the URL. What can I do to switch the params?


const
SMART_URL = 'http://www.runescape.com/l=1/game';

function smartGetParameters(out params: TStringArray): boolean;
var
page: string;
begin
page := getPage(SMART_URL);

params := explode(',', between('<iframe id="game" src="', '"', page));

result := (length(params) = 2);

if (not result) then
begin
print('Error while grabbing parameters', TDebug.ERROR);
print('Make sure you can reach the RS website, and no active firewall is blocking Simba', TDebug.HINT);
exit(false);
end;

print('smartGetParameters(): Succesfully grabbed paramters', TDebug.SUB);
end;

rj

2014-05-09 21:49:24

When I saw the think it went to the english version, what error are you getting?

Sawyer

2014-05-09 21:56:30

From: Robert
When I saw the think it went to the english version, what error are you getting?


I am using the German URL, and it cannot grab the correct parameters.
EDIT: The link certainly does go to the German version.
@Frement Do you have any ideas? Thanks.
What can I do to grab the correct parameters for the German version of the game? What is different between the two versions?

[0:00:01]: -- setupSRL()
[0:00:01]: ---- Setting up SRL...
[0:00:01]: ---- initSmart():
[0:00:01]: ------ Attempting to pair to a previously spawned client
[0:00:01]: ------ smartPairToExistingClient():
[0:00:01]: -------- Found no free clients to pair to
[0:00:01]: ------ smartPairToExistingClient(): result = false
[0:00:01]: ------ Attempting to spawn a new client..
[0:00:01]: ------ smartCreateClient():
[0:00:01]: -------- ERROR: Error while grabbing parameters
[0:00:01]: -------- HINT: Make sure you can reach the RS website, and no active firewall is blocking Simba
[0:00:01]: -------- FATAL ERROR: Failed to grab parameters
[0:00:01]: Successfully executed.

Frement

2014-05-09 22:57:53

Hah, funny. Seems that there are 3 parameters, so changing
result := (length(params) = 2);
to
result := (length(params) = 3);
should fix it.

Sawyer

2014-05-09 23:06:19

From: Frement
Hah, funny. Seems that there are 3 parameters, so changing
result := (length(params) = 2);
to
result := (length(params) = 3);
should fix it.


Thank you. It did progress after that; however, I am still receiving an error. Here is the code:
[0:00:01]: -- setupSRL()
[0:00:01]: ---- Setting up SRL...
[0:00:01]: ---- initSmart():
[0:00:01]: ------ Attempting to pair to a previously spawned client
[0:00:01]: ------ smartPairToExistingClient():
[0:00:01]: -------- Found no free clients to pair to
[0:00:01]: ------ smartPairToExistingClient(): result = false
[0:00:01]: ------ Attempting to spawn a new client..
[0:00:01]: ------ smartCreateClient():
[0:00:02]: ---------- smartGetParameters(): Succesfully grabbed paramters
[0:00:02]: -------- getJavaPath():
[0:00:02]: ---------- Attempting to search for your Java path
[0:00:02]: ---------- Found your java path @ C:\Program Files (x86)\Java\jre7\bin\java.exe
[0:00:02]: -------- getJavaPath()
[0:00:02]: -------- Using parameters [http://world102.runescape.com/l=1/, j0, f2511085557353337060]
[0:00:02]: -------- Using plugins "opengl32.dll,d3d9.dll"
[0:00:12]: -------- FATAL ERROR: Failed to spawn a SMART client
[0:00:12]: Successfully executed.

The error appears to be occuring in the SmartCreateClient function here:
procedure smartCreateClient(w, h: integer);
var
plugins: string;
params: TStringArray;
path: string;
begin
print('smartCreateClient():', TDebug.HEADER);

if (not smartGetParameters(params)) then
print('Failed to grab parameters', TDebug.FATAL);

path := getJavaPath();
plugins := implode(',', smartPlugins);

print('Using parameters ' + toStr(params));
print('Using plugins "' + plugins + '"');

__smartCurrentTarget := 0;
__smartCurrentTarget := smartSpawnClient(path, stringReplace(PluginPath, '\', '/', [rfReplaceAll]),
params[0], ',' + params[1], w, h, smartInitSeq, '', '', plugins);

if (__smartCurrentTarget <> 0) then
begin
print('Succesfully spawned a client, attempting to target');

__smartCurrentPID := smartGetClientPID(__smartCurrentTarget);

if (smartSetAsTarget(__smartCurrentPID)) then
print('smartCreateClient(): result = true', TDebug.FOOTER);
end else
print('Failed to spawn a SMART client', TDebug.FATAL);
end;

Thank you for the help so far. Should I not be using the OpenGL plugins with the German version, or is it something else? Thanks.

Frement

2014-05-09 23:13:30

Try this:
  __smartCurrentTarget := smartSpawnClient(path, stringReplace(PluginPath, '\', '/', [rfReplaceAll]),
params[0], ',' + params[1] + ',' + params[2], w, h, smartInitSeq, '', '', plugins);

Sawyer

2014-05-09 23:20:39

From: Frement
Try this:
  __smartCurrentTarget := smartSpawnClient(path, stringReplace(PluginPath, '\', '/', [rfReplaceAll]),
params[0], ',' + params[1] + ',' + params[2], w, h, smartInitSeq, '', '', plugins);


That made it even farther as the console appeared for a few milliseconds, then disappeared. The debug box read:
[0:00:01]: -- setupSRL()
[0:00:01]: ---- Setting up SRL...
[0:00:01]: ---- initSmart():
[0:00:01]: ------ Attempting to pair to a previously spawned client
[0:00:01]: ------ smartPairToExistingClient():
[0:00:01]: -------- Found no free clients to pair to
[0:00:01]: ------ smartPairToExistingClient(): result = false
[0:00:01]: ------ Attempting to spawn a new client..
[0:00:01]: ------ smartCreateClient():
[0:00:01]: ---------- smartGetParameters(): Succesfully grabbed paramters
[0:00:01]: -------- getJavaPath():
[0:00:01]: ---------- Attempting to search for your Java path
[0:00:01]: ---------- Found your java path @ C:\Program Files (x86)\Java\jre7\bin\java.exe
[0:00:01]: -------- getJavaPath()
[0:00:01]: -------- Using parameters [http://world102.runescape.com/l=1/, j0, f20707290225340516]
[0:00:01]: -------- Using plugins "opengl32.dll,d3d9.dll"
[0:00:11]: -------- FATAL ERROR: Failed to spawn a SMART client
[0:00:11]: Successfully executed.
Thanks for the help, but it still is encountering errors. The console for SMART appears briefly, then is gone, and it reads the fatal error message. Do you have any other suggestions? Thanks.

Frement

2014-05-09 23:29:06

smart.simba
(*
Smart
=====

The Smart file stores all the functions and procedures used to initiate SMART
in scripts. To use SMART in a script, simply add the following code before SRL is
included.

.. code-block:: pascal

{$DEFINE SMART}

The source for this file can be found `here <https://github.com/SRL/SRL-6/blob/master/lib/misc/smart.simba>`_.

*)

{$loadlib libsmartremote}

{$include_once ../core/client.simba}

{$f-}

(*
const URL
~~~~~~~~~
The Runescape web address for SMART to load.
*)
const
//SMART_URL = 'http://www.runescape.com/game.ws?j=1';
SMART_URL = 'http://www.runescape.com/l=1/game';

(*
var SMART plugins
~~~~~~~~~~~~~~~~~
A TStringArray of smart plugins
*)
var
smartPlugins: TStringArray = ['OpenGL32.dll'];

(*
var User Set
~~~~~~~~~~~~

Variables that can be used in scripts.

* smartGetJavaPath - If enabled will attempt to find your java path
* smartShowConole - If enabled will show the java console else wont.
* smartForceNewClient - If enabled will skip attempting to pair to a previously spawned client
* smartEnableDrawing - If enabled will allow drawing on smart.
* smartInitSeq - Key that smart will press while smart is loading.

*)
var
smartGetJavaPath: boolean := true;
smartShowConsole: boolean := true;
smartForceNewClient: boolean := false;
smartEnableDrawing: boolean := false;
smartInitSeq: string := '';

{*
var Internal
~~~~~~~~~~~~

Internal SMART variables used only in smart.simba.
** Target <> PID. PID for identifying smarts. Target for targetting a specific applet and cleaning up.
* __smartCurrentPid: Keeps track of the current smart PID.
* __smartCurrentTarget: Keeps track of the current smart target.
* __smartIsDrawingSetup: Keeps track if smart drawing is setup or not.
* __smartNativeDebugButtonID: The id of the debug button (if not using a native button) set as -1.
* smartClientWidth, smartClientHeight - The dimensions of the smart client
* smartImage: TMufasaBitmap that is displayed onto smart.
*}
__smartCurrentPid: integer := 0;
__smartCurrentTarget: integer := 0;
__smartIsDrawingSetup: boolean := False;
__smartNativeDebugButtonID: integer := 101;
__smartClientWidth: integer := 800;
__smartClientHeight: integer := 600;
smartImage: TMufasaBitmap;

(*
findJavaPath
~~~~~~~~~~~~

.. code-block:: pascal

Function findJavaPath(out res: string): boolean;

Attempts to locate the users java path, will return if succesfull or not

.. note::

- By: Brandon
- Last Updated: August 26, 2013 by Olly

Example:

.. code-block:: pascal

findJavaPath(s);
*)
function findJavaPath(out res: string): boolean;

function GetDirectoryName(Directory, Path: String): String;
var
I: Integer;
Directories: TStringArray;
begin
Directories := GetDirectories(Path);

for I := 0 To High(Directories) Do
if ExecRegExpr(Directory, Directories[I]) then
if (Directories[I] > Result) then
Result := Directories[I];
end;

function FindDirectory(Directory, Path: String): Boolean;
begin
Result := Length(GetDirectoryName(Directory, Path)) > 0;
end;

var
Drive: String;
CurrentPath: String;
begin
result := false;
res := '';

drive := Copy(PluginPath, 0, 3);

if (FindDirectory('Program\sFiles\s\(x86\)', Drive)) then
begin
CurrentPath := Drive + 'Program Files (x86)\';
end else
CurrentPath := Drive + 'Program Files\';

if (FindDirectory('Java|java', CurrentPath + '\')) then
begin
CurrentPath := CurrentPath + 'Java\';
end else
begin
print('Failed To Find Path: ' + CurrentPath + 'Java\', TDebug.ERROR);
exit;
end;

Drive := GetDirectoryName('jre', CurrentPath);

if (length(drive) > 0) then
begin
if (smartShowConsole) then
CurrentPath := CurrentPath + Drive + '\bin\java.exe'
else
CurrentPath := CurrentPath + Drive + '\bin\javaw.exe';
end else
begin
Drive := GetDirectoryName('jdk', CurrentPath);

if (smartShowConsole) then
CurrentPath := CurrentPath + Drive + 'jre\bin\java.exe'
else
CurrentPath := CurrentPath + Drive + 'jre\bin\javaw.exe';
end;

result := FileExists(CurrentPath);
res := currentPath;
end;

(*
getJavaPath
~~~~~~~~~~~

.. code-block:: pascal

function getJavaPath(): string;

Will return the Java path needed for the first parameter of SmartSpawnClient.

.. note::

- By: Olly
- Last Updated: August 26, 2013 by Olly

Example:

.. code-block:: pascal

getJavaPath();
*)
function getJavaPath(): string;
begin
print('getJavaPath():', TDebug.HEADER);
{$IFDEF WINDOWS}
if (not smartGetJavaPath) then
begin
if (smartShowConsole) then
result := 'java.exe'
else
result := 'javaw.exe';

print('Not searching for your Java path. Make sure the JRE is in your system''s PATH before JDK (if you have JDK).', TDebug.WARNING);
print('getJavaPath()', TDebug.FOOTER);
exit();
end;

print('Attempting to search for your Java path');

if (findJavaPath(result)) then
print('Found your java path @ ' + result)
else begin
print('Failed to find your Java path', TDebug.WARNING);
print('If RS is failing to switch to OpenGL mode, add JRE to your systems path before JDK (if you have JDK)', TDebug.HINT);
end;
{$ELSE}
print('Not searching for your Java path. Make sure the JRE is in your system''s PATH before JDK (if you have JDK).', TDebug.WARNING);

Result := 'java';
if (not (smartShowConsole)) then
Result := Result + 'w';
{$ENDIF}
print('getJavaPath()', TDebug.FOOTER);
end;

(*
smartSetDebug; overload
~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure smartSetDebug(enable: boolean); overload;

Overloaded function that toggles the debug image on smart without need the target
parameter.

.. note::

- By: Olly
- Last Updated: August 26, 2013 by Olly

Example:

.. code-block:: pascal

smartSetDebug(true);
*)
procedure smartSetDebug(enable: boolean); overload;
begin
if (__smartNativeDebugButtonID <> -1) then
smartSetNativeButton(__smartCurrentTarget, 0, __smartNativeDebugButtonID, not enable)
else
smartSetDebug(__smartCurrentTarget, enable);
end;

(*
smartGetParameters
~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function smartGetParameters(out params: array of string): boolean;

Attempts to grab the correct parameters for spawning a SMART client. Results if
succesfull or not.

.. note::

- By: Brandon, Mormanman, Benland100
- Last Updated: May. 26, 2013 by Olly

Example:

.. code-block:: pascal

*)
function smartGetParameters(out params: TStringArray): boolean;
var
page: string;
begin
page := getPage(SMART_URL);

params := explode(',', between('<iframe id="game" src="', '"', page));

result := (length(params) = 3);

if (not result) then
begin
print('Error while grabbing parameters', TDebug.ERROR);
print('Make sure you can reach the RS website, and no active firewall is blocking Simba', TDebug.HINT);
exit(false);
end;

print('smartGetParameters(): Succesfully grabbed paramters', TDebug.SUB);
end;

(*
smartSetAsTarget
~~~~~~~~~~~~~~~~

.. code-block:: pascal

function smartSetAsTarget(pid: integer): boolean;

Pairs Simba to the smart client via EIOS.

.. note::

- By: Olly
- Last Updated: August 28, 2013 by Olly

Example:

.. code-block:: pascal

*)
function smartSetAsTarget(pid: Int32): boolean;
begin
result := true;

try
setEIOSTarget('libsmartremote', intToStr(pid));
print('smartSetAsTarget(): Succesfully set SMART['+ intToStr(pid) +'] as Simba''s target', TDebug.SUB);
except
print('smartSetAsTarget(): Failed to set SMART['+ intToStr(pid) +'] as Simba''s target', TDebug.SUB);
result := false;
end;
end;

(*
smartCreateClient
~~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure smartCreateClient(w, h: integer);

Creates a smart client using the dimensions "w" and "h".

.. note::

- By: Olly
- Last Updated: August 28, 2013 by Olly

Example:

.. code-block:: pascal

*)
procedure smartCreateClient(w, h: integer);
var
plugins: string;
params: TStringArray;
path: string;
begin
print('smartCreateClient():', TDebug.HEADER);

if (not smartGetParameters(params)) then
print('Failed to grab parameters', TDebug.FATAL);

path := getJavaPath();
plugins := implode(',', smartPlugins);

print('Using parameters ' + toStr(params));
print('Using plugins "' + plugins + '"');

__smartCurrentTarget := 0;
__smartCurrentTarget := smartSpawnClient(path, stringReplace(PluginPath, '\', '/', [rfReplaceAll]),
params[0], ',' + params[1] + ',' + params[2], w, h, smartInitSeq, '', '', plugins);

if (__smartCurrentTarget <> 0) then
begin
print('Succesfully spawned a client, attempting to target');

__smartCurrentPID := smartGetClientPID(__smartCurrentTarget);

if (smartSetAsTarget(__smartCurrentPID)) then
print('smartCreateClient(): result = true', TDebug.FOOTER);
end else
print('Failed to spawn a SMART client', TDebug.FATAL);
end;

(*
smartGetPIDs
~~~~~~~~~~~~

.. code-block:: pascal

function smartGetPIDs(): TIntegerArray;

Returns all true, non pair PIDs of smart clients.

.. note::

- By: Olly
- Last Updated: August 28, 2013 by Olly

Example:

.. code-block:: pascal

*)
function smartGetPIDs(): TIntegerArray;
var
i, count: Integer;
begin
count := SmartGetClients(true);
setLength(result, count);

if (count > 0) then
for i := 0 to (count - 1) do
result[i] := SmartGetAvailablePID(i);
end;

(*
smartPairToExistingClient
~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function smartPairToExistingClient(): boolean;

Attempts to pair us to a previously spawned smart client, will result true if
succesfull or not.

.. note::

- By: Olly
- Last Updated: August 28, 2013 by Olly

Example:

.. code-block:: pascal

*)
function smartPairToExistingClient(): boolean;
var
pidArr: TIntegerArray;
t: PtrUInt;
i, p: Int32;
begin
result := false;

print('smartPairToExistingClient():', TDebug.HEADER);

pidArr := smartGetPIDs();

if (length(pidArr) < 1) then
begin
print('Found no free clients to pair to');
print('smartPairToExistingClient(): result = false', TDebug.FOOTER);
exit();
end;

print('Found ' + intToStr(length(pidArr)) + ' free client(s), attempting to pair to one...');

for i := 0 to high(pidArr) do
begin
t := 0;
t := SmartPairClient(pidArr[i]);

if (t <> 0) then
begin
p := pidArr[i];

result := smartSetAsTarget(p);

if (result) then
begin
__smartCurrentPID := p;
__smartCurrentTarget := t;

if (not (smartEnabled(__smartCurrentTarget))) then
smartSetEnabled(__smartCurrentTarget, True);

print('Succesfully paired to a existing client, SMART['+ intToStr(__smartCurrentPID) +']');
print('smartPairToExistingClient(): result = true', TDebug.FOOTER);
addOnTerminate('smartFreeCurrentClient');
exit();
end;
end else begin
print('Failed to pair to SMART['+ intToStr(pidArr[i]) +']');
smartFreeClient(t);
end;
end;

print('smartPairToExistingClient(): result = false', TDebug.FOOTER);
end;

(*
initSmart
~~~~~~~~~

.. code-block:: pascal

procedure initSmart();

Initializes us to a SMART client, will attempt to pair to a existing client, if
that fails we will attempt to spawn a client, will terminate the script if anything
goes wrong.

.. note::

- By: Olly
- Last Updated: August 26, 2013 by Olly

Example:

.. code-block:: pascal

*)
procedure initSmart(forceNew: boolean);
begin
print('initSmart():', TDebug.HEADER);

if (not forceNew) then
begin
print('Attempting to pair to a previously spawned client');

if (smartPairToExistingClient()) then
begin
print('Succesfully initialized via pairing to a previously spawned client');
print('initSmart()', TDebug.FOOTER);
exit();
end;
end;

print('Attempting to spawn a new client..');

smartCreateClient(__smartClientWidth, __smartClientHeight);

print('Succesfully initialized via spawning a new client');

smartSetDebug(false);
addOnTerminate('smartFreeCurrentClient');

print('initSmart()', TDebug.FOOTER);
end;

(*
smartFreeCurrentClient
~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure smartFreeCurrentClient();

Free's our current smart client.

.. note::

- By: Olly
- Last Updated: August 28, 2013 by Olly

Example:

.. code-block:: pascal

*)
procedure smartFreeCurrentClient();
begin
try
smartFreeClient(__smartCurrentTarget);
print('Succesfully freed SMART[' + intToStr(__smartCurrentPid) + ']');
except
print('Error freeing SMART[' + intToStr(__smartCurrentPid) + ']', TDebug.ERROR);
end;
end;

(*
smartSetupDrawing
~~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure smartSetupDrawing();

Setups SMART so its ready to be drawn on-to.

.. note::

- By: Olly
- Last Updated: August 28, 2013 by Olly

Example:

.. code-block:: pascal

*)
procedure smartSetupDrawing();
begin
if (__smartIsDrawingSetup) then
exit();

smartSetDebug(true);

try
smartImage.init(Client.getMBitmaps());
smartImage.setName('SMART Debug Image');
smartImage.setPersistentMemory(SmartDebugArray(__smartCurrentTarget), __smartClientWidth, __smartClientHeight);
smartImage.drawClear(0);

print('smartSetupDrawing(): Succesfully setup SMART drawing', TDebug.SUB);
except
print('smartSetupDrawing(): Unable to setup SMART drawing', TDebug.FATAL);
end;

__smartIsDrawingSetup := true;
addOnTerminate('smartFreeDrawing');
end;

(*
smartFreeDrawing
~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure smartFreeDrawing();

Frees the TMufasaBitmap used for smart drawing.

.. note::

- By: Olly
- Last Updated: August 28, 2013 by Olly

Example:

.. code-block:: pascal

*)
procedure smartFreeDrawing();
begin
try
smartImage.resetPersistentMemory();
smartImage.free();
except finally
__smartIsDrawingSetup := false;
end;
end;

(*
smartReloadClient
~~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure smartReloadClient();

Kills the current client, and spawns a new one, parameter 'waitTime' is how long
we will wait before spawning a new client after killing our current.

.. note::

- By: Olly
- Last Updated: September 20, 2013 by Olly

Example:

.. code-block:: pascal

*)
procedure smartReloadClient(waitTime: integer);
var
img, r: integer;
begin
print('smartReloadClient()', TDebug.HEADER);
img := -999;

if (__smartIsDrawingSetup) then
begin
img := copyBitmap(smartImage.getIndex());
smartFreeDrawing();
end;

r := SmartGetRefresh(__smartCurrentTarget);

smartFreeCurrentClient();
smartKillClient(__smartCurrentPID);

print('Killed our current client, waiting ' + intToStr(waitTime) + ' ms before reloading client');
wait(waitTime);

initSmart(true);

print('Setting refresh rate back to ' + intToStr(r));
SmartSetRefresh(__smartCurrentTarget, r);

if (bitmapExists(img)) then
begin
smartSetupDrawing();

print('Re-drawing the smartImage bitmap');

getMufasaBitmap(img).drawTransparent(0, 0, smartImage);
freeBitmap(img);
end;

print('smartReloadClient()', TDebug.FOOTER);
end;

(*
sixHourFix
~~~~~~~~~~

.. code-block:: pascal

procedure sixHourFix();

Kills the current client, and spawns a new one.

.. note::

- By: Olly
- Last Updated: September 2, 2013 by Olly

Example:

.. code-block:: pascal

*)
procedure sixHourFix();
begin
print('sixHourFix():', TDebug.HEADER);

if (players.getActive() < 1) then
print('No active players, no use in reloading the client!', TDebug.FATAL);

smartReloadClient((5 * 60000) + random(15000));

if (waitClientReady()) then
begin
print('Client succesfully loaded after reload');

if (players[currentPlayer].login()) then
begin
print('Succesfully logged in after client was reloaded');
print('sixHourFix()', TDebug.FOOTER);
exit();
end else
print('Failed to login player after restart', TDebug.FATAL);
end else
print('Client never reloaded after restart..', TDebug.FATAL);
end;

begin
SRL_Events[EVENT_RS_UPDATE] := sixHourFix;

{$IFDEF WINDOWS}
// check for the plugin on compile
if (not fileExists(PluginPath + 'OpenGL32.dll')) then
print('SMART - Unable to find OpenGL32.dll (plugin required for SRL to work with SMART)', TDebug.FATAL);
{$ENDIF}
end;
There you go.

Sawyer

2014-05-09 23:32:16

From: Frement

There you go.


@Frement I have tried using that smart file, but it is still encountering a Fatal error. I will try a re-install.

EDIT: I re-installed, and still could not get past the fatal error, even with your smart file. My other installation of simba works with normal runescape, however. I am puzzled as to why mine is not working.

Frement

2014-05-09 23:50:53

From: Sawyer
@Frement I have tried using that smart file, but it is still encountering a Fatal error. I will try a re-install.

EDIT: I re-installed, and still could not get past the fatal error, even with your smart file. My other installation of simba works with normal runescape, however. I am puzzled as to why mine is not working.


Weird, works fine for me.

Sawyer

2014-05-09 23:53:33

From: Frement
Weird, works fine for me.


I have switched my smart file for yours, and it gives me a fatal error. We have the same SMART version, and the same smart code. I do not know why my smart is not working. maybe @Janilabo or @Brandon knows.. I am puzzled.

Frement

2014-05-09 23:57:30

Works fine for me on a fresh install too.
Compiled successfully in 1123 ms.
-- setupSRL()
---- Setting up SRL...
---- initSmart():
------ Attempting to pair to a previously spawned client
------ smartPairToExistingClient():
-------- Found 1 free client(s), attempting to pair to one...
-------- Failed to pair to SMART[14144]
------ smartPairToExistingClient(): result = false
------ Attempting to spawn a new client..
------ smartCreateClient():
---------- smartGetParameters(): Succesfully grabbed paramters
-------- getJavaPath():
---------- Attempting to search for your Java path
---------- Found your java path @ C:\Program Files (x86)\Java\jre7\bin\java.exe
-------- getJavaPath()
-------- Using parameters [http://world102.runescape.com/l=1/, j0, f3093899731012543973]
-------- Using plugins "OpenGL32.dll"
-------- Succesfully spawned a client, attempting to target
---------- smartSetAsTarget(): Succesfully set SMART[15172] as Simba's target
------ smartCreateClient(): result = true
------ Succesfully initialized via spawning a new client
---- initSmart()
---- Waiting up to 5 minutes for RS to load...
------ __setInputBoxes(): Set username and password boxes
---- Client is ready.
---- Setup SRL in 13276ms.
-- setupSRL(): True
-- Succesfully freed SMART[15172]
Successfully executed.

Sawyer

2014-05-10 00:05:02

From: Frement
Works fine for me on a fresh install too.


Could you possibly send me a link to your freshly installed Simba Folder that works? I do not know why mine does not. Here is my code that calls for SMART in my script:
procedure Setup_Script;
var
i: Integer;
begin
SetScriptProp(SP_WriteTimeStamp, [True]);

{$IFDEF SMART}
smartPlugins := ['opengl32.dll', 'd3d9.dll']; //
smartShowConsole := false;
{$ENDIF}

SetupSRL;
{$IFNDEF SMART}ActivateClient;{$ENDIF}

DeclarePlayers;
end;

Am I doing something incorrectly here?

Frement

2014-05-10 00:06:19

I'm just testing with this:
program new;
{$define smart}
{$I srl-6/srl.simba}
begin
setupsrl;
end.

Sawyer

2014-05-10 00:10:25

From: Frement
I'm just testing with this:
program new;
{$define smart}
{$I srl-6/srl.simba}
begin
setupsrl;
end.


I have tried that and it still reads the above error messages.

Brandon

2014-05-10 13:22:01

For german you can use the following.. The only thing I changed was the URL and it worked. SMART_URL = 'http://www.runescape.com/l=1/game.ws?j=1';

I didn't touch anything else but I believe what Frement posted with the commas should be right.


(*
Smart
=====

The Smart file stores all the functions and procedures used to initiate SMART
in scripts. To use SMART in a script, simply add the following code before SRL is
included.

.. code-block:: pascal

{$DEFINE SMART}

The source for this file can be found `here <https://github.com/SRL/SRL-6/blob/master/lib/misc/smart.simba>`_.

*)

{$loadlib libsmartremote}

{$include_once ../core/client.simba}

{$f-}

(*
const URL
~~~~~~~~~
The Runescape web address for SMART to load.
*)
const
SMART_URL = 'http://www.runescape.com/l=1/game.ws?j=1';

(*
var SMART plugins
~~~~~~~~~~~~~~~~~
A TStringArray of smart plugins
*)
var
smartPlugins: TStringArray = ['OpenGL32.dll'];

(*
var User Set
~~~~~~~~~~~~

Variables that can be used in scripts.

* smartGetJavaPath - If enabled will attempt to find your java path
* smartShowConole - If enabled will show the java console else wont.
* smartForceNewClient - If enabled will skip attempting to pair to a previously spawned client
* smartEnableDrawing - If enabled will allow drawing on smart.
* smartInitSeq - Key that smart will press while smart is loading.

*)
var
smartGetJavaPath: boolean := true;
smartShowConsole: boolean := true;
smartForceNewClient: boolean := false;
smartEnableDrawing: boolean := false;
smartInitSeq: string := '';

{*
var Internal
~~~~~~~~~~~~

Internal SMART variables used only in smart.simba.
** Target <> PID. PID for identifying smarts. Target for targetting a specific applet and cleaning up.
* __smartCurrentPid: Keeps track of the current smart PID.
* __smartCurrentTarget: Keeps track of the current smart target.
* __smartIsDrawingSetup: Keeps track if smart drawing is setup or not.
* __smartNativeDebugButtonID: The id of the debug button (if not using a native button) set as -1.
* smartClientWidth, smartClientHeight - The dimensions of the smart client
* smartImage: TMufasaBitmap that is displayed onto smart.
*}
__smartCurrentPid: integer := 0;
__smartCurrentTarget: integer := 0;
__smartIsDrawingSetup: boolean := False;
__smartNativeDebugButtonID: integer := 101;
__smartClientWidth: integer := 800;
__smartClientHeight: integer := 600;
smartImage: TMufasaBitmap;

(*
findJavaPath
~~~~~~~~~~~~

.. code-block:: pascal

Function findJavaPath(out res: string): boolean;

Attempts to locate the users java path, will return if succesfull or not

.. note::

- By: Brandon
- Last Updated: August 26, 2013 by Olly

Example:

.. code-block:: pascal

findJavaPath(s);
*)
function findJavaPath(out res: string): boolean;

function GetDirectoryName(Directory, Path: String): String;
var
I: Integer;
Directories: TStringArray;
begin
Directories := GetDirectories(Path);

for I := 0 To High(Directories) Do
if ExecRegExpr(Directory, Directories[I]) then
if (Directories[I] > Result) then
Result := Directories[I];
end;

function FindDirectory(Directory, Path: String): Boolean;
begin
Result := Length(GetDirectoryName(Directory, Path)) > 0;
end;

var
Drive: String;
CurrentPath: String;
begin
result := false;
res := '';

drive := Copy(PluginPath, 0, 3);

if (FindDirectory('Program\sFiles\s\(x86\)', Drive)) then
begin
CurrentPath := Drive + 'Program Files (x86)\';
end else
CurrentPath := Drive + 'Program Files\';

if (FindDirectory('Java|java', CurrentPath + '\')) then
begin
CurrentPath := CurrentPath + 'Java\';
end else
begin
print('Failed To Find Path: ' + CurrentPath + 'Java\', TDebug.ERROR);
exit;
end;

Drive := GetDirectoryName('jre', CurrentPath);

if (length(drive) > 0) then
begin
if (smartShowConsole) then
CurrentPath := CurrentPath + Drive + '\bin\java.exe'
else
CurrentPath := CurrentPath + Drive + '\bin\javaw.exe';
end else
begin
Drive := GetDirectoryName('jdk', CurrentPath);

if (smartShowConsole) then
CurrentPath := CurrentPath + Drive + 'jre\bin\java.exe'
else
CurrentPath := CurrentPath + Drive + 'jre\bin\javaw.exe';
end;

result := FileExists(CurrentPath);
res := currentPath;
end;

(*
getJavaPath
~~~~~~~~~~~

.. code-block:: pascal

function getJavaPath(): string;

Will return the Java path needed for the first parameter of SmartSpawnClient.

.. note::

- By: Olly
- Last Updated: August 26, 2013 by Olly

Example:

.. code-block:: pascal

getJavaPath();
*)
function getJavaPath(): string;
begin
print('getJavaPath():', TDebug.HEADER);
{$IFDEF WINDOWS}
if (not smartGetJavaPath) then
begin
if (smartShowConsole) then
result := 'java.exe'
else
result := 'javaw.exe';

print('Not searching for your Java path. Make sure the JRE is in your system''s PATH before JDK (if you have JDK).', TDebug.WARNING);
print('getJavaPath()', TDebug.FOOTER);
exit();
end;

print('Attempting to search for your Java path');

if (findJavaPath(result)) then
print('Found your java path @ ' + result)
else begin
print('Failed to find your Java path', TDebug.WARNING);
print('If RS is failing to switch to OpenGL mode, add JRE to your systems path before JDK (if you have JDK)', TDebug.HINT);
end;
{$ELSE}
print('Not searching for your Java path. Make sure the JRE is in your system''s PATH before JDK (if you have JDK).', TDebug.WARNING);

Result := 'java';
if (not (smartShowConsole)) then
Result := Result + 'w';
{$ENDIF}
print('getJavaPath()', TDebug.FOOTER);
end;

(*
smartSetDebug; overload
~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure smartSetDebug(enable: boolean); overload;

Overloaded function that toggles the debug image on smart without need the target
parameter.

.. note::

- By: Olly
- Last Updated: August 26, 2013 by Olly

Example:

.. code-block:: pascal

smartSetDebug(true);
*)
procedure smartSetDebug(enable: boolean); overload;
begin
if (__smartNativeDebugButtonID <> -1) then
smartSetNativeButton(__smartCurrentTarget, 0, __smartNativeDebugButtonID, not enable)
else
smartSetDebug(__smartCurrentTarget, enable);
end;

(*
smartGetParameters
~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function smartGetParameters(out params: array of string): boolean;

Attempts to grab the correct parameters for spawning a SMART client. Results if
succesfull or not.

.. note::

- By: Brandon, Mormanman, Benland100
- Last Updated: May. 26, 2013 by Olly

Example:

.. code-block:: pascal

*)
function smartGetParameters(out params: TStringArray): boolean;
var
page: string;
begin
page := getPage(SMART_URL);

params := explode(',', between('<iframe id="game" src="', '"', page));

result := (length(params) = 2);

if (not result) then
begin
print('Error while grabbing parameters', TDebug.ERROR);
print('Make sure you can reach the RS website, and no active firewall is blocking Simba', TDebug.HINT);
exit(false);
end;

print('smartGetParameters(): Succesfully grabbed paramters', TDebug.SUB);
end;

(*
smartSetAsTarget
~~~~~~~~~~~~~~~~

.. code-block:: pascal

function smartSetAsTarget(pid: integer): boolean;

Pairs Simba to the smart client via EIOS.

.. note::

- By: Olly
- Last Updated: August 28, 2013 by Olly

Example:

.. code-block:: pascal

*)
function smartSetAsTarget(pid: Int32): boolean;
begin
result := true;

try
setEIOSTarget('libsmartremote', intToStr(pid));
print('smartSetAsTarget(): Succesfully set SMART['+ intToStr(pid) +'] as Simba''s target', TDebug.SUB);
except
print('smartSetAsTarget(): Failed to set SMART['+ intToStr(pid) +'] as Simba''s target', TDebug.SUB);
result := false;
end;
end;

(*
smartCreateClient
~~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure smartCreateClient(w, h: integer);

Creates a smart client using the dimensions "w" and "h".

.. note::

- By: Olly
- Last Updated: August 28, 2013 by Olly

Example:

.. code-block:: pascal

*)
procedure smartCreateClient(w, h: integer);
var
plugins: string;
params: TStringArray;
path: string;
begin
print('smartCreateClient():', TDebug.HEADER);

if (not smartGetParameters(params)) then
print('Failed to grab parameters', TDebug.FATAL);

path := getJavaPath();
//path := 'C:/Program Files/Java/jre8/bin/java.exe';
plugins := implode(',', smartPlugins);

print('Using parameters ' + toStr(params));
print('Using plugins "' + plugins + '"');

__smartCurrentTarget := 0;
__smartCurrentTarget := smartSpawnClient(path, stringReplace(PluginPath, '\', '/', [rfReplaceAll]),
params[0], ',' + params[1], w, h, smartInitSeq, '', '', plugins);

if (__smartCurrentTarget <> 0) then
begin
print('Succesfully spawned a client, attempting to target');

__smartCurrentPID := smartGetClientPID(__smartCurrentTarget);

if (smartSetAsTarget(__smartCurrentPID)) then
print('smartCreateClient(): result = true', TDebug.FOOTER);
end else
print('Failed to spawn a SMART client', TDebug.FATAL);
end;

(*
smartGetPIDs
~~~~~~~~~~~~

.. code-block:: pascal

function smartGetPIDs(): TIntegerArray;

Returns all true, non pair PIDs of smart clients.

.. note::

- By: Olly
- Last Updated: August 28, 2013 by Olly

Example:

.. code-block:: pascal

*)
function smartGetPIDs(): TIntegerArray;
var
i, count: Integer;
begin
count := SmartGetClients(true);
setLength(result, count);

if (count > 0) then
for i := 0 to (count - 1) do
result[i] := SmartGetAvailablePID(i);
end;

(*
smartPairToExistingClient
~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function smartPairToExistingClient(): boolean;

Attempts to pair us to a previously spawned smart client, will result true if
succesfull or not.

.. note::

- By: Olly
- Last Updated: August 28, 2013 by Olly

Example:

.. code-block:: pascal

*)
function smartPairToExistingClient(): boolean;
var
pidArr: TIntegerArray;
t: PtrUInt;
i, p: Int32;
begin
result := false;

print('smartPairToExistingClient():', TDebug.HEADER);

pidArr := smartGetPIDs();

if (length(pidArr) < 1) then
begin
print('Found no free clients to pair to');
print('smartPairToExistingClient(): result = false', TDebug.FOOTER);
exit();
end;

print('Found ' + intToStr(length(pidArr)) + ' free client(s), attempting to pair to one...');

for i := 0 to high(pidArr) do
begin
t := 0;
t := SmartPairClient(pidArr[i]);

if (t <> 0) then
begin
p := pidArr[i];

result := smartSetAsTarget(p);

if (result) then
begin
__smartCurrentPID := p;
__smartCurrentTarget := t;

if (not (smartEnabled(__smartCurrentTarget))) then
smartSetEnabled(__smartCurrentTarget, True);

print('Succesfully paired to a existing client, SMART['+ intToStr(__smartCurrentPID) +']');
print('smartPairToExistingClient(): result = true', TDebug.FOOTER);
addOnTerminate('smartFreeCurrentClient');
exit();
end;
end else begin
print('Failed to pair to SMART['+ intToStr(pidArr[i]) +']');
smartFreeClient(t);
end;
end;

print('smartPairToExistingClient(): result = false', TDebug.FOOTER);
end;

(*
initSmart
~~~~~~~~~

.. code-block:: pascal

procedure initSmart();

Initializes us to a SMART client, will attempt to pair to a existing client, if
that fails we will attempt to spawn a client, will terminate the script if anything
goes wrong.

.. note::

- By: Olly
- Last Updated: August 26, 2013 by Olly

Example:

.. code-block:: pascal

*)
procedure initSmart(forceNew: boolean);
begin
print('initSmart():', TDebug.HEADER);

if (not forceNew) then
begin
print('Attempting to pair to a previously spawned client');

if (smartPairToExistingClient()) then
begin
print('Succesfully initialized via pairing to a previously spawned client');
print('initSmart()', TDebug.FOOTER);
exit();
end;
end;

print('Attempting to spawn a new client..');

smartCreateClient(__smartClientWidth, __smartClientHeight);

print('Succesfully initialized via spawning a new client');

smartSetDebug(false);
addOnTerminate('smartFreeCurrentClient');

print('initSmart()', TDebug.FOOTER);
end;

(*
smartFreeCurrentClient
~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure smartFreeCurrentClient();

Free's our current smart client.

.. note::

- By: Olly
- Last Updated: August 28, 2013 by Olly

Example:

.. code-block:: pascal

*)
procedure smartFreeCurrentClient();
begin
try
smartFreeClient(__smartCurrentTarget);
print('Succesfully freed SMART[' + intToStr(__smartCurrentPid) + ']');
except
print('Error freeing SMART[' + intToStr(__smartCurrentPid) + ']', TDebug.ERROR);
end;
end;

(*
smartSetupDrawing
~~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure smartSetupDrawing();

Setups SMART so its ready to be drawn on-to.

.. note::

- By: Olly
- Last Updated: August 28, 2013 by Olly

Example:

.. code-block:: pascal

*)
procedure smartSetupDrawing();
begin
if (__smartIsDrawingSetup) then
exit();

smartSetDebug(true);

try
smartImage.init(Client.getMBitmaps());
smartImage.setName('SMART Debug Image');
smartImage.setPersistentMemory(SmartDebugArray(__smartCurrentTarget), __smartClientWidth, __smartClientHeight);
smartImage.drawClear(0);

print('smartSetupDrawing(): Succesfully setup SMART drawing', TDebug.SUB);
except
print('smartSetupDrawing(): Unable to setup SMART drawing', TDebug.FATAL);
end;

__smartIsDrawingSetup := true;
addOnTerminate('smartFreeDrawing');
end;

(*
smartFreeDrawing
~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure smartFreeDrawing();

Frees the TMufasaBitmap used for smart drawing.

.. note::

- By: Olly
- Last Updated: August 28, 2013 by Olly

Example:

.. code-block:: pascal

*)
procedure smartFreeDrawing();
begin
try
smartImage.resetPersistentMemory();
smartImage.free();
except finally
__smartIsDrawingSetup := false;
end;
end;

(*
smartReloadClient
~~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure smartReloadClient();

Kills the current client, and spawns a new one, parameter 'waitTime' is how long
we will wait before spawning a new client after killing our current.

.. note::

- By: Olly
- Last Updated: September 20, 2013 by Olly

Example:

.. code-block:: pascal

*)
procedure smartReloadClient(waitTime: integer);
var
img, r: integer;
begin
print('smartReloadClient()', TDebug.HEADER);
img := -999;

if (__smartIsDrawingSetup) then
begin
img := copyBitmap(smartImage.getIndex());
smartFreeDrawing();
end;

r := SmartGetRefresh(__smartCurrentTarget);

smartFreeCurrentClient();
smartKillClient(__smartCurrentPID);

print('Killed our current client, waiting ' + intToStr(waitTime) + ' ms before reloading client');
wait(waitTime);

initSmart(true);

print('Setting refresh rate back to ' + intToStr(r));
SmartSetRefresh(__smartCurrentTarget, r);

if (bitmapExists(img)) then
begin
smartSetupDrawing();

print('Re-drawing the smartImage bitmap');

getMufasaBitmap(img).drawTransparent(0, 0, smartImage);
freeBitmap(img);
end;

print('smartReloadClient()', TDebug.FOOTER);
end;

(*
sixHourFix
~~~~~~~~~~

.. code-block:: pascal

procedure sixHourFix();

Kills the current client, and spawns a new one.

.. note::

- By: Olly
- Last Updated: September 2, 2013 by Olly

Example:

.. code-block:: pascal

*)
procedure sixHourFix();
begin
print('sixHourFix():', TDebug.HEADER);

if (players.getActive() < 1) then
print('No active players, no use in reloading the client!', TDebug.FATAL);

smartReloadClient((5 * 60000) + random(15000));

if (waitClientReady()) then
begin
print('Client succesfully loaded after reload');

if (players[currentPlayer].login()) then
begin
print('Succesfully logged in after client was reloaded');
print('sixHourFix()', TDebug.FOOTER);
exit();
end else
print('Failed to login player after restart', TDebug.FATAL);
end else
print('Client never reloaded after restart..', TDebug.FATAL);
end;

begin
SRL_Events[EVENT_RS_UPDATE] := sixHourFix;

{$IFDEF WINDOWS}
// check for the plugin on compile
if (not fileExists(PluginPath + 'OpenGL32.dll')) then
print('SMART - Unable to find OpenGL32.dll (plugin required for SRL to work with SMART)', TDebug.FATAL);
{$ENDIF}
end;

Sawyer

2014-05-10 14:55:15

From: Brandon
For german you can use the following.. The only thing I changed was the URL and it worked. SMART_URL = 'http://www.runescape.com/l=1/game.ws?j=1';

I didn't touch anything else but I believe what Frement posted with the commas should be right.



@Brandon
I honestly have no clue why mine does not work. I have re-installed Simba, and used the above smart files. It just keeps having a fatal error. Is my smart not up to date, or am I not using a correct plugin? I would really like to load smart in the other language, and yet I keep encountering an error. I have reinstalled simba and replaced the smart file, but it never spawns a client.

Sawyer

2014-05-11 16:53:16

Issue resolved