Hi y'all,
I've been tinkering on some SRL functions and adjusted a few things. The idea was to look in the chatbox for a text like "mining", then storing the persons name, so nexttime the same person asks it again, it would give a False and not answer him/her.
Problem i have is that it keeps on looping the response.
Anyone can tell me where i've gone wrong?
SCAR Code:
program New;
{.include SRL/SRL.scar}
Var
Slevel: Integer;
function ChatsBlueText: array of string;
var
I: Byte;
tpa: TPointArray;
begin
SetArrayLength(tpa, 9);
for I := 8 DownTo 1 do
tpa[i] := TextCoords(i);
SetArrayLength(Result, 9);
for I := 1 to 8 do
Result[I] := Trim(GetTextAtEx(tpa[i].x - 2, tpa[i].y - 2, 0, SmallChars, False,
False, 0, 1, 16711680, 80, False, tr_AllChars));
end;
function CheckChat(ChatTxt1, ChatTxt2, ChatTxt3, ChatTxt4: string): Boolean;
var
a: Integer;
name1, name2, name3, name4: string;
textP: TPoint;
TheLines: array of string;
I: Byte;
begin
Result := False;
TheLines := ChatsBlueText;
for I := 8 DownTo 1 do
if (Pos(ChatTxt1, TheLines[I]) <> 0) or
(Pos(ChatTxt2, TheLines[I]) <> 0) or
(Pos(ChatTxt3, TheLines[I]) <> 0) or
(Pos(ChatTxt4, TheLines[I]) <> 0) then
begin
textP := TextCoords(I);
name1 := LowerCase(Trim(GetTextAtEx(textP.x - 2, textP.y - 2, 0, SmallChars, False, False, 0, 1,
0, 60, False, tr_allChars)));
a := Pos(':', name1);
if (a <> 0) then
begin
Delete(name1, a, a);
if (not(name1 = name2)) and
(not(name1 = name3)) and
(not(name1 = name4)) then
begin
name4 := name3;
name3 := name2;
name2 := name1;
Result := True;
Exit;
end;
end;
end;
end;
begin
setupsrl;
activateclient;
Slevel := GetSkillLevel('mining');
Wait(200 + Random(100));
GameTab(4);
repeat
Wait(1000 + Random(500));
if (CheckChat('Mng', 'lvl', 'Mining', 'level') = True) then
writeln(IntToStr(Slevel))
until (False)
end.
EDIT: Fixed, had to assign a temporary string to name2, name3 and name4, I guess comparing its find against a blank would result in a True;