SRL Archive - SRL Archives

More ChatCode of mine


n3ss3s

2007-12-04 13:36:01

Hey, I had a few simple ideas, the functions aren't nothing special, but maybe they help someone get along with the chat box.

Enjoy, open to all comments and suggestions/ improvements…


Type
ChatLine = Record
Name, Text: String;
End;

Function ChatBox: Array of ChatLine;
Var
X, Y, I: Integer;
Begin

SetArrayLength(Result, 8);

X := 10;

For I := 0 To 7 Do
Begin

Y := 345 + I * 14;

Result[i].Name := Replace(GetTextAtEx(x, y, 5, SmallChars, False, False, 0, 0,
0, 50, False, tr_allChars), ':', '');

Result[i].Text := GetTextAtEx(82, y, 5, SmallChars, False, False, 0, 0,
16711680, 50, False, tr_allChars);

End;
End;

Function LineOfName(TheName: String): Integer;
Var
Txts: Array of ChatLine;
I: Integer;
Begin
Txts := ChatBox;
For I := 0 To 7 Do
Begin
If Txts[i].Name = TheName Then
Begin
Result := i + 1;
Break;
End;
End;
End;

Function LineOfText(TheText: String): Integer;
Var
Txts: Array of ChatLine;
I: Integer;
Begin
Txts := ChatBox;
For I := 0 To 7 Do
Begin
If Txts[i].Text = TheText Then
Begin
Result := i + 1;
Break;
End;
End;
End;

Function NameOfChatter(TheText: String): String;
Var
Txts: Array of ChatLine;
I: Integer;
Begin
Txts := ChatBox;
For I := 0 To 7 Do
Begin
If Pos(TheText, Txts[i].Text) > 0 Then
Begin
Result := Txts[i].Name;
Break;
End;
End;
End;

Procedure RespondTo(Txt, By: String; Mark: Char; UseName: Boolean);
Var
Txts: Array of ChatLine;
I, X: Integer;
S, F: String;
Begin
Txts := ChatBox;
For I := 0 To 7 Do
Begin
If Pos(Txt, Txts[i].Text) > 0 Then
Begin
If UseName Then
S := NameOfChatter(Txt);
If Not Mark = '' Then
Begin
For X := 0 To Random(4) Do
F := F + Mark;
End;
TypeSend(S+', '+By+F);
End;
End;
End;

The functions should be pretty self-explanatory if you know any scar, oh right, you do, this is the members section :p

Anyhow, if something is bugging you feel free to ask…

mastaraymond

2007-12-04 13:43:14

I hear echo! Is the forum lagging for you to?

Delete your other thread ;).

EDIT: What happens if you get a runescape message, e.g. : "You attempt to catch a fish.".. It would return that text as the name?

n3ss3s

2007-12-04 13:55:41

Hmm gotta do a thing like If Pos(':', Texts.Name) = 0 Then Continue;

Thx lol, I wouldn't notice there came two threads.

:( Yes, the forums do lagg.

pwnaz0r

2007-12-04 15:23:37

Don't you mean


If (Pos(':', Texts[i].Name) <> 0) then continue;

Edit: I'm an idiot.