SRL Archive - Reflection Help

NPC Chat


mormonman

2009-01-14 23:30:28

Is there anyway to make a function that findsnpcchat, like in the normal srl? i tried to find someway, but im not so good with reflection. Any help?

Naike

2009-01-15 01:31:03

You can use SRLs one since reflection don't got any.

ZaSz

2009-01-15 02:44:52

LIES!!!!

{*******************************************************************************
function ChatBoxTextExists(Text: string): Boolean;
By: lordsaturn
Description: Returns true if text exists and is visible in the chatbox according
to 'ChatType'.
*******************************************************************************}

So all you would have to put is
if ChatBoxTextExists('zasz owns') then
begin
writeln('Zasz GOT 10 YEAR DOMAIN AND 4 YEAR HOSTING FOR FREE!!');
end;

Scaper

2009-01-15 03:38:20

if ChatBoxTextExists('vicrant60 owns') then
begin
writeln('Because Scaper GOT 10 YEAR DOMAIN AND 8 YEAR HOSTING FOR FREE!!');
end;

and yea you found it and this is no way to boast :p

Heysus

2009-01-15 04:00:04

The functions reflection has are for the chat box. I think what he wants is the text when you are talking to an NPC. Reflection doesn't have that yet but it is possible.

mormonman

2009-01-15 08:47:02

From: N1ke!
You can use SRLs one since reflection don't got any.


i am… but reflection is faster most of the time… i just want to know if anyone else can do it?

Heysus

2009-01-15 10:03:16

I made these functions. Not sure if they work for all NPC chat but it worked for everything I tested it on.

Function GetNPCChat: array of string;
var
P, C: integer;
Parents: array of integer;
begin
Parents := [64, 228, 241, 242];
for P:=Low(Parents) to High(Parents) do
for C:=1 to 6 do
if GetInterfaceText(Parents[P], C) <> '' then
begin
SetArrayLength(Result, GetArrayLength(Result) + 1);
Result[High(Result)] := GetInterfaceText(Parents[P], C);
end;
end;

Function IsNPCChat(Text: string): boolean;
var
i: integer;
Chat: array of string;
begin
Result := false;
Chat := GetNPCChat;
if GetArrayLength(Chat) = 0 then
exit;
for i:=0 to High(Chat) do
begin
if Pos(Text, Chat[i]) > 0 then
begin
Result := true;
exit;
end;
end;
end;

mormonman

2009-01-15 10:06:31

nice… but i actually think there are some more parents… but i can find those on my own. thanks!

Shady?

2009-01-15 11:37:53

just to spam a little more :/

if ChatBoxTextExists('vicrant60 owns') then
begin
writeln('Because vicrant60 is going to buy me an iphone!!!!!);
end;