Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant archive_postsperpage - assumed 'archive_postsperpage' (this will throw an Error in a future version of PHP) in ..../archive/index.php on line 456
How to get logged character's name? [Archive] - Forums

PDA

View Full Version : How to get logged character's name?



yucks
08-17-2013, 04:53 PM
Someone can help me? Thanks!

Ash Katchup
08-17-2013, 05:47 PM
Hello, Yucks.

How much you know about memory reading?

yucks
08-17-2013, 07:05 PM
Hello, thanks for answer, I'm newbie on that to create bots for Tibia, but I Know Delphi language, for now I've been helping myself with CheatEngine to retrieve the addresses where keeps the name of the char online, but can not find ...

I have this:



function TfrmMain.GetCharName():string;
var
name : string;
begin
Offset := Integer(GetTibiaBaseAddress(ProcessID));
name := ReadString(CharName + Offset);
Result := 'Char Name: ' + name;
end;

Where CharName is the address of Char who is Online.

Blood
08-18-2013, 12:04 PM
Using cheat engine, search "charlist selected index" and "charlist names"...
With a few calculations you can retrieve the character name...



const
LoginList_Selected = $????????; // index
LoginList_Address = $????????; // start of charlist structure
LoginList_Length = $????????; // char count
LoginList_Dist = 84; // distance in memory between each char in charlist
LoginList_DistName = 0;
LoginList_DistWorld = 30;

function getName:string;
var
pointer, selected:Integer;
begin
pointer := ReadMemInt( LoginList_Address );
selected := ReadMemInt( LoginList_Selected );
pointer := pointer + ( selected * LoginList_Dist );
Result := ReadMemStr( pointer + LoginList_DistName );
end;

function getWorld:string;
var
pointer, selected:Integer;
begin
pointer := ReadMemInt( LoginList_Address );
selected := ReadMemInt( LoginList_Selected );
pointer := pointer + ( selected * LoginList_Dist );
Result := ReadMemStr( pointer + LoginList_DistWorld );
end;


Ps.: This is for older versions... In the newest I think you need to calculate base address + xor and fix address and offsets...

Sketchy
08-18-2013, 01:59 PM
If you are working with the newest Tibia version your character's name, when logged in, is added to the client's window title in the format of "Tibia - Character Name". So you can just use GetWindowText to get the title and then sub string the character name out.

yucks
08-18-2013, 02:01 PM
Yes, I've made another function as you say Sketchy, taking name from window title:



function TfrmMain.GetCharName():string;
var
liLength : Integer;
lpChar : PChar;
name : string;
begin
liLength := GetWindowTextLength(TibiaH) + 1;
lpChar := StrAlloc(liLength);
Try
GetWindowText(TibiaH, lpChar, liLength);
Result:=fGen.MidStr(lpChar,9,Length(lpChar)-8);
Finally
StrDispose(lpChar);
End;
end;



Using cheat engine, search "charlist selected index" and "charlist names"...
With a few calculations you can retrieve the character name...



const
LoginList_Selected = $????????; // index
LoginList_Address = $????????; // start of charlist structure
LoginList_Length = $????????; // char count
LoginList_Dist = 84; // distance in memory between each char in charlist
LoginList_DistName = 0;
LoginList_DistWorld = 30;

function getName:string;
var
pointer, selected:Integer;
begin
pointer := ReadMemInt( LoginList_Address );
selected := ReadMemInt( LoginList_Selected );
pointer := pointer + ( selected * LoginList_Dist );
Result := ReadMemStr( pointer + LoginList_DistName );
end;

function getWorld:string;
var
pointer, selected:Integer;
begin
pointer := ReadMemInt( LoginList_Address );
selected := ReadMemInt( LoginList_Selected );
pointer := pointer + ( selected * LoginList_Dist );
Result := ReadMemStr( pointer + LoginList_DistWorld );
end;


Ps.: This is for older versions... In the newest I think you need to calculate base address + xor and fix address and offsets...

Thank you Blood.

XtrmJash
08-18-2013, 03:21 PM
Yes, I've made another function as you say Sketchy, taking name from window title:



function TfrmMain.GetCharName():string;
var
liLength : Integer;
lpChar : PChar;
name : string;
begin
liLength := GetWindowTextLength(TibiaH) + 1;
lpChar := StrAlloc(liLength);
Try
GetWindowText(TibiaH, lpChar, liLength);
Result:=fGen.MidStr(lpChar,9,Length(lpChar)-8);
Finally
StrDispose(lpChar);
End;
end;




Thank you Blood.

The way I normally go about it (in case you were interested) is by reading the battle list until one of the results returns a null string, then evaluate the list to find one which has my CID, if I find one, I'm logged in and my name is at the offset of the CID for that creature in the battle list + 0x4 bytes.