Log in

View Full Version : Very strange SMART client window issue.



msemtex
08-07-2012, 01:15 PM
Hi, My problem is that I'm trying to run 3 scripts on 3 separate simba programs. When I run each of them sometimes they use 3 individual SMART windows (which is fine). But, sometimes all of the scripts try to run on one window. Which causes the login and mouse movements to be crazy. If 3 individual SMART windows are open and one script fails. I re-run that script and it tries to use a SMART window that is being used by another script.

Hope I have been clear,

Matt

P1ng
08-07-2012, 01:21 PM
Are you using SMART v7.2 or 8.0? I think this error was resolved in the 8.0 update

msemtex
08-07-2012, 01:22 PM
I'am using 7.2 I was unaware that 8 had been released. Do you have a download link?

EDIT:Found link, downloaded, now i have encountered another error with smartparams. :|

[Error] E:\Programs\Simba\Includes\SRL/SRL/Misc/SmartParams.Simba(268:134): Invalid number of parameters at line 267
Compiling failed.

When there is only "end;" on line 267

msemtex
08-07-2012, 02:00 PM
Added further issues.

P1ng
08-07-2012, 02:17 PM
Have a look in the SMART v8.0 thread, that error is fixed in there.

I believe you need to go to line 277 and remove the ",-1" from that line

msemtex
08-07-2012, 02:25 PM
Have a look in the SMART v8.0 thread, that error is fixed in there.

I believe you need to go to line 277 and remove the ",-1" from that line

Yeah, I saw that before I get the same error.

msemtex
08-07-2012, 02:27 PM
This is the script I'am trying to use:

Narcles fast fighter


{------------------------------Script Info-------------------------------------|
| ScriptName = Fast Fighter |
| Author = Narcle |
| Description = Fights any monster, food eating and HP regen. |
|================================================= =============================|
| Instructions |
|================================================= =============================|
| |
| Setup with Form: (Reccommended) |
| 1a. Read FAQ on first post of Fast Fighter thread. |
| 1b. OR Hit play now the form is pretty easy to use. |
| Click 'Help' in Form if you don't know how to grab/set colors. |
| |
| Setup with Declare Players: |
| 1. Make sure you use the Color picker and select 3 colors |
| from monster, and place them accordingly in DeclarePlayers. |
| 2. Setup players in DeclarePlayers |
| 3. Setup RuneScape (unless your using SMART) |
| 4. Push play! |
| |
| |
|_________________________________________________ _____________________________}
{$DEFINE SMART}
{$i SRL/SRL.simba}
{$i SRL/SRL/skill/fighting.simba}
{$i SRL/SRL/skill/ranging.simba}
{$i SRL/SRL/misc/Reports.simba}
{$i srl/srl/misc/smartgraphics.simba}
{------------------------------------------------------------------------------}
{===============================Player Setup===================================}
{------------------------------------------------------------------------------}
Const
LogoutIn = 2900000; //Logout every ?? Minutes; +/- 3 minutes for randomness
LogToFile = False; //File logging (helps me debug your problem) stores in /Scripts
DebugMode = False; //Debug mode
DisableSMARTPaint = False;//Might use less CPU if True


{ ATTENTION!!!
To use Forms just push play do NOT put anything in DeclarePlayers.
If you want to use DeclarePlayers fill it in (Forms should NOT come up then) }

procedure DeclarePlayers;
begin
With Players[0] do
begin
Name := ''; //Character Name
Pass := '; //Character Pass
Active := True; //True if you want this player to be ran in the script, false if not
Strings[0] := '';//monster name
Strings[1] := '';//Fight style (str, att, def, crush etc. anything in your weapon info}
Integers[0] := 9212819;//1st color of monster
Integers[1] := 8423046;//2nd color of monster
Integers[2] := 6843757;//3rd color of monster
Arrays[0] := [6, True, false];
//[NPC Color Tolerance, Left click only, Right click only]
end;

{
With Players[1] do //copy and change number accordingly to add players
begin
Name :='';
Pass :='';
Active := True;
Strings[0] := '';//monster name
Strings[1] := '';//Fight Style
Integers[0] := 0;//1st color of monster
Integers[1] := 0;//2nd color of monster
Integers[2] := 0;//3rd color of monster
Arrays[0] := [3, false, false];
//[NPC Color Tolerance, Left click only, Right click only]
end;
}
end;

