View Full Version : finding if player spoke in last 5 chat lines?
gsquare567
03-25-2007, 01:05 AM
i've made this function, which SHOULD check every line, starting from the bottom, for the occurance of a ':' then the occurance of the name before the ':', but it never finds the ':'!
function GHaveSpoken(Name: string): Boolean;
var
TextY, i: integer;
LineText : string;
begin
TextY := 415;
for i:=1 to 5 do
begin
LineText := LowerCase(Trim(GetTextAtEx(21, TextY, 0, SmallChars, False, False, 0, 0, 0, 80, False, tr_allChars)));
//writeln('Check ' + inttostr(i) + ': ' + inttostr(Pos(':', lineText)));
if(Pos(':', LineText) <> 0) then
begin
if(LowerCase(Copy(lineText,1,Pos(':', lineText)-1)) = lowercase(name)) then
begin
Result := True;
Exit;
end;
end;
TextY := TextY - 14;
end;
end;
edit: using findtext now, but this would be more efficient, i'd be happy if any1 could help me make this work.
gsquare567
03-27-2007, 03:29 AM
nvm, doesnt work. can sum1 tell me why my function dont work:
// sees whether or not player has spoken in last chatline
function GHaveSpoken: Boolean;
begin
Result := FindText(x,y,Players[CurrentPlayer].Name,smallchars,MCX1,414,MCX2,430);
end;
thanks!
nielsie95
03-27-2007, 08:12 PM
I'm not sure, but it could have something to do with Capitals? So maybe try to find the NickName
gsquare567
03-28-2007, 05:13 PM
tru dat i'll try that out thanks for actually responding ^^
smithspsbob
03-28-2007, 06:20 PM
If you go to Zezima-Reporter Script.
It has this in it:
procedure GetName;
begin
Text := Trim(GetTextAtEx(21, 415, 0, SmallChars, False, False, 0, 0, 0, 50, False, tr_AllChars));
Position := Pos(':', Text);
delete(Text, Position, 1);
Writeln(Text);
end;
That grabs names off where people who chatted.:D
From Jason2gs: Script @ http://www.villavu.com/forum/showthread.php?t=7496
Edit: I think it also collects the ":" to...
Smartzkid
03-28-2007, 06:26 PM
function GetName:String;
var
Text:String;
begin
Text := Trim(GetTextAtEx(21, 415, 0, SmallChars, False, False, 0, 0, 0, 50, False, tr_AllChars));
Position := Pos(':', Text);
delete(Text, Position, 1);
result:=Text;
end;
Fixed it up a little
gsquare567
03-28-2007, 09:35 PM
thanks a lot smith. but this doesnt really explain why mine doesnt work. mine, if you didnt understand it, has the exact same finding method as this (cept yours has lower length :S) but searches every line starting from the bottom. this is weird. and smartkidz, nice try... i can already see you forgot to declare position ;)
smithspsbob
03-29-2007, 02:37 AM
You could use:
function FindChatText(txt: String): Boolean;
I would try to test but i have no time.:D
gsquare567
03-30-2007, 02:35 AM
thats what im using atm. now a different problem/idea: say the chat box says "Usernameofsomeguy: Hey, sup?" and i say FindChatText("sup"). will it return true or false because i need to say the question mark too?
edit: why do i always ask before i try it myself. sorry every1. answer if u didnt know is that it finds any part of any word, so from "Sexiness" it could find "ess" ;)
nielsie95
03-30-2007, 10:55 AM
Yes, it will find the text ''sup'' in ''sup?'', and yes it will find the text ''ess'' in ''sexiness''. You could solve this by looking for '' ess '' (note the spaces). But then it wont find ''ess?''. If you know what I mean...;)
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.