SRL Archive - OSR Help

Getting player chat message


rj

2013-03-17 19:18:15

Can anyone point me in the direct of saving what a player says? For example, if I wanted the script to Writeln everything that "nub_cake32" sais in public chat, how would I do that?
Like if "Nub_cake32" sais:

Nub_cake32: Hello, I am a noob

Hello, I am a noob
Thanks in advance

Sin

2013-03-17 19:26:01

GetChatBoxText():String;

rj

2013-03-17 19:27:11

From: Sin
GetChatBoxText():String;


Can it look for what a specific player said?

Sin

2013-03-17 19:32:57

Im writing this w/o the compiler, please edit out any mistakes:


function GetChatFromName(Name:String):String;
var
i:Integer;
begin
for i := 8 downto 1 do
begin
if FindChatBoxText(Name,i,clBlack) then
begin
Result := GetChatBoxText(i,clBlue);
break;
end;
end;
end;

Im not sure how Explode works, so I probably (99%) sure that I did it wrong. You'll have to get someone to get the Explode() working correctly.

EDIT:
Nvm idk what im smoking, its edited to be correct.

rj

2013-03-17 19:36:16

From: Sin
Im writing this w/o the compiler, please edit out any mistakes:


function GetChatFromName(Name:String):String;
var
i:Integer;
begin
for i := 8 downto 1 do
begin
if FindChatBoxText(Name,i,clBlack) then
begin
Result := GetChatBoxText(i,clBlue);
break;
end;
end;
end;

Im not sure how Explode works, so I probably (99%) sure that I did it wrong. You'll have to get someone to get the Explode() working correctly.

EDIT:
Nvm idk what im smoking, its edited to be correct.


So Do I use it like:

GetChatFromName(PlayerName)

OR

GetChatFromName(PlayerName,Stringvariablehere)

Or what I keep getting errors

Sin

2013-03-17 19:38:10

Its a function that returns a string.
You'll have to declare a string (var s:String), then

s := GetChatFromName('Zezima');

rj

2013-03-17 19:41:08

From: Sin
Its a function that returns a string.
You'll have to declare a string (var s:String), then

s := GetChatFromName('Zezima');

ahh got it, if this works out I will reserect a funny script I found on powerbot back in 2010

Edit, it is not working

Said := GetChatFromName('Namehere')
Writeln('' + Said)


If i have a title does that effect it?

Sin

2013-03-17 19:50:48


Messed around with it a little:


function GetChatFromName(Name:String):TStringArray;
var
i:Integer;
TSA:array of String;
begin
SetLength(TSA,9);
TSA[0] := '';
for i := 1 to 8 do
begin
if FindChatBoxText(Name,i,clBlack) then
begin
TSA[i] := GetChatBoxText(i,clBlue);
writeLn('In index ' + ToStr(i)+ ' ' + TSA[i]);
end;
end;
Result := TSA;
end;

EDIT:

The trivia game??????? OMG

rj

2013-03-17 19:54:02

From: Sin

Messed around with it a little:


function GetChatFromName(Name:String):TStringArray;
var
i:Integer;
TSA:array of String;
begin
SetLength(TSA,9);
TSA[0] := '';
for i := 1 to 8 do
begin
if FindChatBoxText(Name,i,clBlack) then
begin
TSA[i] := GetChatBoxText(i,clBlue);
writeLn('In index ' + ToStr(i)+ ' ' + TSA[i]);
end;
end;
Result := TSA;
end;

EDIT:

The trivia game??????? OMG


Edit, got it. You will see

Sin

2013-03-17 19:56:13

Uh…… IDK?
Im just running stock settings lol.

The Mayor

2013-03-17 19:59:34

Looking forward to the trivia game!

rj

2013-03-17 19:59:48

This is going to be so funny stock up on throwaway accounts boys lolol.


If I get into SRL mems I will release it myself there, if not I will ask a member+ too

rj

2013-03-17 20:12:16

From: Sin
Uh…… IDK?
Im just running stock settings lol.


Sorry about double post, but it is now just compiling and then ending..

I'm using

Begin
SetupSRL;
GetChatFromName('myname')
End.

As my main loop :/ I got it to work one time but now it does not

Sin

2013-03-17 20:16:10

Umm… It's public chat, chat is blue, name is correct right?

rj

2013-03-17 20:16:56

From: Sin
Umm… It's public chat, chat is blue, name is correct right?


Yea, I tried using spaces instead of underscores and underscores instead of spaces

Output:

Compiled successfully in 686 ms.
SRL Compiled in 0 msec
Paired with SMART[2728]
Successfully executed.


also, when i try to not use smart and drag target to smart it closes out of smart


EDIT: Ok, I figured out it can't find names with spaces, but how do I make it filters the boxes that don't have their name in it?

Sin

2013-03-17 21:04:16

SRL Compiled in 0 msec
Paired with SMART[8784]
Asking Question: What is the village of NPCS called north of Falador?
In index 1
In index 2
In index 3
In index 4
In index 5
In index 6
In index 7
In index 8 Goblin village
Correct Answer: Player1645?
Successfully executed.


I think it's glitching for you >_<

Le Jingle

2013-03-17 21:13:19

Here's a little snippet I made a while back:

{$include_once srl/srl.simba}
{$include_once srl/srl/misc/debug.simba}

function GetChatBoxTextAnyColor(Line: Integer): array of string;
var
TempCTS, i: Integer;
P: TPoint;
B: TBox;
clearTPA, res: TPointArray;
Area51Colors: TIntegerArray;
begin
P := TextCoords(Line);
TempCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(3);
B := IntToBox(MCX1 + 5, P.y, MCX2 - 19, P.y + 13);
FindColorsTolerance(clearTPA, 7705763, B.X1, B.Y1, B.X2, B.Y2, 22);
ReturnPointsNotInTPAWrap(clearTPA, B, res);

debugTPA(res, '');
Area51Colors := GetColors(res);
ClearSameIntegers(Area51Colors);
SetArrayLength(result, Length(Area51Colors));

B := GetTPABounds(res);
for i := 0 to high(Area51Colors) do
result[i] := Trim(GetTextAtExWrap(B.X1 - 1, P.y, B.X2 + 1, P.y + 13,
0, 5, 2, Area51Colors[i], 0, SmallChars));
ColorToleranceSpeed(1);
ColorToleranceSpeed(TempCTS);
end;

function GetCBTxt(line: integer): string;
begin
result := Implode(' ', GetChatBoxTextAnyColor(line));
{
remove := ['', '', '', '', '', '', '', '', '', ''];
for i := 0 to high(remove) do
result := ReplaceWrap(result, remove[i], '', []);
}
end;

begin
SetupSRL;
Writeln(GetCBTxt(8));
end.

Note, I didn't bother filtering out the unidentifiable characters from the string (doesn't make much a difference unless you actually need to use the strings later on).

Sin

2013-03-17 21:51:11

Got my script working!

I just need more questions.