{------------------------------------------------------------------------------}
{===========Don't edit below this unless you know what your doing!=============}
{------------------------------------------------------------------------------}
Type
FUsers = Record
Range, Melee, Setup, OutOfFood, TPAFight: Boolean;
MobName: string;
NPCTol, Clicktype, AvgWeapTime, AvgAniChange, MaxAniTime, InvAmt, LastWeaptime: integer;
Colors, WeaponTimes, AniTimes, AniChanges: TIntegerArray;
Weapon: array of TStringArray;
end;

Const
Version = '4.13';
ScriptName = 'Fast Fighter';
PixelChange = 300;
WeaponTime = 4000;
PLAYERSET = 3;
TOTALNPCKILLS = 10;
FOODATE = 11;
NPCKILLS = 12;
KILLSperHour = 13;
XPGained = 14;
XPperHour = 15;
REPORTXP = 16;
CURRENTXP = 17;
LOGOUTIME = 19;
ATTACKTIME = 20;
STARTXP = 21;
DRAWXP = 22;

var
Playas: array [0..99] of FUsers;
TOTALKILLS, TOTALXP: integer;//Counters
LeftClickFail: boolean;
DebugFile: integer;
DebugModeOn: Boolean;
ReportTime: integer;
PlayerBox, AniBox: TBox;

const
FilePath = AppPath + 'FastFighter4Chars.ini';
var
frmDesign: TForm;
PButtons: Array [0..3] of TButton;
SButtons: Array of TButton;
frmLabels: Array of TLABEL;
frmEdits: Array of TEDIT;
CheckBoxs: Array [0..2] of TCHECKBOX;
CurPlayer: integer;
AKpf_SavePlayers, AKpf_Terminate: boolean;
Memo: TMemo;


procedure Debug(S: String);
begin
if LogToFile then
try
if (DebugFile <> -1) then
if (not WriteFileString(DebugFile, TheTime+' - '+S + #13+#10)) then
Writeln('Debug: Failed to write to file');
except
Writeln(ExceptionToString(ExceptionType, ExceptionParam));
end;
if DebugModeOn then
Writeln(S)
else
DebugLn(s);
end;

Procedure FormNotify(S: string);
begin
Writeln(S);
Memo.LINES.Add(s);
end;

Procedure SavePlayers(tofile: boolean);
var
i, ii: integer;
begin
try
With Players[CurPlayer] do
begin
Name := frmEdits[0].Caption;
Pass := frmEdits[1].Caption;
Active := CheckBoxs[0].CHECKED;
Strings[0] := frmEdits[6].Caption;//npc name
Strings[1] := frmEdits[11].Caption;//fight style
for ii := 0 to 2 do
Integers[ii] := StrToInt( ReplaceWrap( (frmEdits[ii+7].Caption), ' ', '', [rfReplaceAll]));
Arrays[0] := [frmEdits[10].Caption, CheckBoxs[1].CHECKED, CheckBoxs[2].CHECKED];
end;
except
Writeln('Failed to save Player '+ToStr(CurPlayer)+'.');
end;

if tofile then
begin
WriteINI('General', 'NumOfPlayers', IntToStr(HowManyPlayers), FilePath);
WriteINI('General', 'statsUser', frmEdits[4].Caption, FilePath);
WriteINI('General', 'statsPass', frmEdits[5].Caption, FilePath);
end;

if tofile then
for i := 0 to HowManyPlayers - 1 do
with Players[i] do
begin
WriteINI('Player['+IntToStr(i)+']', 'Name', Name, FilePath);
WriteINI('Player['+IntToStr(i)+']', 'Pass', Pass, FilePath);
WriteINI('Player['+IntToStr(i)+']', 'Active', BoolToStr(Active), FilePath);
WriteINI('Player['+IntToStr(i)+']', 'Strings[0]', Strings[0], FilePath);
WriteINI('Player['+IntToStr(i)+']', 'Strings[1]', Strings[1], FilePath);
for ii := 0 to 2 do
WriteINI('Player['+IntToStr(i)+']', 'Integers['+IntToStr(ii)+']', IntToStr(Integers[ii]), FilePath);
WriteINI('Player['+IntToStr(i)+']', 'Arrays[0][0]', IntToStr(Arrays[0][0]), FilePath);
WriteINI('Player['+IntToStr(i)+']', 'Arrays[0][1]', BoolToStr(Arrays[0][1]), FilePath);
WriteINI('Player['+IntToStr(i)+']', 'Arrays[0][2]', BoolToStr(Arrays[0][2]), FilePath);
end;
end;


Procedure NewPlayer(index: integer);
var
ii:integer;
begin
with Players[Index] do
begin
Name := '';
Pass := '';
Active := true;
Strings[0] := '';
Strings[1] := '';
for ii := 0 to 2 do
Integers[ii] := 0;
Arrays[0] := [9, false, false];//Color Tolerance, right click, left click
end;
end;

Procedure ShowPlayer(index: integer);
var
ii: integer;
begin
if Players[index].Name = '' then
NewPlayer(Index);
With Players[index] do
begin
frmEdits[0].Caption := Name;
frmEdits[1].Caption := Pass;
CheckBoxs[0].CHECKED := Active;
frmEdits[6].Caption := Strings[0];
frmEdits[11].Caption := Strings[1];
for ii := 0 to 2 do
frmEdits[ii+7].Caption := IntToStr(Integers[ii]);
frmEdits[10].Caption := IntToStr(Arrays[0][0]);//npc tol
CheckBoxs[1].Checked := Arrays[0][1];//Right click
CheckBoxs[2].Checked := Arrays[0][2];//Left click
end;
CurPlayer := index;
frmEdits[4].Caption := stats_Username;
frmEdits[5].Caption := stats_UserPass;
frmEdits[2].Caption := IntToStr(CurPlayer);
frmEdits[3].Caption := IntToStr(HowManyPlayers);
end;

Procedure LoadPlayers;
var
i,ii: integer;
begin
HowManyPlayers := StrToIntDef(ReadINI('General', 'NumOfPlayers', FilePath), 1);
stats_Username := ReadINI('General', 'statsUser', FilePath);
stats_UserPass := ReadINI('General', 'statsPass', FilePath);
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
CurPlayer := CurrentPlayer;
for i := 0 to HowManyPlayers - 1 do
with Players[i] do
begin
Name := ReadINI('Player['+IntToStr(i)+']', 'Name', FilePath);
Pass := ReadINI('Player['+IntToStr(i)+']', 'Pass', FilePath);
Active := StrToBool(ReadINI('Player['+IntToStr(i)+']', 'Active', FilePath));
Strings[0] := ReadINI('Player['+IntToStr(i)+']', 'Strings[0]', FilePath);
Strings[1] := ReadINI('Player['+IntToStr(i)+']', 'Strings[1]', FilePath);
for ii := 0 to 2 do
Integers[ii] := StrToInt(ReadINI('Player['+IntToStr(i)+']', 'Integers['+IntToStr(ii)+']', FilePath));
try
Arrays[0] := [StrToInt(ReadINI('Player['+IntToStr(i)+']', 'Arrays[0][0]', FilePath)),
StrToBool(ReadINI('Player['+IntToStr(i)+']', 'Arrays[0][1]', FilePath)),
StrToBool(ReadINI('Player['+IntToStr(i)+']', 'Arrays[0][2]', FilePath))];
except
Arrays[0] := [3, false, false];
end;
end;
end;

procedure OnLeftClick(Sender: TObject);
begin
Case Sender of
SButtons[0]: begin//Start
frmDesign.ModalResult := mrOk;
AKpf_SavePlayers := False;
AKpf_Terminate := False;
Writeln('Start.');
end;
SButtons[1]: begin//Save and start
frmDesign.ModalResult := mrOk;
AKpf_SavePlayers := True;
AKpf_Terminate := False;
Writeln('Save and Start.');
end;
SButtons[2]: begin//Save and Exit
frmDesign.MODALRESULT:= mrOk;
AKpf_SavePlayers := True;
AKpf_Terminate := True;
Writeln('Save and Exit.');
end;
SButtons[3]: begin//Exit
frmDesign.MODALRESULT:= mrOk;
AKpf_SavePlayers := False;
AKpf_Terminate := True;
Writeln('Exit.');
end;
SButtons[4]: Memo.LINES.Clear;
SButtons[5]: Memo.LINES.Add(GetClipBoard);
SButtons[6]: OpenWebPage('http://villavu.com/forum/showthread.php?t=67793');

PButtons[0]: begin//Previous player
SavePlayers(false);
if CurPlayer = 0 then
ShowPlayer(HowManyPlayers - 1)
else
ShowPlayer(CurPlayer - 1);
end;
PButtons[1]: begin//New player
Debugln('Trying to add new player.');
Inc(HowManyPlayers);
NumberOfPlayers(HowManyPlayers);
CurPlayer := HowManyPlayers-1;
ShowPlayer(CurPlayer);
FormNotify('Player '+IntToStr(CurPlayer)+' added.');
end;
PButtons[2]: begin//Next player
SavePlayers(false);
if CurPlayer = HowManyPlayers - 1 then
ShowPlayer(0)
else
ShowPlayer(CurPlayer + 1);
end;
PButtons[3]: begin//Delete player
if (HowManyPlayers > 1) and (CurPlayer = 0) then
FormNotify('Can''t delete player 0.')
else
if (HowManyPlayers = 1) then
begin
if not (MessageDlg('Delete?', 'Do you want to reset Player '+ToStr(CurPlayer)+'?', mtConfirmation, [mbYes,mbNo]) = mrYes) then
Exit;
NewPlayer(CurPlayer);
FormNotify('Player '+ToStr(CurPlayer)+' reset.');
end
else
if (MessageDlg('Delete?', 'Do you want to delete Player '+ToStr(CurPlayer)+'?', mtConfirmation, [mbYes,mbNo]) = mrYes) then
begin
FormNotify('Player '+ToStr(CurPlayer)+' deleted.');
Swap(Players[CurPlayer], Players[HowManyPlayers - 1]);
IncEx(HowManyPlayers, -1);
ShowPlayer(Max(CurPlayer - 1, 0));
SavePlayers(true);
end;
end;
CheckBoxs[1]: begin
if CheckBoxs[2].CHECKED then
CheckBoxs[2].CHECKED := false;
end;
CheckBoxs[2]: begin
if CheckBoxs[1].CHECKED then
CheckBoxs[1].CHECKED := false;
end;
end;
end;

procedure InitForm;
var
i: integer;
PCaps, Labels, Hints: TStringArray;
Ws, Ls, Ts: TIntegerArray;
begin
frmDesign := Tform.Create(nil);
With frmDesign do
begin
setBounds(100, 100, 600, 330);
Caption := ScriptName+' v'+Version+' by Narcle';
Color := ClWhite;
Font.Color := ClBlack;
end;


PCaps := ['Previous Player', 'New Player', 'Next Player', 'Delete Player'];
for i := 0 to 3 do
begin
PButtons[i] := TBUTTON.Create(frmDesign);
with PButtons[i] do
begin
Parent := frmDesign;
Height := 22;
if i = 3 then
Width := 80//Delete Player
else
Width := 120;
Left := 10+i*125;
Top := 8;
CAPTION := PCaps[i];
ONCLICK := @OnLeftClick;
if i = 3 then
begin
Left := 135;
Top := 34;
end;
end;
end;

PCaps := ['Start', 'Save and Start', 'Save and Exit', 'Exit', 'Clear', 'Paste', 'Help!'];
Hints := ['Clear the memo','Paste from clip board','Open help in default web browser.'];
SetArrayLength(SButtons, Length(PCaps));
for i := 0 to High(SButtons) do
begin
SButtons[i] := TBUTTON.Create(frmDesign);
with SButtons[i] do
begin
Parent := frmDesign;
Height := 22;
Width := 90;
Left := 6+i*96;
Top := 300;
FONT.Size := 8;
CAPTION := PCaps[i];
OnClick := @OnLeftClick;
if InIntArray([4,5,6],i) then
begin
Width := 50;
Left := 430+(i-4)*55;
ShowHint := true;
Hint := Hints[i-4];
end;
end;
end;



Labels := ['Username:', 'Password:', 'Active', 'Right click only', 'Left click only',
'SRL Stats User:', 'SRL Stats Password:', 'Player:', 'Total Players:',
'NPC Color 1:', 'NPC Color 2:', 'NPC Color 3:', 'NPC Name:','NPC Color Tolerance:', 'Fight Style:'];
Hints := ['Login name for the character you are using.','Login password','Will you be using this character?',
'Left click attack only', 'Right click attack only', 'SRL Stats goto stats.villavu.com to sign up!',
'SRL Stats goto stats.villavu.com to sign up!','','','Color of the NPC/Monster you''ll be fighting, use the color picker',
'Color of the NPC/Monster you''ll be fighting, use the color picker',
'Color of the NPC/Monster you''ll be fighting, use the color picker', 'Name of the NPC your fighting, check forums for details',
'Lower this number if the mouse hovers over other objects.', 'Read instructions on thread for more info'];
SetArrayLength(frmLabels, Length(Labels));
Ts := [62, 108, 186, 208, 230, 280, 280, 38, 38, 126, 156, 186, 62, 216, 160];
Ls := [10, 10, 30, 30, 30, 34, 198, 20, 260, 182, 182, 182, 200, 182, 10];
for i := 0 to High(Labels) do
begin
frmLabels[i] := TLABEL.Create(frmDesign);
with frmLabels[i] do
begin
Parent := frmDesign;
Height := 20;
Width := 50;
Top := Ts[i];
Left := Ls[i];
Font.Size := 8;
Caption := Labels[i];
if (Hints[i] <> '') then
Hint := Hints[i];
ShowHint := true;
end;
end;

Ws := [150, 150, 28, 28, 76, 76, 150, 100, 100, 100, 40, 80];
Ts := [ 80, 126, 34, 34, 274, 274, 80, 120, 150, 180, 210, 154];
Ls := [ 10, 10, 60, 330, 112, 300, 200, 250, 250, 250, 290, 80];
SetArrayLength(frmEdits, Length(Ws));
for i := 0 to High(frmEdits) do
begin
frmEdits[i] := TEDIT.Create(frmDesign);
with frmEdits[i] do
begin
Parent := frmDesign;
Height := 21;
Width := Ws[i];
top := Ts[i];
Left := Ls[i];
Font.Size := 8;
end;
end;

for i := 0 to High(CheckBoxs) do
begin
CheckBoxs[i] := TCHECKBOX.Create(frmDesign);
with CheckBoxs[i] do
begin
Parent := frmDesign;
Top := 184+i*22;
Left := 10;
ShowHint := true;
ONCLICK := @OnLeftClick;
end;
end;

Memo := TMemo.Create(frmDesign);
with Memo do
begin
Parent := frmDesign
Left := 390;
Top := 10;
Width := 200;
Height := 280;
end;

Memo.Lines.Add(ScriptName+' v'+Version+' by Narcle');
if FileExists(FilePath) then
begin
LoadPlayers;
ShowPlayer(0);
end
else
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
CurPlayer := 0;
ShowPlayer(CurPlayer);
end;
frmDesign.ShowModal;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure AntiBan;
begin
if not LoggedIn then Exit;
case Random(99) of
0: wait(500+random(3000));
1: begin
RandomMovement;
SetAngle(SRL_ANGLE_HIGH);
end;
3: PickUpMouse;
end;
end;

Function HpCheck: boolean;
var
c, T, i:Integer;
RunDir: String;
begin
if (HPPercent < 50) and LoggedIn then
begin
Result := True;
Debug('HP low doing HP checks...');
if not InvEmpty then
for c := 0 to 1 do
begin
if (c > 0) then//in case uptext fails
MakeCompass(rs_GetCompassAngleDegrees+60+random(50 ));
for i := 1 to 28 do //Begin food eating proc
if ExistsItem(i) then
begin
MMouseItem(i);
if WaitUpTextMulti(['Eat', 'obster', 'onkfish', 'hark'], 400) then
begin
ClickMouse2(False);
if WaitOption('Eat', 400) then
begin
Debug('Eating food...');
t := GetSystemTime;
while ExistsItem(i) and ((GetSystemTime-t) < 2000) do
wait(20);
if not ExistsItem(i) then
Inc(Players[CurrentPlayer].Integers[FOODATE]);
if (HPPercent > 60) then
Exit;
end;
end;
end;//End food eating
end;
if (not LoggedIn) or (HPPercent > 50) then
Exit;

if (HPPercent < 50) then
begin
if (HPPercent < 25) then
if (InFight) then
begin
RunDir := 'nsewns';
Debug('Running away HP% < 25...');
RunAway(RunDir[random(6)+1], true, 1, 10000 + random(2000));
end;
T := GetSystemTime;
repeat
if not IsResting then
SetRest;
Wait(200+random(200));
FindNormalRandoms;
If ((GetSystemTime - T) > (50000+random(50000)) ) then
begin
case random(2) of
0: BoredHuman;
1: RandomMovement;
end;
T := GetSystemTime;
end;
if not LoggedIn then
Exit;
until (HPPercent > 60);
SetAngle(SRL_ANGLE_HIGH);
end;
end;
end;

procedure Report;
var
xp,i: integer;
begin

if not LoggedIn then
Exit;

with Players[CurrentPlayer] do
begin
IncEx(TOTALKILLS, Integers[NPCKILLS]);//Total Kills
stats_IncVariable('Monsters Killed', Integers[NPCKILLS]);

for i := 0 to 3 do
xp := Max(xp, GetXPBarTotal);
if (xp > Integers[REPORTXP]) then
Integers[CURRENTXP] := xp;
stats_IncVariable('Total EXP Gained', Integers[CURRENTXP]-Integers[REPORTXP]);
IncEx(Integers[XPGained], Integers[CURRENTXP]-Integers[REPORTXP]);
IncEx(TOTALXP, Integers[CURRENTXP]-Integers[REPORTXP]);
Integers[REPORTXP] := Integers[CURRENTXP];

if ((PlayerWorked(CurrentPlayer)/60000.0) > 0) then
Integers[KILLSperHour] := round( (Integers[TOTALNPCKILLS]*60.0)/(PlayerWorked(CurrentPlayer)/60000.0))//XP Per hour
else
Integers[KILLSperHour] := -1;

if ((PlayerWorked(CurrentPlayer)/60000.0) > 0) then
Integers[XPperHour] := round( (Integers[XPGained]*60.0)/(PlayerWorked(CurrentPlayer)/60000.0))//XP Per hour
else
Integers[XPperHour] := -1;

SRLProgressReport(ResultDebugBox, ScriptName, 'Narcle', Version,
['Time Ran','Killed', 'XP'],
[MsToTime(GetTimeRunning, Time_Abbrev), TOTALKILLS, TOTALXP]);

SRLPlayerReport(ResultDebugBox, 0, False,
[True, false, false, false, false, false],
['Kills', 'Kills/H', 'XP Gained', 'XP/H'],
[], [TOTALNPCKILLS, KILLSperHour, XPGained, XPperHour], [], []);

Integers[NPCKILLS] := 0;
end;
ReportTime := GetSystemTime + 5*61000;
stats_Commit;
end;

procedure LogoutSeq(reason:string);
begin
while InFight and LoggedIn do
begin
HpCheck;
wait(100);
end;
Debug('Logout sequence...');
if (reason = '') then
begin
if HowManyPlayers = 1 then
begin
LogOut;
Wait(RandomRange(1*60000, 3*60000));
NextPlayer(true);
end
else
NextPlayer(true);
end
else
begin
Writeln(reason+' '+Players[Currentplayer].Name+' is now inactive.');
NextPlayer(false);
end;
end;

procedure SitAndWait;//Super advance I know :P
var
T: integer;
begin
T := GetSystemTime + 30000;
Debug('No NPCs detected on screen, waiting...');
repeat
if not LoggedIn then
Exit;
Wait(50+random(50));
FindNormalRandoms;
AntiBan;
HpCheck;
until (GetSystemTime > T) or (Length(GetMMDotsOnMS('npc')) > 0);
end;

function ChangeCamera: boolean;
var
i, II, PosNeg:integer;
begin
Case random(2) of
0: PosNeg := 1;
1: PosNeg := -1;
end;
i := Round(rs_GetCompassAngleDegrees/45 - 1);
if i < 0 then i := 0;
if i > 7 then i := 7;
For II := 0 to 4+Random(4) do
begin
if (Length(GetMMDotsOnMS('npc')) > 0) then
begin
Result := true;
exit;
end;
i := i+PosNeg;
if i > 7 then i := 0;
if i < 0 then i := 7;
MakeCompass(inttostr(i*(40+random(6))));
end;
end;

procedure WaitFight;
Var
T, C, s, x, i, Time, L, Remove, H, Pixs, LastXP: integer;
P: TIntegerArray;
WeapTime, TimeOut: integer;
begin
//if DebugMode then
//SMART_DrawBoxEx(False, False, AniBox, clPurple);

if Length(Playas[CurrentPlayer].WeaponTimes) > 49 then
Playas[CurrentPlayer].AvgWeapTime := AverageTIA(Playas[CurrentPlayer].WeaponTimes);
if Length(Playas[CurrentPlayer].AniChanges) > 199 then
Begin
Playas[CurrentPlayer].AvgAniChange := Round(AverageTIA(Playas[CurrentPlayer].AniChanges)*0.9);
Debug('Pixs changed to: '+ToStr(Playas[CurrentPlayer].AvgAniChange));
end;

with Playas[CurrentPlayer] do
if AvgWeapTime > 0 then
begin
H := High(WeaponTimes);
for i := 0 to H do
if not InRange(WeaponTimes[i], AvgWeapTime-400, AvgWeapTime+400) then
begin
Swap(WeaponTimes[i], WeaponTimes[H-Remove]);
Inc(Remove);
end;
SetLength(WeaponTimes, Length(WeaponTimes)-Remove);
AvgWeapTime := AverageTIA(Playas[CurrentPlayer].WeaponTimes);

WeapTime := Round(AvgWeapTime+0.0*1.15);
if LastWeaptime <> WeapTime then
Debug('Weapon time switched too: '+ToStr(WeapTime));
LastWeaptime := WeapTime;
end;

if (WeapTime = 0) then
WeapTime := WeaponTime;


for i := 0 to 2 do
With Players[CurrentPlayer] do
Integers[CURRENTXP] := Max(Integers[CURRENTXP], GetXPBarTotal);
s := Players[CurrentPlayer].Integers[CURRENTXP];
x := s;
C := GetSystemTime;
T := C;
TimeOut := C + 8000+random(3000);
Repeat
P := PixelShiftMulti([AniBox], 200);

if Playas[CurrentPlayer].AvgAniChange > 0 then
Pixs := Playas[CurrentPlayer].AvgAniChange-20
else
Pixs := PixelChange;

if (P[0] > Pixs) then
begin
//Debugln('Ani Time: '+Padl(ToStr(GetSystemTime-(T-WeapTime)), 5)+' Ani Change: '+ToStr(P[0]));
Time := GetSystemTime-T;
if (Playas[CurrentPlayer].AvgAniChange < 1) then
begin
L := Length(Playas[CurrentPlayer].AniChanges);
SetArrayLength(Playas[CurrentPlayer].AniChanges, L+1);
Playas[CurrentPlayer].AniChanges[L] := P[0];
end;
T := GetSystemTime;
TimeOut := T + WeapTime;
end;

With Players[CurrentPlayer] do
Integers[CURRENTXP] := Max(Integers[CURRENTXP], GetXPBarTotal);

if (Players[CurrentPlayer].Integers[CURRENTXP] > x) then
begin
LastXP := Players[CurrentPlayer].Integers[CURRENTXP] - x;
Time := GetSystemTime - C;
x := Players[CurrentPlayer].Integers[CURRENTXP];
if InRange(Time, 1000, 5000) then
begin
L := Length(Playas[CurrentPlayer].WeaponTimes);
SetArrayLength(Playas[CurrentPlayer].WeaponTimes, L+1);
Playas[CurrentPlayer].WeaponTimes[L] := Time;
end;
C := GetSystemTime;
Debugln('| Hit~ '+ToStr(Round(LastXP*1.9))+' Speed: '+Tostr(Time));
end;

FindNormalRandoms;
if HpCheck then
TimeOut := GetSystemTime + 4000;
until (GetSystemTime > TimeOut) or (not LoggedIn);
Debugln('Ani Time: '+Padl(ToStr(GetSystemTime-T), 5));
Debug('Fighting Done.');
if ((Players[CurrentPlayer].Integers[CURRENTXP]-s) > 12) then
begin
Inc(Players[CurrentPlayer].Integers[TOTALNPCKILLS]);
Inc(Players[CurrentPlayer].Integers[NPCKILLS]);
end;
end;

Procedure SetupBackGround;
var
TPA: TPointArray;
B: TBox;
begin
if DisableSMARTPaint then
Exit;
B := IntToBox(8, 345, 497, 379);
TPA := TPAFromBox(B);
SMART_DrawDotsEx(True, TPA, 725267);
B := IntToBox(8, 378, 497, 378);
TPA := TPAFromBox(B);
SMART_DrawDotsEx(false, TPA, 2570567);
//SMART_DrawTextEx(False, 378, 346, UpChars, ScriptName, 2570567);
SMART_DrawTextEx(False, 344, 345, BigChars, 'by Narcle', 2570567);
SMART_DrawTextEx(False, 282, 345, UpCharsEx, ' Fast', 2570567);
SMART_DrawTextEx(False, 280, 344+17, UpCharsEx, 'Fighter', 2570567);
SMART_DrawTextEx(False, 9, 347, UpChars, ' Kills: ', clYellow);
SMART_DrawTextEx(False, 154, 347, UpChars, ' K/H: ', clYellow);
SMART_DrawTextEx(False, 8, 347+17, UpChars, ' XP: ', clYellow);
SMART_DrawTextEx(False, 153, 347+17, UpChars, 'XP/H: ', clYellow);
end;

procedure PrintOnSmart(Str: String; Placement: TPoint); //y1 345, y2 377
var
TPA: TPointArray;
B: TBox;
begin
B := IntToBox(Placement.x, Placement.y, Placement.x+Length(Str)*8 , Placement.y+15);
TPA := TPAFromBox(B);
SMART_DrawDotsEx(False, TPA, 725267);
SMART_DrawTextEx(False, Placement.x, Placement.y, UpChars, Str, clYellow);
end;

Procedure SMARTDrawDisplay;
var
xp, x: integer;
begin
if DisableSMARTPaint then
Exit;
SMART_ClearCanvasArea(IntToBox(0, 0, MSX2, MSY2));
With Players[CurrentPlayer] do
begin
x := GetXPBarTotal;
if InRange(x, Integers[CURRENTXP], Integers[CURRENTXP]+1000) then
Integers[CURRENTXP] := x;

if Integers[DRAWXP] = Integers[CURRENTXP] then
Exit;
xp := (Integers[CURRENTXP]-Integers[STARTXP]);

if ((PlayerWorked(CurrentPlayer)/60000.0) > 0) then
Integers[KILLSperHour] := round( (Integers[TOTALNPCKILLS]*60.0)/(PlayerWorked(CurrentPlayer)/60000.0))//XP Per hour
else
Integers[KILLSperHour] := -1;

if ((PlayerWorked(CurrentPlayer)/60000.0) > 0) then
Integers[XPperHour] := round( (xp*60.0)/(PlayerWorked(CurrentPlayer)/60000.0))//XP Per hour
else
Integers[XPperHour] := -1;

Integers[DRAWXP] := Integers[CURRENTXP];

PrintOnSmart(ToStr(Integers[TOTALNPCKILLS]), Point(40, 347));
PrintOnSmart(ToStr(Integers[KILLSperHour]), Point(188, 347));
PrintOnSmart(ToStr(XP), Point(40, 347+17));
PrintOnSmart(ToStr(Integers[XPperHour]), Point(188, 347+17));
end;
end;

Function FightIt: Boolean;
var
i, ii, r, L, P: integer;
T: TPoint;
NPCs, TPA: TPointArray;
ATPA: T2DPointArray;
BoxArr: TBoxArray;
begin
P := GetSystemTime;
NPCs := GetMMDotsOnMS('npc');
L := Length(NPCs);
if L < 1 then
Exit;
SetLength(BoxArr, L);
for i := 0 to L-1 do
begin
T := MMtoMS(NPCs[i]);
BoxArr[i] := IntToBox(Max(T.x-40, MSX1), Max(T.y-40, MSY1), Min(T.x+40, MSX2), Min(T.y+40, MSY2));
end;

With Playas[CurrentPlayer] do
for i := 0 to L-1 do
with BoxArr[i] do
begin
SetLength(ATPA, Length(Colors));
For ii := 0 to High(Colors) do //Color array
FindColorsTolerance(ATPA[ii], Colors[ii], X1, Y1, X2, Y2, NPCTol);
TPA := MergeATPA(ATPA);
if Length(TPA) > 0 then
begin
ATPA := SplitTPA(TPA, 6);
SortATPASize(ATPA, True);
T := MiddleTPA(ATPA[0]);
if IsFightAt(T.x, T.y) then
Continue;

if not DisableSMARTPaint then
begin
SMARTDrawDisplay;
SMART_DrawBoxEx(False, False, BoxArr[i], clBlue);
SMART_DrawDotsEx(False, ATPA[0], clRed);
end;
MMouse(T.x, T.y, 3, 3);
if WaitUpTextMulti([MobName], 150+random(100)) then//Text array
begin
Case ClickType of
0: r := Random(3);
1: r := 1;
2: r := 2;
end;
if (ClickType = 0) then
if LeftClickFail then
r := 2;
case r of
0..1: begin
ClickMouse2(True);
Result := DidClick(True, 100);
end;
2: begin
ClickMouse2(False);
Result := ChooseOption('ttack');
end;
end;
LeftClickFail := not result;
if Result then
begin
Debug('Attacked '+Inttostr(GetsystemTime - P)+'ms');
MarkTime(Players[CurrentPlayer].Integers[ATTACKTIME]);
FFlag(0);
Exit;
end Else Continue;
end;
end;
end;
end;

procedure SetupPlayer;
var
ammo, i, N: integer;
begin
if not LoggedIn then
Exit;
MouseSpeed := RandomRange(15, 17);
SetupBackGround;
ToggleXPBar(True);

with Players[CurrentPlayer] do
begin
if not Booleans[PLAYERSET] then
begin
Debug('Setting Angle');
SetAngle(SRL_ANGLE_HIGH);
SetAngle(SRL_ANGLE_HIGH);//just in case of lag
Debug('Setting Retaliate');
Retaliate(True);
Debug('Getting Weapon Info');
GetWeaponData(Playas[CurrentPlayer].Weapon);

if (Players[CurrentPlayer].Strings[1] <> '') then
if SetWeaponMode(Players[CurrentPlayer].Strings[1], Playas[CurrentPlayer].Weapon, True) then
Debug('Weapon set');
N := StrToIntDef(Players[CurrentPlayer].Strings[1], 0);
if InRange(N, 1, 4) then
SetFightMode(N);
Playas[CurrentPlayer].Range := SetWeaponMode('ange', Playas[CurrentPlayer].Weapon, false);
Playas[CurrentPlayer].Melee := SetWeaponMode('ttack', Playas[CurrentPlayer].Weapon, false);
Debug('Getting Levels');
GetAllLevels;
If Playas[CurrentPlayer].Range then
Writeln(Capitalize(Players[CurrentPlayer].Name)+ ' is Ranging.');
if Playas[CurrentPlayer].Melee then
Writeln(Capitalize(Players[CurrentPlayer].Name)+ ' is Meleeing.');
if not (Playas[CurrentPlayer].Range or Playas[CurrentPlayer].Melee) then
Writeln('[WARNING] Failed to get weapon data. Can''t detect if ranging or meleeing.');
for i := 0 to 9 do
Integers[STARTXP] := Max(GetXPBarTotal, Integers[STARTXP]);
Integers[CURRENTXP] := Integers[STARTXP];
Integers[REPORTXP] := Integers[STARTXP];
Booleans[PLAYERSET] := true;
end;
end;

if Playas[CurrentPlayer].Range then
begin
GameTab(tab_Equip);
ammo := ArrowAmount;
Debug('Ammo left: '+IntToStr(ammo));
if (ammo < 200) then
//LogoutSeq('Low Ammo');
end;

SetRun(True);

Players[CurrentPlayer].Integers[LOGOUTIME] := Getsystemtime + RandomRange((LogoutIn-3)*60000, (LogoutIn+3)*60000);
MarkTime(Players[CurrentPlayer].Integers[ATTACKTIME]);
end;

procedure EndOfScript;
begin
FreeSRL;
if LogToFile then
CloseFile(DebugFile);
Disguise('ENDED');
writeln('');
writeln('Thanks for using Fast Fighter!');
writeln('Please post proggies on forums!');
writeln(' -Narcle');
end;

Procedure FFStartUp;
var
i, ii, c: integer;
ScriptStart: string;
begin
SRL_SixHourFix := True;
Smart_FixSpeed := True;
SetupSRL;
if DisableSMARTPaint then
SmartSetDebug(False);
DebugModeOn := True;
MouseSpeed := 16+random(3);
Disguise(scriptname);
ScriptStart := TheDate(DATE_DAY) + ' at ' + TheTime;
ScriptStart := Replace(scriptStart, ':', ' ');
Writeln('');
Writeln(ScriptName+' v'+version);
Writeln(' By Narcle');
Writeln('');
NumberOfPlayers(100);
DeclarePlayers;
if (Players[0].Name = '') then
begin
SafeInitForm;
if AKpf_SavePlayers then
SavePlayers(True);
if AKpf_Terminate then
TerminateScript;
end else
begin
HowManyPlayers := 0;
CurrentPlayer := 0;
DeclarePlayers;
for i := 0 to High(Players) do
if (Players[i].Name <> '') then
Inc(HowManyPlayers)
else
Break;
NumberOfPlayers(HowManyPlayers);
end;

if LogToFile then
DebugFile := CreateFile(AppPath+'Scripts\'+ScriptName+' Log ' + ScriptStart + '.txt');

AddOnTerminate('EndOfScript');
SetupSRLStats(19, stats_Username, stats_Userpass);

SRL_Procs[srl_OnLogIn] := @SetupPlayer;
SRL_Procs[srl_OnLogOut] := @Report;
for i := 0 to HowManyPlayers - 1 do
begin
if Players[i].Nick = '' then
Players[i].Nick := Capitalize(Copy(Players[i].Name, 1, 4));
try
if (Length(Players[i].Arrays[0]) <> 3) then
Debug('[ERROR] '+Capitalize(Players[i].Name)+' settings array is wrong length');
except
Debug('[ERROR] '+Capitalize(Players[i].Name)+' settings array is wrong length - '+ExceptionToString(ExceptionType, ExceptionParam));
end;
Try
Playas[i].NPCTol := Players[i].Arrays[0][0];
except
Debug('[ERROR] '+Capitalize(Players[i].Name)+' NPCTol setting is incorrect - '+ExceptionToString(ExceptionType, ExceptionParam));
end;
try
Playas[i].Colors := [Players[i].Integers[0], Players[i].Integers[1], Players[i].Integers[2]];
except
Debug('[ERROR] '+Capitalize(Players[i].Name)+' color array is incorrect - '+ExceptionToString(ExceptionType, ExceptionParam));
end;
if trim(Players[i].Strings[0]) = '' then
begin
Playas[i].MobName := 'tack';
Writeln('[WARNING] '+Capitalize(Players[i].Name)+' has no NPC name given to attack.');
end
else
Playas[i].MobName := Players[CurrentPlayer].Strings[0];
If (i > 0) and (Players[i].Integers[0] = 0) then
begin
Playas[i].Colors := Playas[0].Colors;
Playas[i].MobName := Playas[0].MobName;
end;
c := 0;
for ii := 0 to 2 do
if (Playas[i].Colors[ii] <> 0) then
inc(c);
if (c = 0) then
begin
Writeln('[ERROR] '+Capitalize(Players[i].Name)+' has no colors entered.');
Writeln('[HELP] If you don''t know how to get colors please read this tutorial:');
//Writeln('[HELP] http://villavu.com/forum/showthread.php?t=67793');
TerminateScript;
end;
if c < 3 then
Writeln('[WARNING] '+Capitalize(Players[i].Name)+' only has '+ToStr(c)+' color(s) entered.');
try
Playas[i].Clicktype := 0;
if (Players[i].Arrays[0][1]) and (Players[i].Arrays[0][2]) then
begin
Debug('[WARNING] '+Capitalize(Players[i].Name)+' can''t have both Right & Left clicks. Setting to Default.');
Continue;
end;
if Players[i].Arrays[0][1] then
Playas[i].Clicktype := 1;//Left
if Players[i].Arrays[0][2] then
Playas[i].Clicktype := 2;//Right
except
Debug(Capitalize(Players[i].Name)+' click array is incorrect - '+ExceptionToString(ExceptionType, ExceptionParam));
end;
end;
for i := 0 to HowManyPlayers-1 do
if Players[i].Active then
begin
CurrentPlayer := i;
Break;
end;
Writeln('CurrentPlayer = '+Players[CurrentPlayer].Name);
PlayerBox := IntToBox(240, 137, 278, 185);
AniBox := IntToBox(MSCX-10, MFBox.y2-4, MSCX+10, MFBox.y2+16);
DebugModeOn := DebugMode;
ReportTime := GetSystemTime + 5*61000;
Loginplayer;
end;


//============================Main Execution==================================\\
begin
FFStartUp;
repeat
if not LoggedIn then
LogoutSeq('');

if FightIt then
WaitFight;

if (Length(GetMMDotsOnMS('npc')) = 0) then
if not ChangeCamera then
SitAndWait;

if (Getsystemtime > Players[CurrentPlayer].Integers[LOGOUTIME]) then
LogoutSeq('');

if TimeFromMark(Players[CurrentPlayer].Integers[ATTACKTIME]) > 10*60000 then
LogoutSeq('Failed to attack after 10 minutes');//Major fail safe, I suggest leaving it

if (GetSystemTime > ReportTime) then
Report;

SMARTDrawDisplay;
HpCheck;
Antiban;//delete for no antiban call
FindNormalRandoms;
until (AllPlayersInactive);
end.


This is my smart params with the -1 removed at line 277


{$DEFINE SRL_SMART}
{$DEFINE SMART}
{$loadlib libsmartremote}

(*
GetSmartParams
~~~~~~~~~~~~~~

.. code-block:: pascal

Function GetSmartParams: TStringArray;

Grabs The Correct Parameters For passing to the SmartClient.

.. note::

By: Brandon.
Modified By: Mormanman, Benland100.

Example:

.. code-block:: pascal

*)
Function GetSmartParams: TStringArray;
var
Params: TStringArray;
Page: String;
begin
Page := Between('<iframe id="game" src="', '"', GetPage('http://www.runescape.com/game.ws?j=1'));
Params := Explode(',', Page);
Result := Params;
end;

(*
FixSmartSpeed
~~~~~~~~~~~~~~

.. code-block:: pascal

Procedure FixSmartSpeed;

Fixes Smart's Loading Speed.
Moves the Mouse & Adjusting the Canvas Refresh rate.

.. note::

By: Brandon.

Example:

.. code-block:: pascal

*)
Procedure FixSmartSpeed;
var
T: Integer;
begin
T:= GetSystemTime + 2000;
While (Not SmartEnabled) Do
begin
if (GetSystemTime >= T) Then
Break;
Wait(500);
end;

While (GetColor(382, 252) = 0) Do
begin
If RSReady then
Break;
SmartSetRefresh(SmartGetRefresh + 1);
MMouse(4, 4, 0, 0);
SmartSetRefresh(SmartGetRefresh - 1);
if (GetSystemTime >= T) Then
Break;
Wait(500);
end;
end;

(*
SmartGetClientIDs
~~~~~~~~~~~~~~

.. code-block:: pascal

Function SmartGetClientIDs: TIntegerArray;

Grabs All Client ID's of the current remote.

.. note::

By: Mormanman.

Example:

.. code-block:: pascal

*)
Function SmartGetClientIDs: 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] := SmartClientID(I);
end;

(*
SmartKillClients
~~~~~~~~~~~~~~

.. code-block:: pascal

procedure SmartKillClients;

Kills All Smart Clients.

.. note::

By: Mormanman.

Example:

.. code-block:: pascal

*)
procedure SmartKillClients;
var
IDs: TIntegerArray;
I: Integer;
begin
IDs := SmartGetClientIDs;
For I := High(IDs) DownTo 0 Do
If SmartKillClient(IDs[I]) Then
Writeln('Killed Client: ' + ToStr(IDs[I]))
else
Writeln('Failed To Kill Client: ' + ToStr(IDs[I]));
end;

(*
SixHourFix
~~~~~~~~~~~~~~

.. code-block:: pascal

Procedure SixHourFix;

Kills The Current Smart Client and Restarts it.
Fixes the 6 hour login.

.. note::

By: Brandon.

Example:

.. code-block:: pascal

*)
Procedure FreeSRL; Forward;
Procedure SetupSRL; Forward;
Procedure SixHourFix;
var
Trash: TVariantArray;
begin
FreeSRL;
SmartKillClient(SmartCurrentClient);
SetupSRL;
try
CallProc('DeclarePlayers', Trash);
except
Writeln('Could Not DeclarePlayers');
TerminateScript;
end;

If (Not LoginPlayer) then
begin
Writeln('~SixHourFix~ Could Not Login Player');
TerminateScript;
end;
end;


(*
PairSmart
~~~~~~~~~~~~~~

.. code-block:: pascal

Function PairSmart(ID: Integer): Boolean;

Pairs A Client To The Current Controller.

.. note::

By: Benland100, Brandon.

Example:

.. code-block:: pascal

*)
Function PairSmart(ID: Integer): Boolean;
var
I, Count: Integer;
IDs: TIntegerArray;
begin
IDs := SmartGetClientIDs;
Count := Length(IDs);
If (Count > 0) then
For I:= 0 To (Count - 1) Do
If (IDs[I] = ID) and SmartPairClient(ID) then
begin
SetEIOSTarget('libsmartremote', ToStr(ID));
Writeln('Paired with SMART[' + ToStr(ID) + ']');
Result := True;
Exit;
end;
Writeln('** Failed To Pair Client: ' + ToStr(ID) + '; Client Does Not exist **');
end;

(*
InitSmart
~~~~~~~~~~~~~~

.. code-block:: pascal

Function InitSmart(ForceNew: Boolean): Integer;

Initializes A Smart Remote Client.
Terminates the current script upon failure.
Terminates all clients of the current remote upon failure.
ForceNew Creates a new client.

.. note::

By: Benland100, Mormanman, Brandon.

Example:

.. code-block:: pascal

*)
Function InitSmart(ForceNew: Boolean): Integer;
var
I, Count: Integer;
IDs: TIntegerArray;
Params: TStringArray;
begin
If (Not ForceNew) then
begin
Ids := SmartGetClientIDs;
Count := Length(IDs);
If (Count > 0) then
For I:= 0 To (Count - 1) Do
begin
If SmartPairClient(IDs[I]) then
begin
Result := IDs[I];
SetEIOSTarget('libsmartremote', ToStr(Result));
Writeln('Paired with SMART[' + ToStr(Result) + ']');
Exit;
end;
end;
end;

Params := GetSmartParams;
If (Length(Params) > 2) then
begin
Writeln('** Failed To Grab Smart Parameters **');
TerminateScript;
Exit;
end;

Result:= SmartSpawnClient(ReplaceWrap(PluginPath, '\', '/', [rfReplaceAll]), Params[0], ',' + Params[1], 765, 553, 's', '', '');
If (Result > 0) Then
begin
try
SetEIOSTarget('libsmartremote', ToStr(Result));
Writeln('Loading SMART: ' + Params[0] + Params[1]);
except
WriteLn('** Fatal Error: Pairing Clients; Terminating Script **');
TerminateScript;
end;
end else
begin
Writeln('** Smart Cannot Spawn Clients **');
TerminateScript;
end;
end;

(*
SetupSmart
~~~~~~~~~~~~~~

.. code-block:: pascal

Procedure SetupSmart(ForceNewClient: Boolean);

Sets Up a new Smart Client and waits until it's on screen.
Terminates The current script upon failure.

.. note::

By: Mormanman.
Modified By: Brandon.

Example:

.. code-block:: pascal

*)
Procedure SetupSmart(ForceNewClient: Boolean);
var
T: Integer;
begin
T:= GetSystemTime + 120000;
Smart_CurrentClient:= InitSmart(ForceNewClient);
if (Smart_CurrentClient <= 0) then
begin
writeln('*** Smart Failed To Load ***');
TerminateScript;
end;

if (SRL_SixHourFix) then
SRL_Procs[SRL_OnRSUpdate]:= @SixHourFix;

While (GetColor(382, 252) <> 0) Do
begin
if RSReady then
break;

Wait(100);
if (GetTimeRunning >= 120000) then
begin
Writeln('*** Failed To Detect Clients ***');
TerminateScript;
end;
end;
end;





{* Functions Below Here are From the Original Smart.Simba *}


{*
By: Unknown Author.
Finds a Windows by partial title and Sets it as the target.
*}
function FindAndSetTarget(TitlePrefix: String; SetAsTarget: Boolean): Boolean;
var
T : TSysProcArr;
I : Integer;
begin
T := GetProcesses;
for I := High(T) downto 0 do
if Pos(TitlePrefix, T[I].Title) <> 0 then
begin
Result := True;
if SetAsTarget then SetTarget(T[I]);
Exit;
end;
end;

{*
By: Unknown Author.
Gets the position of the actual mouse (Not Smart's Mouse).
*}
procedure GetRealMousePos(var X, Y : Integer);
var
KMTarget, ITarget: Integer;
begin
KMTarget := GetKeyMouseTarget;
ITarget := GetImageTarget;
FindAndSetTarget('SMART', True);
GetTClient.IOManager.GetMousePos(X, Y);
FreeTarget(GetImageTarget);
SetKeyMouseTarget(KMTarget);
SetImageTarget(ITarget);

// These are not universial offsets, but works somewhat for some Windows themes.
X := X - 8;
Y := Y - 25;
end;

{*
By: Unknown Author.
Returns if the "Real Mouse" (Not Smart's Mouse) Is Within a given Box.
*}
function IsRealMouseInBox(B : TBox): Boolean;
var
P : TPoint;
begin
GetRealMousePos(P.X, P.Y);
Result := PointInBox(P, B);
end;

P1ng
08-07-2012, 02:36 PM
Compiled your script and got a syntax error on this line

Pass := '; //Character Pass

it just needs to be changed to

Pass := ''; //Character Pass

Then it compiled perfectly fine for me.

didn't look at your smartparams but if you followed the fix on the v8.0 thread then it should work just fine, too.
What errors are you getting? what does the debug box say?

msemtex
08-07-2012, 02:41 PM
Compiled your script and got a syntax error on this line

Pass := '; //Character Pass

it just needs to be changed to

Pass := ''; //Character Pass

Then it compiled perfectly fine for me.

didn't look at your smartparams but if you followed the fix on the v8.0 thread then it should work just fine, too.
What errors are you getting? what does the debug box say?

That missing " ' " will have been from when I removed my username and pass. The script itself works fine. It's definitely a smartparams issue. I get the same "Invalid number of parameters at line 267"

Can you upload a copy of your smartparams so I can test it? If I get the same issue with yours then I will reinstall simba.

P1ng
08-07-2012, 02:45 PM
Here is my SmartParams
{$DEFINE SRL_SMART}
{$DEFINE SMART}
{$loadlib libsmartremote}

(*
GetSmartParams
~~~~~~~~~~~~~~

.. code-block:: pascal

Function GetSmartParams: TStringArray;

Grabs The Correct Parameters For passing to the SmartClient.

.. note::

By: Brandon.
Modified By: Mormanman, Benland100.

Example:

.. code-block:: pascal

*)
Function GetSmartParams: TStringArray;
var
Params: TStringArray;
Page: String;
begin
Page := Between('<iframe id="game" src="', '"', GetPage('http://www.runescape.com/game.ws?j=1'));
Params := Explode(',', Page);
Result := Params;
end;

(*
FixSmartSpeed
~~~~~~~~~~~~~~

.. code-block:: pascal

Procedure FixSmartSpeed;

Fixes Smart's Loading Speed.
Moves the Mouse & Adjusting the Canvas Refresh rate.

.. note::

By: Brandon.

Example:

.. code-block:: pascal

*)
Procedure FixSmartSpeed;
var
T: Integer;
begin
T:= GetSystemTime + 2000;
While (Not SmartEnabled) Do
begin
if (GetSystemTime >= T) Then
Break;
Wait(500);
end;

While (GetColor(382, 252) = 0) Do
begin
If RSReady then
Break;
SmartSetRefresh(SmartGetRefresh + 1);
MMouse(4, 4, 0, 0);
SmartSetRefresh(SmartGetRefresh - 1);
if (GetSystemTime >= T) Then
Break;
Wait(500);
end;
end;

(*
SmartGetClientIDs
~~~~~~~~~~~~~~

.. code-block:: pascal

Function SmartGetClientIDs: TIntegerArray;

Grabs All Client ID's of the current remote.

.. note::

By: Mormanman.

Example:

.. code-block:: pascal

*)
Function SmartGetClientIDs: 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] := SmartClientID(I);
end;

(*
SmartKillClients
~~~~~~~~~~~~~~

.. code-block:: pascal

procedure SmartKillClients;

Kills All Smart Clients.

.. note::

By: Mormanman.

Example:

.. code-block:: pascal

*)
procedure SmartKillClients;
var
IDs: TIntegerArray;
I: Integer;
begin
IDs := SmartGetClientIDs;
For I := High(IDs) DownTo 0 Do
If SmartKillClient(IDs[I]) Then
Writeln('Killed Client: ' + ToStr(IDs[I]))
else
Writeln('Failed To Kill Client: ' + ToStr(IDs[I]));
end;

(*
SixHourFix
~~~~~~~~~~~~~~

.. code-block:: pascal

Procedure SixHourFix;

Kills The Current Smart Client and Restarts it.
Fixes the 6 hour login.

.. note::

By: Brandon.

Example:

.. code-block:: pascal

*)
Procedure FreeSRL; Forward;
Procedure SetupSRL; Forward;
Procedure SixHourFix;
var
Trash: TVariantArray;
begin
FreeSRL;
SmartKillClient(SmartCurrentClient);
SetupSRL;
try
CallProc('DeclarePlayers', Trash);
except
Writeln('Could Not DeclarePlayers');
TerminateScript;
end;

If (Not LoginPlayer) then
begin
Writeln('~SixHourFix~ Could Not Login Player');
TerminateScript;
end;
end;


(*
PairSmart
~~~~~~~~~~~~~~

.. code-block:: pascal

Function PairSmart(ID: Integer): Boolean;

Pairs A Client To The Current Controller.

.. note::

By: Benland100, Brandon.

Example:

.. code-block:: pascal

*)
Function PairSmart(ID: Integer): Boolean;
var
I, Count: Integer;
IDs: TIntegerArray;
begin
IDs := SmartGetClientIDs;
Count := Length(IDs);
If (Count > 0) then
For I:= 0 To (Count - 1) Do
If (IDs[I] = ID) and SmartPairClient(ID) then
begin
SetEIOSTarget('libsmartremote', ToStr(ID));
Writeln('Paired with SMART[' + ToStr(ID) + ']');
Result := True;
Exit;
end;
Writeln('** Failed To Pair Client: ' + ToStr(ID) + '; Client Does Not exist **');
end;

(*
InitSmart
~~~~~~~~~~~~~~

.. code-block:: pascal

Function InitSmart(ForceNew: Boolean): Integer;

Initializes A Smart Remote Client.
Terminates the current script upon failure.
Terminates all clients of the current remote upon failure.
ForceNew Creates a new client.

.. note::

By: Benland100, Mormanman, Brandon.

Example:

.. code-block:: pascal

*)
Function InitSmart(ForceNew: Boolean): Integer;
var
I, Count: Integer;
IDs: TIntegerArray;
Params: TStringArray;
begin
If (Not ForceNew) then
begin
Ids := SmartGetClientIDs;
Count := Length(IDs);
If (Count > 0) then
For I:= 0 To (Count - 1) Do
begin
If SmartPairClient(IDs[I]) then
begin
Result := IDs[I];
SetEIOSTarget('libsmartremote', ToStr(Result));
Writeln('Paired with SMART[' + ToStr(Result) + ']');
Exit;
end;
end;
end;

Params := GetSmartParams;
If (Length(Params) > 2) then
begin
Writeln('** Failed To Grab Smart Parameters **');
TerminateScript;
Exit;
end;

Result:= SmartSpawnClient(ReplaceWrap(PluginPath, '\', '/', [rfReplaceAll]), Params[0], ',' + Params[1], 765, 553, 's', '', '');
If (Result > 0) Then
begin
try
SetEIOSTarget('libsmartremote', ToStr(Result));
Writeln('Loading SMART: ' + Params[0] + Params[1]);
except
WriteLn('** Fatal Error: Pairing Clients; Terminating Script **');
TerminateScript;
end;
end else
begin
Writeln('** Smart Cannot Spawn Clients **');
TerminateScript;
end;
end;

(*
SetupSmart
~~~~~~~~~~~~~~

.. code-block:: pascal

Procedure SetupSmart(ForceNewClient: Boolean);

Sets Up a new Smart Client and waits until it's on screen.
Terminates The current script upon failure.

.. note::

By: Mormanman.
Modified By: Brandon.

Example:

.. code-block:: pascal

*)
Procedure SetupSmart(ForceNewClient: Boolean);
var
T: Integer;
begin
T:= GetSystemTime + 120000;
Smart_CurrentClient:= InitSmart(ForceNewClient);
if (Smart_CurrentClient <= 0) then
begin
writeln('*** Smart Failed To Load ***');
TerminateScript;
end;

if (SRL_SixHourFix) then
SRL_Procs[SRL_OnRSUpdate]:= @SixHourFix;

While (GetColor(382, 252) <> 0) Do
begin
if RSReady then
break;

Wait(100);
if (GetTimeRunning >= 120000) then
begin
Writeln('*** Failed To Detect Clients ***');
TerminateScript;
end;
end;
end;





{* Functions Below Here are From the Original Smart.Simba *}


{*
By: Unknown Author.
Finds a Windows by partial title and Sets it as the target.
*}
function FindAndSetTarget(TitlePrefix: String; SetAsTarget: Boolean): Boolean;
var
T : TSysProcArr;
I : Integer;
begin
T := GetProcesses;
for I := High(T) downto 0 do
if Pos(TitlePrefix, T[I].Title) <> 0 then
begin
Result := True;
if SetAsTarget then SetTarget(T[I]);
Exit;
end;
end;

{*
By: Unknown Author.
Gets the position of the actual mouse (Not Smart's Mouse).
*}
procedure GetRealMousePos(var X, Y : Integer);
var
KMTarget, ITarget: Integer;
begin
KMTarget := GetKeyMouseTarget;
ITarget := GetImageTarget;
FindAndSetTarget('SMART', True);
GetTClient.IOManager.GetMousePos(X, Y);
FreeTarget(GetImageTarget);
SetKeyMouseTarget(KMTarget);
SetImageTarget(ITarget);

// These are not universial offsets, but works somewhat for some Windows themes.
X := X - 8;
Y := Y - 25;
end;

{*
By: Unknown Author.
Returns if the "Real Mouse" (Not Smart's Mouse) Is Within a given Box.
*}
function IsRealMouseInBox(B : TBox): Boolean;
var
P : TPoint;
begin
GetRealMousePos(P.X, P.Y);
Result := PointInBox(P, B);
end;

EDIT: Just compared yours with mine on this site: http://www.tareeinternet.com/scripts/comparison-tool/#diff
And it shows no differences between the two bits of code.

msemtex
08-07-2012, 02:48 PM
Just tried your params. Works perfectly. Can't understand why mine didn't. :|

P1ng
08-07-2012, 02:49 PM
That is super weird, hopefully that fixes things for you :)

msemtex
08-11-2012, 02:42 AM
That is super weird, hopefully that fixes things for you :)

The problem has re-emerged again. Exact same error with your smartparams that worked. :(

msemtex
08-11-2012, 02:50 AM
Tried the line 285 fix again. Still get the same error.