Log in

View Full Version : Dulicate Identifier Help



Seif
01-29-2012, 08:20 AM
Hello all. Was wondering if I could get some help with an error that seems to persist with certain scripts. After searching the forum for a bit and trying to find similar problems I finally came to the conclusion that I had to make my own thread about it. First of all, the problem came to head upon tinkering with some tutorial referring to a change in the green button for continue screen. I have since then uninstalled and reinstalled but to much disappointment it did not help. If anyone could help it would be appreciated. The error is as follows:
function ClickContinue(Click, Waiting: Boolean): Boolean;
var
x, y : Integer;
begin
Result := false;
Result := FindColor(x,y, 938793, 221, 457, 295, 474); // normal green, click continue bounds
{if not Result then // not sure if I want this, don't want it pressing space when it doesn't need to.
begin
Result := FindColor(x,y, 3067775, 221, 457, 295, 474);// hilight activated green
if not Result then
Exit;
end;}

if Click and Result then
begin
TypeSendEx(' ', False);
if Waiting then
ChatWait;
end;
end;

The script in use is "DemiseFisher" although I do get the same error with other scripts while some scripts have gone unaffected. When the error does pop up, it opens itself in a new tab titled "chat" and are between lines 247-266. [Error] C:\Simba\Includes\SRL/SRL/core/chat.scar(248:10): Duplicate identifier 'CLICKCONTINUE' at line 247
Compiling failed. If it helps, the entire context of the "chat" window is as such and between lines 1-501.
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- ? Chat Routines --//
//-----------------------------------------------------------------//
// * function SetChat(state: string; chat: Integer): Boolean; // by Wizzup?, WT-Fakawi, Starblaster100 & N1ke!
// * procedure SetAllChats(Pub, Priv, Clan, Trade, Assist: string); // by ZephyrsFury
// * procedure ChatsOff; // by Starblaster100
// * procedure ChatWait; // by Nielsie95
// * function ClickContinue(Click, Wait: Boolean): Boolean; // by Nielsie95
// * function ClickToContinue: Boolean; // by ZephyrsFury
// * function TextCoords(textn: Integer): TPoint; // by Wizzup?
// * function GetChatBoxText(Line, TextCol: Integer): string; // by ZephyrsFury
// * function FindChatBoxText(Line: Integer; Text: string; TextCol: Integer): Boolean; // by ZephyrsFury
// * function IsChatBoxTextBetween(Text: string; TextCol, StartLine, EndLine: Integer): Boolean; // by ZephyrsFury
// * function IsChatBoxTextAnyLine(Text: string; TextCol: Integer): Boolean; // by ZephyrsFury
// * function ChatBoxTextArray(TextCol: Integer): TStringArray; // by ZephyrsFury
// * Function GetBlackChatMessage: String; // by Wizzup?
// * Function FindBlackChatMessage(ChatMsg: String): Boolean; // by Wizzup?
// * function LastChatter(var name: String): Boolean; // by masquerader
// * function GetLastChatText(var chat: String): Boolean; // by masquerader
// * function InChat(Text: String): Boolean; // by WT-Fakawi
// * procedure FixChat; // by WT-Fakawi
// * function SaveToChatLog: Boolean; // by WT-Fakawi / masquerader
// * function ColorEffectAdd(Color, Effect: Boolean): string; // by NiCbaZ

const
CHAT_GAME = 0;
CHAT_PUBLIC = 1;
CHAT_PRIVATE = 2;
CHAT_FRIENDS = 3;
CHAT_CLAN = 4;
CHAT_TRADE = 5;
CHAT_ASSIST = 6;

{************************************************* ******************************
function SetChat(state: string; chat: Integer): Boolean;
By: Wizzup?, WT-Fakawi, Starblaster100, N1ke! & Coh3n
Description: Sets Chat to desired state
Chat: Game Public Private Friends Clan Trade Assist
0 1 2 3 4 5 6
************************************************** *****************************}
function SetChat(state: string; chat: Integer): Boolean;
var
x, y, mx, Color: Integer;
begin
result := false;
mx := 90 + (chat * 55);

if (not InRange(chat, CHAT_GAME, CHAT_ASSIST)) then
begin
srl_Warn('SetChat', 'chat(' + IntToStr(chat) + ') does not exist.', warn_AllVersions);
Exit;
end;

case Lowercase(State) of
'on', 'all': Color := 65280;
'off': Color := 255;
'hide': Color := 16776960;
'friends', 'filter': Color := 65535;
else
srl_Warn('SetChat', state + ' does not exist.', warn_AllVersions);
end;

if (not FindColor(x, y, Color, mx - 10, 486, mx + 10, 502)) then
begin
Mouse(mx, 496, 4, 4, False);
Wait(RandomRange(50, 150));

