if anyone is still has problems then replace this with your globals.scar:
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- ? Global Variables --//
//-----------------------------------------------------------------//
// * procedure LoadSRLBitMaps; // by SRL Dev Team
// * procedure FreeSRLBitMaps; // by Ron
// * procedure LoadSRLFonts; // by Markus
// * procedure FreeSRLFonts; // by Markus
// * procedure srl_Warn(ProcName, ErrorMessage: String; wVersion: Integer); // by SRL Dev Team
// * procedure SetupBoxes; // by the SRL Dev Team & MylesMadness
// * function srl_InFight: Boolean; // by Frement
{ const SRLVersionNumber;
Description: Repository Version Number. }
const
SRLVersionNumber = 38;
{ var TalkAfterRandoms: Boolean;
Description: Talk random phrases after randoms are detected/solved. }
var
TalkAfterRandoms: Boolean;
{ var FriendChars, LoginChars: Integer;
Description: Fonts used internally and for use in scripts. }
{$IFDEF LoadExtraFonts}
var
FriendChars, LoginChars: Integer;
{$ENDIF}
{var Fontpath,includepath : string;
Description: Path to the font folder and include folder}
{$IFNDEF Simba}
var
FontPath, IncludePath : string;
{$ENDIF}
{ var bmpAdmin, bmpMod, Lamp, BoxMask: Integer;
Description: Global Bitmaps. Need to be Global because of SCAR Memory leaks. }
var
bmpAdmin, bmpMod, Lamp: Integer;
{ var RoadColor, WaterColor, BankColor: Integer;
Description: Three variables you will almost always use. :) }
var
RoadColor, WaterColor, BankColor: Integer;
{ var LampSkill: String;
Description: Set Lamp skill. }
var
LampSkill: string;
{ var NPCChars, UpChars, SmallChars, StatChars, FriendChars, BigChars, LoginChars: LongInt;
Description: All the fonts for SCAR 3.25 and newer }
{$IFDEF SCAR325_UP}
var
NPCChars, UpChars, SmallChars, StatChars, FriendChars, BigChars, LoginChars: LongInt;
{$ENDIF}
{$IFNDEF Simba}
var
XPChars: LongInt;
{$ENDIF}
{ const srl_outline_black
Description: Black Color outline}
const
srl_outline_black = 131072;
srl_outline_white = clWhite;
{ const MMX1, MMY1, MMX2, MMY2;
Description: MiniMap Edge Points. }
const
MMX1 = 550;
MMY1 = 8;
MMX2 = 703;
MMY2 = 161;
{ const MMCX, MMCY;
Description: MiniMap Centre Point. }
const
MMCX = 627;
MMCY = 85;
{ const MSX1, MSY1, MSX2, MSY2;
Description: Main Screen EdgePoints. }
const
MSX1 = 4;
MSY1 = 4;
MSX2 = 515;
MSY2 = 337;
{ const MSCX, MSCY;
Description: Main Screen Centre Points. }
const
MSCX = 259;
MSCY = 170;
{ const MIX1, MIY1, MIX2, MIY2;
Description: Inventory EdgePoints. }
const
MIX1 = 547;
MIY1 = 202;
MIX2 = 737;
MIY2 = 466;
{ const MICX, MICY;
Description: Inventory Centre Points. }
const
MICX = 642;
MICY = 334;
{ const MCX1, MCY1, MCX2, MCY2;
Description: Chat Screen EdgePoints. }
const
MCX1 = 4;
MCY1 = 342;
MCX2 = 514;
MCY2 = 475;
{ const MCCX, MCCY;
Description: Chat Screen Centre Points. }
const
MCCX = 250;
MCCY = 401;
{ const MBX1, MBY1, MBX2, MBY2;
Description: BankScreen EdgePoints (where you click the items, does not include tabs). }
const
MBX1 = 26;
MBY1 = 84;
MBX2 = 480;
MBY2 = 292;
{ const DBX1, DBY1, DBX2, DBY2;
Description: Deposit box edgepoints (only where the item appear) }
const
DBX1 = 91;
DBY1 = 57;
DBX2 = 443;
DBY2 = 262;
{ const SRL_Procs Constants;
Description: Constants for SRL_Procs. }
const
srl_AntiBan = 0; // Your AntiBan procedure to be called during various SRL functions and procedures. (Flag, FFlag)
srl_OnFindMod = 1; // After a player or Jagex mod is detected talking in the chat box.
srl_OnFindDead = 2; // After the text 'Oh dear you are dead' is detected.
srl_OnFindFight = 3; // After detecting a fighting random.
srl_OnFindTrade = 4; // After the trade has been attempted (either success or failure).
srl_OnNextPlayer = 5; // While the players are logged out and before CurrentPlayer changes.
srl_OnSendStats = 6; // After SRL Script Stats are sent to the server.
srl_OnRandomCall = 7; // Called in FindNormalRandoms, FindInventoryRandoms, FindNonInventoryRandoms. (NOT ONLY WHEN RANDOMS ARE DETECTED).
srl_OnFindRandom = 8; // After a random event is detected. (FNR, FIR, FNIR, FT)
srl_OnLogOut = 9; // Just before the player is logged out.
srl_InNextPlayerLoop = 10; // During the infinite loop in NextPlayer when all players are inactive.
srl_OnCustomRC = 11; // When custom RC trigger has been given.
srl_OnExitToLobby = 12; // On exit to lobby
srl_OnLogIn = 13; // Right after player has successfully logged in.
{ var SRL_Procs: array [0..12] of procedure();
Description: Varibles to store user-defined procs to be called in SRL. }
var
SRL_Procs: array [0..13] of procedure();
SRL_OnFindRandomCall : function(var Cont : boolean) : boolean;
{ const GameTab Constants;
Description: Constants representing gametab numbers. }
const
tab_Combat = 21;
tab_Diary = 22;
tab_Task = 22;
tab_Stats = 23;
tab_Quest = 24;
tab_Inv = 25;
tab_Equip = 26;
tab_Prayer = 27;
tab_Magic = 28;
tab_Objectives = 29;
tab_Friends = 30;
tab_Ignore = 31;
tab_Clan = 32;
tab_Options = 33;
tab_Emotes = 34;
tab_Music = 35;
tab_Notes = 36;
tab_LogOut = 37;
{ type TAutoColorInfo;
Description: Set of information that can be used in some functions. }
type
TAutoColorInfo = record
Name: string;
Color: Integer;
ColorArray: TIntegerArray;
MinCount: Integer;
MaxCount: Integer;
MaxDist: Integer;
MaxDistCenter: Integer;
UpText: string;
UpTextMulti: TStringArray;
HueMod, SatMod: Extended;
LumTol: Integer;
MinR, MaxR, MinG, MaxG, MinB, MaxB: Integer;
MinX, MaxX, MinY, MaxY, MinZ, MaxZ: Extended;
end;
{ type fnct_ActionOptions;
Description: Action options. }
type
fnct_ActionOptions = (ClickLeft,ClickRight,Move,Nothing);
var
{ var ACArr
Description: Stores the information needed for the autocolour functions }
acArr: array of TAutoColorInfo;
{ var isACLoaded
Description: Boolean array to make sure that all TAutoColorInfos are loaded
prior to calling. Optimizes AutoColors significantly }
isACLoaded: array of Boolean;
{ var Smart_Server: Integer;
Description: Smart Server to Load. }
var
Smart_Server: Integer;
{ var Smart_Members, Smart_Signed, Smart_SuperDetail: Boolean
Description: Smart Options to Load. }
var
Smart_Members, Smart_Signed, Smart_SuperDetail: Boolean;
{ var WarnSensitivity: Integer
Description: var for srl_Warn. }
var
WarnSensitivity: Integer; //-2 will show Warnings and above, -3 notices too.
{ const srl_Warn Constants;
Description: Constants for srl_Warn. }
const
warn_AllVersions = 0;
warn_Terminate = -1;
warn_Warning = -2;
warn_Notice = -3;
warn_Debug = -4;
{var SRLBitmapsLoaded : boolean;
Description: True if SRL bmps/DTMs are loaded}
var
SRLBitmapsLoaded : boolean;
//****************************************************************************//
// * I tried to make these Bitmaps Local, but I got after a couple of hours
// * running scripts, CTB and DB handle errors. So sorry, declared them global
//****************************************************************************//
{*******************************************************************************
procedure LoadSRLBitMaps;
By: SRL Dev Team
Description: Loads SRL Bitmaps into memory.
*******************************************************************************}
procedure LoadSRLBitMaps;
begin
bmpMod := BitmapFromString(9, 6, 'beNqbPn0RWeDBgwdAkgEMkBnT' +
'p0+HS6GR+KVwAgAGXFQr');
bmpAdmin := BitmapFromString(9, 6, 'beNqbp/j9PwcZ6P//FiDJAA' +
'bIjGvzFOFSaCR+KZwIALniVEk=');
Lamp := DTMFromString('78DA63946060601062400153A78832F003694' +
'620FE0F048C02986A181898C0242394C7280A24F808A891031202' +
'04D4A801096122EC12C7AF060054C60662');
SRLBitmapsLoaded := True;
{$IFDEF SIMBA}
SetBitmapName(bmpMod,'SRL - Mod bitmap');
SetBitmapName(bmpAdmin,'SRL - Admin bitmap');
SetDTMName(Lamp,'SRL - Lamp bitmap');
{$ENDIF}
end;
{*******************************************************************************
procedure FreeSRLBitMaps;
By: Ron
Description: Frees SRL Bitmaps from memory.
*******************************************************************************}
procedure FreeSRLBitmaps;
begin
if SRLBitmapsLoaded then
begin
FreeBitmap(bmpMod);
FreeBitmap(bmpAdmin);
FreeDTM(Lamp);
SRLBitmapsLoaded := False;
end;
end;
{*******************************************************************************
procedure LoadSRLFonts;
By: Markus
Description: Loads SRL Fonts into memory.
*******************************************************************************}
procedure LoadSRLFonts;
begin
{$IFDEF LoadExtraFonts}
FriendChars := LoadChars2(FontPath + 'FriendChars/');
LoginChars := LoadChars2(FontPath + 'LoginChars/');
{$ENDIF}
end;
{*******************************************************************************
procedure FreeSRLFonts;
By: Markus
Description: Frees SRL Fonts from memory.
*******************************************************************************}
procedure FreeSRLFonts;
begin
{$IFDEF LoadExtraFonts}
FreeChars2(FriendChars);
FreeChars2(LoginChars);
{$ENDIF}
end;
{*******************************************************************************
procedure srl_Warn(ProcName, ErrorMessage: String; wVersion: Integer);
by: SRL Dev Team
Description: WriteLn's a warning message.
*******************************************************************************}
procedure srl_Warn(ProcName, ErrorMessage: String; wVersion: Integer);
begin
if (wVersion > WarnSensitivity) then
if (wVersion <> warn_Debug) then
WriteLn('** Warning in ' + ProcName + ': ' + ErrorMessage + '**')
else
WriteLn('Debugging ' + ProcName + ': ' + ErrorMessage);
if wVersion = -1 then
TerminateScript;
end;
{ MainScreen, Minimap, Inventory, Chat, Bank boxes as TBox }
var
MSBox, MMBox, MIBox, MCBox, MBBox: TBox;
{*******************************************************************************
Procedure SetupBoxes;
by: SRL Dev Team & MylesMadness
Description: Sets up Box variables
*******************************************************************************}
Procedure SetupBoxes;
begin
MSBox := IntToBox(MSX1, MSY1, MSX2, MSY2);
MMBox := IntToBox(MMX1, MMY1, MMX2, MMY2);
MIBox := IntToBox(MIX1, MIY1, MIX2, MIY2);
MCBox := IntToBox(MCX1, MCY1, MCX2, MCY2);
MBBox := IntToBox(MBX1, MBY1, MBX2, MBY2);
end;
{ const HP_BAR constants;
Global contants storing width, height and tolerance for HP bars.
Used in srl_InFight. }
const
HP_BAR_TOL = 3;
HP_BAR_WIDTH = 57;
HP_BAR_HEIGHT = 7;
{*******************************************************************************
function srl_InFight: Boolean;
By: Frement
Description: Checks whether player currently is in a fight, using mainscreen
HP bar presence detection. Returns True if Player's HP bar is detected.
*******************************************************************************}
function srl_InFight: Boolean;
var
I, C, HP_BAR_MIN, HP_BAR_MAX: Integer;
HP_BAR_GREEN, HP_BAR_RED, HP_BAR_HITS: TIntegerArray;
Colors: T2DIntegerArray;
TPA1, TPA2: TPointArray;
ATPA: T2DPointArray;
begin
HP_BAR_GREEN := [49499, 52611, 51081, 52641, 47667];
HP_BAR_RED := [590010, 590002, 131211, 524453, 594402];
HP_BAR_HITS := [789660, 1325811, 13865994, 1320341, 16294162,
12937740, 14185741, 4297620];
HP_BAR_MIN := HP_BAR_WIDTH * HP_BAR_HEIGHT div 10 - HP_BAR_TOL;
HP_BAR_MAX := HP_BAR_WIDTH * HP_BAR_HEIGHT * 3 div 2 + HP_BAR_TOL;
Colors := [HP_BAR_GREEN, HP_BAR_RED, HP_BAR_HITS];
for I := 0 to High(Colors) do
for C := 0 to High(Colors[I]) do
begin
FindColorsTolerance(TPA1, Colors[I][C],
MSCX - 30, MSCY - 120, MSCX + 30, MSCY + 20, 30);
TPA2 := CombineTPA(TPA1, TPA2);
end;
ATPA := TPAToATPAEx(TPA2, HP_BAR_WIDTH, HP_BAR_HEIGHT);
for I := 0 to High(ATPA) do
if (InRange(GetArrayLength(ATPA[I]), HP_BAR_MIN + 100, (HP_BAR_MAX * 2) + 400)) then
begin
Result := True;
Exit;
end;
end;