SRL Archive - General

Getting Text


HoMoReXuaL

2012-07-06 11:58:31

Could somebody provide a built in method or a written procedure that gets the last text line from the rs chatbox, because when i use GetBlackChatMessage, It stores things like "? || _ ?" into my string..

Zeta Matt

2012-07-06 19:10:16

Use the InChat function, it gets the last line only.

Mine is like this:

if InChat('Bot') then
begin
PlaySound('C:/simba/alarm.wav');
writeln('WARNING: Someone may be talking to you!');
Wait(1000);
end;
*It has FixChat before.

I didn't understand the "It stores things like "? || _ ?" into my string.." thing, tough lol. Maybe InChat does the same thing, you could tell what you want to do, so it's better to help =)

HoMoReXuaL

2012-07-06 20:05:05

Well i need the a function that gets the line and stores it in a string because i am also trying to get the name of the player who has spoken

Brandon

2012-07-06 20:54:33


{$I SRL/SRL.Simba}

{*
Author: Brandon.

Get's The Player's Name at the specified Line.
*}
Function GetPlayerName(Line: Integer): String;
var
TPA: TPointArray;
B: TBox;
P: TPoint;
Text: String;
begin
P:= TextCoords(Line);
If (FindColorsTolerance(TPA, CLBLACK, MCX1, P.y, MCX2, P.y + 13, 0)) then
begin
B := GetTPABounds(TPA);
Text := Trim(GetTextAtExWrap(B.X1 - 1, P.Y, B.X2 + 1, P.Y + 13, 0, 5, 2, CLBLACK, 0, SmallChars));
Result:= Copy(Text, 0, High(Text) - 2);
end;
end;

{*
Author: Brandon.

Gets the name of the player who said the text.
*}
Function GetPlayerWhoSaid(Text: String): String;
var
TPA: TPointArray;
P: TPoint;
B: TBox;
I: Integer;
begin
For I:= 1 To 8 Do
begin
P := TextCoords(I);
If (FindColorsTolerance(TPA, CLBLUE, MCX1, P.y, MCX2, P.y + 13, 0)) then
begin
B := GetTPABounds(TPA);
If (Text = Trim(GetTextAtExWrap(B.X1 - 1, P.Y, B.X2 + 1, P.Y + 13, 0, 5, 2, CLBLUE, 0, SmallChars))) then
begin
Result:= GetPlayerName(I);
Break;
end;
end;
end;
end;

begin
SetupSRL;

writeln(GetPlayerWhoSaid('Brandon'));
end.

HoMoReXuaL

2012-07-06 21:23:53

Wbout code for checking if a specific text was said in the last line

Brandon

2012-07-06 21:56:17

From: HoMoReXuaL
Wbout code for checking if a specific text was said in the last line


You can do that. I already provide code. Your can figure that part out I believe. Maybe look at the parameters? Or modify the function to only search the last line..

HoMoReXuaL

2012-07-06 22:09:09

Actually i dont really understand the code could you pleeaaaaaaaase put it together for me? <3

Brandon

2012-07-06 22:47:02

If you do not want it to search all 8 lines, then change the for-loop to:

For I:= 8 To 8 Do

Or replace it with I:= 8.

It wouldn't be so difficult if you tried to understand it.

Joe

2012-07-06 23:09:48

From: Brandon
If you do not want it to search all 8 lines, then change the for-loop to:

For I:= 8 To 8 Do

Or replace it with I:= 8.

It wouldn't be so difficult if you tried to understand it.


Let the young padewans learn.
But yes, brandon totally pwned.
PS. is this little snippet of code in an include- its very nice.

HoMoReXuaL

2012-07-07 00:40:09

This is what your GetPlayerName is returning as a string - "? - - ? ? ?? -s'? ? ? ?? -s'? ? [ ]" for a name

And would this be valid to check if someone said "!"?
if length(GetPlayerWhoSaid('!')) > 0 then
begin
end;
of course with what i want to do in between..
Could it be because I didn't put the Setup SRL; in my code?