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 85

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 85
Help me with simple code problem
Results 1 to 4 of 4

Thread: Help me with simple code problem

  1. #1
    Junior Member
    Join Date
    Mar 2016
    Posts
    6

    Question Help me with simple code problem

    I'm trying to print at my bot the target X position, however i'm not getting it. What is being printed is 0 always. My knowledge about programming is only one year of studying C++ at college, so don't judge me. I'm using this code:

    Code:
     public int getTargetID()
            {
                return ReadInt32(Tibia.Handle, targetidAdr);
            }
    Code:
     public UInt32 getTargetAdr()
            {
                int tId = getTargetID();
                UInt32 battleListIdAdr = 0x05C68B0;
                UInt32 targetAdr = 0;
                for (int i = 0; i <= 250; i++)
                {
                    if (ReadInt32(Tibia.Handle, battleListIdAdr + i * 156) == tId)
                    {
                        targetAdr = Convert.ToUInt32(battleListIdAdr + i * 156);
                    }
                }
                return targetAdr;
            }
    Code:
     public int getTargetXPos()
            {
                UInt32 targetAdr = getTargetAdr();
                int xpos;
                xpos = ReadInt32(Tibia.Handle, targetAdr + 32);
                return xpos;
            }
    Code:
    txpos = getTargetXPos();
    label22.Text = Convert.ToString(txpos);
    It's a bot for tibia 7.72, the creature step is 156. Can you guys help me?

  2. #2
    Senior Member Lolrapa's Avatar
    Join Date
    Mar 2014
    Posts
    125
    I was about to say that creature structure size isnt 156 but then I read you comment.

    I dont know whats the step of creatures in 7.72 but lets assume thats right.

    Are you sure X position step is 32?
    Current structure is

    Code:
    struct BattleCreature 
    {
    	int Id;
    	char Name[8 * sizeof(int)];
    	int Z;
    	int Y;
    	int X;
    .
    .
    .
    it means x offset is 44 = (8 + 1 + 1 + 1) * 4

  3. #3
    Junior Member
    Join Date
    Mar 2016
    Posts
    6
    after you told me to review the offset to find the target position X , I realized that the distance from the address that stores the IDs in the battle list until the position X is 36 and not 32.
    The distance from battle list starts until the position X is 32. So that is why I was doing it wrong. Thanks bro.

  4. #4
    Senior Member Lolrapa's Avatar
    Join Date
    Mar 2014
    Posts
    125
    Quote Originally Posted by saviofcb View Post
    after you told me to review the offset to find the target position X , I realized that the distance from the address that stores the IDs in the battle list until the position X is 36 and not 32.
    The distance from battle list starts until the position X is 32. So that is why I was doing it wrong. Thanks bro.
    Glad I could help you! Whenever you want

Posting Permissions

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