if (Lowercase(State) = 'off') then
begin
case chat of
CHAT_PUBLIC: Mouse(mx, 496 - 33, 8, 3, True);
CHAT_PRIVATE..CHAT_ASSIST: Mouse(mx, 496 - 20, 8, 3, True);
end;

Wait(RandomRange(50, 150));
Result := FindColor(x, y, Color, mx - 10, 486, mx + 10, 502);
end else
Result := WaitOption(Capitalize(State), 300);
end;
end;

{************************************************* ******************************
procedure SetAllChats(Game, Pub, Priv, Clan, Trade, Assist: string);
By: ZephyrsFury
Description: Sets all the chats to a particular state in one simple procedure.
Leave the parameter as '' if you wish to leave the chat as it is.
Example: SetAllChats('all', 'Hide', '', 'Off', '', 'Friends', '');
************************************************** *****************************}
procedure SetAllChats(Game, Pub, Priv, Friends, Clan, Trade, Assist: string);
var
States: TStringArray;
II: Integer;
begin
if (not(LoggedIn)) then Exit;
States := [Game, Pub, Priv, Friends, Clan, Trade, Assist];
for II := 0 to 6 do
begin
if (States[II] = '') then Continue;
SetChat(States[II], II);
end
end;

{************************************************* ******************************
procedure ChatsOff;
By: Starblaster100
Description: Sets all Chats to off.
************************************************** *****************************}
procedure ChatsOff;
var
i: Integer;
begin
for i := 1 to 6 do
SetChat('off', i);
end;

{************************************************* ******************************
procedure ChatWait;
By: Nielsie95
Description: Waits while there's Please Wait in the chatbox.
************************************************** *****************************}
procedure ChatWait;//MSI issue...
begin
Wait(400 + Random(500));
end;

(*
ClickContinue
~~~~~~~~~~~~~

.. code-block:: pascal

function ClickContinueEx(Click, Wait: Boolean): Boolean;


Returns true if the blue 'Click To Continue' text in the chat box is found.
If will click if Click = True, calls ChatWait if Wait = True.

.. note::

by _ChArMz & Narcle (Original by EvilChicken!)

Example:

.. code-block:: pascal



*)
function ClickContinueEx(Click, Wait: Boolean): Boolean;
var
bTxt, wTxt, SearchTPA, TextTPA, Matches : TPointArray;
Search2D : T2DPointArray;
b : TBox;
Height, i, x, y : Integer;
begin
Result := false;
FindColors(bTxt, 16711680, MCX1, MCY1, MCX2, MCY2);
FindColors(wTxt, 16777215, MCX1, MCY1, MCX2, MCY2);

SearchTPA := CombineTPA(bTxt, wTxt);
if Length(SearchTPA) < 1 then
Exit;

Search2D := SplitTPAEx(SearchTPA, 20, 2);

TextTPA := LoadTextTPA('here to conti', NPCChars, Height);
for i := 0 to High(Search2D) do
begin
Result := FindTextTPAinTPA(Height, TextTPA, Search2D[i], Matches);
if Result and Click then
begin
b := GetTPABounds(Search2D[i]);
GetMousePos(x, y);
if PointInBox(Point(x, y), b) then
Mouse(x, y, 2, 1, true)
else
with b do
Mouse(RandomRange(x1, x2), RandomRange(y1 + 2, y2 - 2), 2, 1, true);
if Wait then
ChatWait;
end;
if Result then
Break;
end;
end;

{************************************************* ******************************
Function ClickContinue(SpaceBar, DoWait: Boolean): Boolean;
By: Narcle
Description: Returns true if the green button in the chat box is found.
It will SpaceBar if true otherwise will mouse it. If DoWait = true
will wait until color count changes.
************************************************** *****************************}
Function ClickContinue(SpaceBar, DoWait: Boolean): Boolean;
var
TPA: TPointArray;
i, C, T: integer;
B: TBox;
ATPA: T2DPointArray;
begin
if ClickContinueEx(SpaceBar, DoWait) then
begin
Result := true;
Exit;
end;
C := GetColorToleranceSpeed;
SetColorToleranceSpeed(1);
FindColorsTolerance(TPA, 11776948, MCX1, MCY1, MCX2, MCY2, 0);//color is constant atm
SetColorToleranceSpeed(C);
if Length(TPA) < 1 then
Exit;
ATPA := SplitTPA(TPA, 2);
for i := 0 to High(ATPA) do
begin
B := GetTPABounds(ATPA[i]);
if InRange(B.x2-B.x1, 58, 72) then
if (CountColorTolerance(1203763, B.x1-5, B.y1+1, B.x2+5, B.y1+15, 37) > 50) then
begin
C := CountColor(0, MCX1, MCY1, MCX2, MCY2);
if SpaceBar then
TypeByte(VK_SPACE)
else
Mouse(B.x1, B.y1, (B.x2-B.x1), 8, true);
Result := True;
T := GetSystemTime + 10000;
if DoWait then
while (C = CountColor(0, MCX1, MCY1, MCX2, MCY2)) and (GetSystemTime < T) do
Wait(50+random(50));
Exit;
end;
end;
end;

{************************************************* ******************************
function ClickToContinue: Boolean;
by: ZephyrsFury
Description: Click the blue 'Click To Continue' text in the chat box.
************************************************** *****************************}
function PleaseWait : Boolean;
var x,y:integer;
begin
Result := false;
Result := FindColor(x,y, 3067775, 221, 457, 295, 474); // hilighted green in box
end;

function ClickContinue(Click, Waiting: Boolean): Boolean;
var
x, y : Integer;
begin
Result := false;
Result := FindColor(x,y, 938793, 221, 457, 295, 474); // normal green, click continue bounds
{if not Result then // not sure if I want this, don't want it pressing space when it doesn't need to.
begin
Result := FindColor(x,y, 3067775, 221, 457, 295, 474);// hilight activated green
if not Result then
Exit;
end;}

if Click and Result then
begin
TypeSendEx(' ', False);
if Waiting then
ChatWait;
end;
end;

{************************************************* ******************************
Function TextCoords(textn: Integer): TPoint;
By: Wizzup?
Description: Returns x, y for text. (1 to 8)
************************************************** *****************************}
function TextCoords(textn: Integer): TPoint;
begin
Result.X := 10;
Result.Y := 346 + (14 * (textn - 1));
end;

{************************************************* ******************************
function GetChatBoxText(Line, TextCol: Integer): string;
By: ZephyrsFury
Description: Gets text on the line Line with colour TextCol. (Line 1 is the top,
Line 8 is the bottom line).
Colours:
clMessage/clBlack - Black text messages ("Oh Dear you are dead", etc).
clChat/clBlue - Chat messages from you and other players.
clTrade/clPurple - Colour of trade request text.
clFriend - Colour of friend and clan chat.
Works with other colours too.
************************************************** *****************************}
function GetChatBoxText(Line, TextCol: Integer): string;
var
P: TPoint;
cArr: TPointArray;
B: TBox;
begin
Result := '';
P := TextCoords(Line);
if (FindColorsTolerance(cArr, TextCol, MCX1, P.y, MCX2, P.y + 13, 0)) then
begin
B := GetTPABounds(cArr);
{$IFDEF Simba}
result := Trim(GetTextAtExWrap(b.x1-1,p.y,B.x2+1,p.y+13,0,5,2,TextCol,0,SmallChars));
{$ELSE}
Result := Trim(GetTextAtEx(B.x1 - 1, B.y1 - 2, 0, SmallChars, False, False,
0, 1, TextCol, 80, False, tr_AllChars));
{$ENDIF}
end;
end;

{************************************************* ******************************
function FindChatBoxText(Text: string; Line: Integer; TextCol: Integer): Boolean;
By: ZephyrsFury
Description: Searches for Text on Line with colour TextCol. True if found.
************************************************** *****************************}
function FindChatBoxText(Text: string; Line: Integer; TextCol: Integer): Boolean;
begin
Result := (Pos(Text, GetChatBoxText(Line, TextCol)) > 0);
end;

{************************************************* ******************************
function IsChatBoxTextBetween(Text: string; TextCol, StartLine, EndLine: Integer): Boolean;
By: ZephyrsFury
Description: Returns true if Text with colour TextCol is found anywhere in the
chat box.
************************************************** *****************************}
function IsChatBoxTextBetween(Text: string; TextCol, StartLine, EndLine: Integer): Boolean;
var
II: Integer;
begin
Result := True;
for II := Max(StartLine, EndLine) downto Min(StartLine, EndLine) do
if (FindChatBoxText(Text, II, TextCol)) then
Exit;
Result := False;
end;

{************************************************* ******************************
function IsChatBoxTextAnyLine(Text: string; TextCol: Integer): Boolean;
By: ZephyrsFury
Description: Returns true if Text with colour TextCol is found anywhere in the
chat box.
************************************************** *****************************}
function IsChatBoxTextAnyLine(Text: string; TextCol: Integer): Boolean;
begin
Result := IsChatBoxTextBetween(Text, TextCol, 1, 8);
end;

{************************************************* ******************************
function ChatBoxTextArray(TextCol: Integer): TStringArray;
By: ZephyrsFury
Description: Gets and return a TStringArray with the contents of each line with
the colour TextCol (see GetChatBoxText for list of colours).
Line 1 is Result[1]
Line 2 is Result[2]
Line 3 is Result[3]
Line 4 is Result[4]
Line 5 is Result[5]
Line 6 is Result[6]
Line 7 is Result[7]
Line 8 is Result[8]
************************************************** *****************************}
function ChatBoxTextArray(TextCol: Integer): TStringArray;
var
II: Integer;
begin
SetLength(Result, 9);
for II := 8 downto 1 do
Result[II] := GetChatBoxText(II, TextCol);
end;

