View Full Version : Returning true if found black chat message.
KeepBotting
08-31-2012, 01:58 AM
How would I do this? FindBlackChatMessage isn't working for me.
My procedure:
procedure WaitForSignal;
begin
ScriptStatus:= 'Waiting for the signal';
ProgressReport;
if FindBlackChatMessage('[My Username]: 0') then
begin
writeln('found it');
end
else
writeln('didnt find it');
end;
Why doesn't this work? It always returns false.
The message IS there.
The message IS black.
I set my friends' chat to black text, spoke that chat message and FindBlackChatMessage doesn't find it.
So what's up?
Footy
08-31-2012, 01:59 AM
Works for me, make sure all capitalization is correct.
KeepBotting
08-31-2012, 02:01 AM
Works for me, make sure all capitalization is correct.
Does it start looking at the beginning of a line? Because my friends' chat tab is in the way.
In other words, will it find '[my username]: 0' if it's actually '[my friends' chat tag] [my username]: 0' with the friends' chat tab being blue?
EDIT: It works when I only include my username. Maybe there's something that's throwing it off...I have a 0 in my username, would that screw it up?
Footy
08-31-2012, 02:07 AM
Hmm, I doubt it. There's a function in SRL that reads the black text in the chat box and outputs it. I'm not positive what it's called, but if you find it, run it and see what's output.
KeepBotting
08-31-2012, 02:10 AM
Hmm, I doubt it. There's a function in SRL that reads the black text in the chat box and outputs it. I'm not positive what it's called, but if you find it, run it and see what's output.I believe I've got it.
Seems that FindBlackChatMessage doesn't like finding the first character in a line. Easily worked around.
Thanks ;)
Runaway
08-31-2012, 02:15 AM
You might be interested in this function if you're waiting for a specific message to appear:
function WaitMessage(Time: Integer; Text: String; Line: TIntegerArray): Boolean;
var
hLine, t, i: Integer;
begin
Result := False;
hLine := High(Line);
FixChat;
MarkTime(t);
while (TimeFromMark(t) < Time) do
begin
for i := 0 to hLine do
begin
Result := (Pos(Text, GetChatBoxText(Line[i], clMessage)) <> 0);
if Result then
Exit;
end;
Wait(25);
end;
end;
:)
KeepBotting
08-31-2012, 02:21 AM
You might be interested in this function if you're waiting for a specific message to appear:
function WaitMessage(Time: Integer; Text: String; Line: TIntegerArray): Boolean;
var
hLine, t, i: Integer;
begin
Result := False;
hLine := High(Line);
FixChat;
MarkTime(t);
while (TimeFromMark(t) < Time) do
begin
for i := 0 to hLine do
begin
Result := (Pos(Text, GetChatBoxText(Line[i], clMessage)) <> 0);
if Result then
Exit;
end;
Wait(25);
end;
end;
:)That seems pretty complex :P Thanks! I'll use this in later versions of my upcoming script.
How would I do this? FindBlackChatMessage isn't working for me.
My procedure:
procedure WaitForSignal;
begin
ScriptStatus:= 'Waiting for the signal';
ProgressReport;
if FindBlackChatMessage('[My Username]: 0') then
begin
writeln('found it');
end
else
writeln('didnt find it');
end;
Why doesn't this work? It always returns false.
The message IS there.
The message IS black.
I set my friends' chat to black text, spoke that chat message and FindBlackChatMessage doesn't find it.
So what's up?
Eh...? So is this what your friend actually said: Hi [My Username]: 0, nice to meet you'?
I'm pretty sure you want it to search for ur actual username, and NOT the words 'My UserName'? If it's meant to recognize a variable containing a string, you should just input the variable name without the ''. Also why put a [] around ur variable?
I believe what Riwu is trying to say is rather than searching for the string you have with [My Username] try and replace it with something along these lines:
procedure WaitForSignal;
begin
ScriptStatus:= 'Waiting for the signal';
ProgressReport;
if FindBlackChatMessage(Players[CurrentPlayer].Nick + ' 0') then
writeln('found it') else
writeln('didnt find it');
end;
KeepBotting
08-31-2012, 10:26 AM
Eh...? So is this what your friend actually said: Hi [My Username]: 0, nice to meet you'?
I'm pretty sure you want it to search for ur actual username, and NOT the words 'My UserName'? If it's meant to recognize a variable containing a string, you should just input the variable name without the ''. Also why put a [] around ur variable?
I believe what Riwu is trying to say is rather than searching for the string you have with [My Username] try and replace it with something along these lines:
procedure WaitForSignal;
begin
ScriptStatus:= 'Waiting for the signal';
ProgressReport;
if FindBlackChatMessage(Players[CurrentPlayer].Nick + ' 0') then
writeln('found it') else
writeln('didnt find it');
end;I had just censored my username, that's why it's there.
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.