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
Useful Functions and Procedures
Results 1 to 6 of 6

Thread: Useful Functions and Procedures

  1. #1
    Senior Member
    Join Date
    Mar 2007
    Posts
    605

    Useful Functions and Procedures

    I'll be posting up some useful delphi code here every so often for those that don't know how to do certain things.

    Find Item:
    Code:
    Function FindItem(ID_Item:integer):TItemBp;
    var
     BP, slot:byte;
    Begin
     Result.found :=False;
     For Bp:=0 to 15 do
      Begin
         If MemReadByte(Adr_bp_Open+(Dist_bp*bp)) = 1 then
           Begin
            For slot:=0 to MemReadByte(Adr_bp+(Dist_bp*bp)-4) do
                Begin
                    if ID_Item = MemReadSmallInt(adr_Bp+(Dist_bp*bp)+(12*slot)) then
                      Begin
                          Result.BP:= bp;
                          Result.slot:= slot;
                          Result.found :=True;
                          Exit;
                      End;
                End;
           End;
      End;
    
    End;
    Some memory functions:
    Code:
    function MemReadByte(Address: Integer): Byte;
    var Value:Byte;
    begin
      ReadProcessMemory(TibiaClient.IDProcess, Ptr(Address), @Value, 1, TibiaClient.NBR);
      Result := Value;
    end;
    
    function MemReadSmallInt(adress:integer): SmallInt;
    var
     value : SmallInt;
    Begin
     ReadProcessMemory(TibiaClient.IDProcess, Ptr(adress), @Value,  2, TibiaClient.NBR);
     Result:=Value;
    End;
    Count items function:
    Code:
    function getamount(itemid:integer):integer;
    var
      amount,i,x:integer;
    begin
    amount:=0;
    for i:=0 to 15 do
    begin
    If MemReadByte(Adr_bp_Open+(Dist_bp*i)) = 1 then
           Begin
            For x:=0 to MemReadByte(Adr_bp+(Dist_bp*i)-4) do
                Begin
                    if itemid = MemReadSmallInt(adr_Bp+(Dist_bp*i)+(12*x)) then
                      Begin
                          amount:=amount+1;
                      End;
                End;
           End;
    end;
    result:=amount;
    end;
    Move item from to:
    Code:
    procedure packetsend_movefromto(slotto:byte;count:byte; item_ID:smallint);
    var
      Pid:Cardinal;
    begin
    GetWindowThreadProcessId(FindWindow('TibiaClient', nil), @Pid);
    item:= FindItem(item_ID);
    if (item.found=true) then
    begin
        packetBuffer[0]:= $0F;
        packetBuffer[1]:= $00;
        packetBuffer[2] := $78;
        packetBuffer[3] := $FF;
        packetBuffer[4] := $FF;
        packetBuffer[5] := $40+item.bp;
        packetBuffer[6] := $00;
        packetBuffer[7] := item.slot;
        packetBuffer[8] := $4B;
        packetBuffer[9] := $0C;
        packetBuffer[10] := item.slot;
        packetBuffer[11] := $FF;
        packetBuffer[12] := $FF;
        packetBuffer[13] := Slotto;
        packetBuffer[14] := $00;
        packetBuffer[15] := Slotto;
        packetBuffer[16] := Count;
    SendPacket(Pid, @PacketBuffer, TRUE, FALSE);
    end;
    end;

  2. #2
    Junior Member
    Join Date
    Mar 2007
    Posts
    15

    Useful Functions and Procedures

    Really Nice

    Good Work xD

  3. #3

    Useful Functions and Procedures

    I have a question ^^

    Code:
    AdrContainerStart=Adr_bp_Open;
    
    Adr_bp_Open = Container_Start;
    
    Adr_Bp =  <<<<  But what is this??
    Cuz when I set here BackPack Slot adress I get result 0 for finditem function :/

  4. #4
    Senior Member
    Join Date
    Mar 2007
    Posts
    605

    Useful Functions and Procedures

    I knew someone would ask this; adr_bp for 8.0 is $617000+60 (basically bp_open+60).

    Mace.

  5. #5
    Senior Member
    Join Date
    Oct 2007
    Posts
    1,045

    Useful Functions and Procedures

    Another infraction for Numone007

  6. #6
    Junior Member
    Join Date
    Dec 2010
    Posts
    2

    RE: Useful Functions and Procedures

    Great, thanks! The memory functions are really helpful. I'm not really sure what the "move item from to" code actually does Do you find these codes in other places or do you come up with them on your own?

Posting Permissions

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