{************************************************* ******************************
function GetBlackChatMessage: String;
By: Wizzup?
Description: Gets text with color 0 in last chat line.
************************************************** *****************************}
function GetBlackChatMessage: string;
begin
Result := GetChatBoxText(8, clMessage);
end;

{************************************************* ******************************
function FindBlackChatMessage(ChatMsg: String): Boolean;
By: Wizzup?
Description: Returns True if text with color 0 in last chat line is found.
************************************************** *****************************}
function FindBlackChatMessage(ChatMsg: string): Boolean;
begin
Result := (Pos(ChatMsg, GetChatBoxText(8, clMessage)) > 0);
end;

{************************************************* ******************************
function LastChatter(var name: String): Boolean;
By: masquerader
Description:Returns name and true if a person was talking, or false and the text
************************************************** *****************************}
function LastChatter(var name: string): Boolean;
var
i: Integer;
begin
Result := False;
Name := LowerCase(GetBlackChatMessage);
i := Pos(':', name);
if (i <> 0) then
begin
Delete(Name, i, i);
Result := True;
end;
end;

{************************************************* ******************************
function GetLastChatText(var chat: String): Boolean;
By: masquerader / Wizzup?
Description: Returns true if blue chat text was found
************************************************** *****************************}
function GetLastChatText(var chat: string): Boolean;
begin
Chat := GetChatBoxText(8, clChat);
Result := (Chat <> '');
end;

{************************************************* ******************************
function InChat(Text: String): Boolean;
By: WT-Fakawi
Description: Grabs Last Chat Line and performs checks on occurence of text
************************************************** *****************************}
function InChat(Text: string): Boolean;
var
s: string;
begin
if (not (GetLastChatText(s))) then
LastChatter(s);
Result := (Pos(Text, s) > 0);
end;

{************************************************* ******************************
procedure FixChat;
by: WT-Fakawi fixed by JPHamlett
Description: Scrolls ChatText scrollbar down.
************************************************** *****************************}
procedure FixChat;
var
ScrollX, ScrollY: Integer;
begin
ScrollX := 507 + Random(8);
ScrollY := 451 + Random(8);
if (GetColor(505, 439) = 2041131) then
begin
MMouse(ScrollX, ScrollY, 0, 0);
HoldMouse(ScrollX, ScrollY, MouseAction(True));
while (GetColor(505, 439) = 2041131) do
Wait(10 + random(15));
Wait(50+random(50));
ReleaseMouse(ScrollX, ScrollY, MouseAction(true));
Wait(100+random(50));
end;
end;

{************************************************* ******************************
function SaveToChatLog: Boolean;
By: WT-Fakawi / masquerader
Description: Saves chat to log file
************************************************** *****************************}
procedure SaveToChatLog;
begin
FixChat;
OldLine := TheLine;

if(LastChatter(TheName))then
begin
GetLastChatText(TheLine);
TheLine:=' '+TheLine+' ';
if OldLine <> TheLine then
try AddToSRLLog(TheName+':'+TheLine); except end;
end else
begin
TheLine:=TheName;
if OldLine <> TheLine then
try AddToSRLLog(TheLine); except end;
end;
end;

{************************************************* ******************************
function ColorEffectAdd(Color, Effect: Boolean): string;
By: NiCbaZ
Description: Returns a RS chat effect based on 'Color' and 'Effect' booleans.
************************************************** *****************************}
function ColorEffectAdd(Color, Effect: Boolean): string;
var
Str : TStringArray;

begin
Result := '';
Str := ['flash1:', 'flash2:', 'flash3:', 'glow1:', 'glow2:', 'glow3:', 'red:',
'green:', 'cyan:', 'purple:', 'white:', 'scroll:', 'shake:', 'slide:',
'wave:', 'wave2:'];
if Color then
Result := Str[Random(11)];
if Effect then
Result := Result + Str[11 + Random(5)];
end;

Spiker
01-29-2012, 09:08 AM
It's because you have the function declared more than once.

EDIT: Misread - One is ClickContinueEx - Still looking

Seif
01-29-2012, 09:37 AM
If possible could I get you to paste your chat tab so that I can compare and make the changes? Any or all help would be much appreciated.

Spiker
01-29-2012, 09:42 AM
Here's my chat tab.

http://pastebin.com/zETp7sQ7

Good Luck

Seif
01-30-2012, 07:38 AM
Ahh, oddly enough it didn't help. I have tried replacing what I thought may be my missing texts aswell as just replacing my entire chat texts with a copy of yours. Much thanks for your help though m8.