SRL Archive - OSR Help

Reading ':' in chatbox?


Justin

2012-10-16 04:25:52

Hey all.

Trying to make a little script just to help out with my Clan.

Aim of the script is for the user to type "@Follow" in the clan chat and the account would do a "MMToMS" and scan for all the players until it found who typed '@Follow' in the clan message, Problem is, when reading the chatbox, ':' is returning as '?'

eg:

[Clan Name] PlayerName: @Follow

Would return in Simba as:


?Clan Name] PlayerName? @Follow

Current code being used;


function GetLastClanMsg: string;
var
P: TPoint;
cArr: TPointArray;
B: TBox;
begin
Result := '';
P := TextCoords(8);
if (FindColorsTolerance(cArr, 0, MCX1, P.y, MCX2, P.y + 13, 255)) then
begin
B := GetTPABounds(cArr);
result := Trim(GetTextAtExWrap(b.x1-1,p.y,B.x2+1,p.y+13,0,5,2,0,255,SmallChars));
end;
end;

^^ from chat.simba (modified to read all colors)


Writeln(GetLastClanMsg);

Output:

?Clan Name] PlayerName? @Follow
^^ removed real clan name and real playername

Any help on what to do to solve this issue?

E: I have tried the Replace funtion with no luck


Tmp := Replace(GetLastClanMsg, '?', '');
writeln(Tmp);

riwu

2012-10-16 04:46:45

try
TheName:=Between(']', '?', GetLastClanMsg);

Justin

2012-10-16 05:09:36

From: riwu
try
TheName:=Between(']', '?', GetLastClanMsg);


Didn't work for me.

I have made a really dirty way of doing this…


function GetLastClanMsg: string;
var
P: TPoint;
cArr: TPointArray;
B: TBox;
begin
Result := '';
P := TextCoords(8);
if (FindColorsTolerance(cArr, 0, MCX1, P.y, MCX2, P.y + 13, 255)) then
begin
B := GetTPABounds(cArr);
result := Trim(GetTextAtExWrap(b.x1-1,p.y,B.x2+1,p.y+13,0,5,2,0,255,SmallCharsNS));
end;
end;


Tmp := GetLastClanMsg;
Tmp := Replace(Tmp,'..',':');
Tmp := Replace(Tmp,'[','');
Tmp := Replace(Tmp,']','');
FinalMsg := Replace(Tmp,'CLAN NAME ','/');
if ((Pos('@Follow', FinalMsg) > 0) or ((Pos('@follow', FinalMsg) > 0))) then
begin
Writeln(FinalMsg);
Writeln('@Follow command activated by : ' + Between('/', ':', FinalMsg));
FindClanMember;
Wait(60000);
end;

riwu

2012-10-16 05:23:36

Well i didn't know what other weird characters you can get.
Can just be
Pos('@follow',Lowercase(FinalMsg));
With Between function what's in front doesn't really matter actually, just need to make sure the symbol after Clan Name is same as substring 1.

Home

2012-10-16 05:30:22

So what you are trying to do is to get the name of the Player who typed "@Follow"?

~Home

Le Jingle

2012-10-16 05:34:55

Kinda new to RegEx's, but I think;


procedure doStuff();
var
thestring:string;
begin
thestring := GetLastClanMsg;
if ExecRegExpr('@{1}Follow|@{1}follow', thestring) then // if we find @Follow or @follow in thestring, then we'll evaluate to true.
writeln('true');
end;

might be what you are looking for?

Justin

2012-10-16 05:44:44

From: Home
So what you are trying to do is to get the name of the Player who typed "@Follow"?

~Home


Correct, but the problem was that SmallChars didn't read : correctly, using SmallCharsNS and replacing '..' (what SmallCharsNS picks up : as) with : worked.

I know its a dirty code but it works :p

litoris

2012-10-16 10:28:02

You could also use a DTM/bitmap of the whole message, but seems like you have a fix.