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 misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
Problem with my code.
Results 1 to 8 of 8

Thread: Problem with my code.

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    19

    Problem with my code.

    Hello. I writing this topic, because I really looking for help.
    I trying to do it so long time, but it isn't work. It should work on server based on Tibia 7.72.

    That's my code:
    Code:
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ExtCtrls;
    
    type
      TForm1 = class(TForm)
        Button2: TButton;
        ListBox1: TListBox;
        Button1: TButton;
        procedure Button2Click(Sender: TObject);
        procedure Button1Click(Sender: TObject);
    
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    const
    PLAYER_ID =$5C684C;
    BATTLELIST_Start=$5C68B4 + 4;
    BATTLELIST_END=$5CC248;
    
    Distance_ID= 0;
    Distance_Type = -1;
    Distance_Name= -0;
    Distance_X = 32;
    Distance_Y = 36;
    Distance_Z = 40;
    Distance_HorizScreenOffset = 44;
    Distance_VertScreenOffset = 48;
    Distance_Chameleon = 60;
    Distance_Chameleon2 = 92;
    Distance_IsWalking = 72;
    Distance_Direction = 76;
    Distance_Outfit = 92;
    Distance_OutfitHead = 96;
    Distance_OutfitBody = 100;
    Distance_OutfitLegs = 104;
    Distance_OutfitFeet = 108;
    Distance_OutfitAddon = 112;
    Distance_LightColor1 = 121;
    Distance_LightColor2 = 122;
    Distance_LightPattern = 123;
    Distance_BlackSquare = 128;
    Distance_HP = 132;
    Distance_WalkSpeed = 136;
    Distance_IsVisible = 140;
    Distance_Skull = 144;
    Distance_Duel = 148;
    Target_ID=$00613B3C;
    DISTANCE_LIGHT= $74;
    DISTANCE_LIGHTCOLOR= $78;
    STATUS_TEXT_TIMER= $71DBDC;
    STATUS_TEXT= $71DBE0;
    Backpack_Start=$5CEDD8;
    Backpack_Name=16;
    Backpack_Size=48;
    Backpack_Amount=56;
    Backpack_ItemID=60;
    Backpack_ItemCount=64;
    Backpack_StepSlot=12;
    Backpack_StepContainer=492;
    
    implementation
    
    {$R *.dfm}
    procedure SendPacket(ProcessID: Cardinal; Packet: Pointer; Encrypt: Boolean; SafeArray: Boolean); stdcall; external 'packet.dll';
    //////////////////////////////////////////////
    //////////////////////////////////////////////
    //////////funkcje czytania///////////////////
    ////////////////////////////////////////////
    ///////////////////////////////////////////
    procedure MemWriteInteger(Address: Integer; buf: Integer; Length: DWORD);
    var ProcID, THandle: Integer;
    e: DWORD;
    begin
    GetWindowThreadProcessId(FindWindow('TibiaClient',Nil), @ProcID);
    THandle := OpenProcess(PROCESS_ALL_ACCESS, False, ProcID);
    WriteProcessMemory(THandle, Ptr(Address), @buf, Length, e);
    CloseHandle(THandle);
    end;
    
    procedure MemWriteString(Address: Integer; buf: String; Length: DWORD);
    var ProcID: Integer;
    THandle: hWnd;
    e: DWORD;
    begin
    GetWindowThreadProcessId(FindWindow('TibiaClient',Nil), @ProcID);
    THandle := OpenProcess(PROCESS_ALL_ACCESS, False, ProcID);
    WriteProcessMemory(THandle, Pointer(Address), PChar(buf), Length, e);
    CloseHandle(THandle);
    end;
    
    function MemReadInteger(Address: Cardinal): Cardinal; //Read adress:value
    var
    ProcId: Cardinal;
    tProc: THandle;
    NBR: Cardinal;
    value:integer;
    begin
    GetWindowThreadProcessId(FindWindow('TibiaClient',Nil), @ProcId);
    tProc:= OpenProcess(PROCESS_ALL_ACCESS, False, ProcId);
    ReadProcessMemory(tProc, Ptr(Address), @value, 4, NBR);
    CloseHandle(tProc);
    Result:=value;
    end;
    
    
    function MemReadString(Address: Integer): String;
    var
    NB : LongWord;
    Temp : ARRAY [1..255] OF Byte;
    I : Byte;
    IDProcess, proc_ID : Cardinal;
    begin
    GetWindowThreadProcessID(FindWindow('TibiaClient', nil), @proc_ID);
    IDProcess := OpenProcess(PROCESS_ALL_ACCESS, false, proc_ID);
    Result := '';
    ReadProcessMemory(IDProcess, Ptr(Address), @Temp[1], 255, NB);
    for I := 1 to 255 do
    begin
    if ((Temp[i] = 0) or (Temp[i] = $0F)) then
    Break;
    Result := Result + Chr(Temp[i]);
    end;
    end;
    ///////////////////////////////////////////////
    //////////////////////////////////////////////
    //////////koniec/////////////////////////////
    ////////////////////////////////////////////
    ///////////////////////////////////////////
    
    
    function pozycja:integer;
    var
    i,id_battle,id:integer;
    begin
    ID:=memreadinteger(Player_id); //odczytanie naszego id z adresu
    for i:=1 to 149 do //przeszukanie wszystkich pozycji na battle list (minimalna 1 maxymanlna 149
    Begin
    id_battle:=memreadinteger(Battlelist_start + i*168);
    if id_battle=ID then //jezeli id z battle list zgadza sie z id z adresu
    Begin
    Result :=i; //wtedy wynikiem funkcji jest nasza pozycja na battle
    exit;
    end;
    end;
    end;
    
    ///////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////
    ///////////////////////pozycja koniec////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////
    
    
    
    procedure TForm1.Button2Click(Sender: TObject);
    var
    i:integer;
    begin
    listbox1.items.Clear;
    for i:=1 to 149 do
    Listbox1.Items.Add(memreadstring(Battlelist_start + (i*156)-4));
    end;
    
    
    
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    showmessage(MemReadString(BattleList_Start+pozycja*160+Distance_name));
    end;
    
    
    end.
    If you have some ideas or if you know what's wrong with this code please tell me or give me some advices.
    The problem is when I trying to read my nickname by using this code:
    showmessage(MemReadString(BattleList_Start+pozycja *160+Distance_name));
    I was reading some tutorials with that and everybody saying that this script is able to work..
    Last edited by Dronic; 04-04-2014 at 07:38 PM.

  2. #2
    Senior Member
    Join Date
    Dec 2011
    Posts
    249
    You even indent bro?

  3. #3
    Junior Member
    Join Date
    Mar 2014
    Posts
    19
    What you mean by that m8?
    I'd like just to read my name by using ''pozycja'' function. I know that when I will just get my name I will create cavebot easier ; )

    When I using this one:
    showmessage(MemReadString(BattleList_Start+pozycja *160+Distance_name)
    I just getting some shit, but not my nickname..

  4. #4
    Senior Member
    Join Date
    Dec 2011
    Posts
    249
    This is what I meant in my previous post: http://en.wikipedia.org/wiki/Indent_style

    Are you sure the creature struct size in 7.72 is 160? And all the other addresses are correct?

    Also this:

    Code:
    Distance_Name= -0;
    Should be

    Code:
    Distance_Name= 4;

  5. #5
    Senior Member
    Join Date
    Jan 2012
    Posts
    417
    @Dronic, would be better you learn how to grab it on the latest client, because the battle list hasn't changed much, as far as I know, and most of the (active) people around here won't bother to download such an old client to help you out.

    Basically, if you grab the latest client, you are going to have faster responses for your problem and the underlying procedure is still the same in the 7.72 (I believe). Probably you'll just need to update constants like battle list step, some offsets, addresses and things like that.

  6. #6
    Junior Member
    Join Date
    Mar 2014
    Posts
    19
    I think that the size is 156. I just hope that other addresses are correct. The battlelist_start address is correct.
    The link what did u give me is.... so much reading.

    Maybe I really should download newest client. Could you give me link to any?

  7. #7
    Senior Member
    Join Date
    Jan 2012
    Posts
    417
    www.tibia.com
    > acc > download

  8. #8
    Junior Member
    Join Date
    Mar 2014
    Posts
    19
    have u got a link with addresses?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •