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
[C#] Tibia API - GetTileWithPlayer() not working
Results 1 to 5 of 5

Thread: [C#] Tibia API - GetTileWithPlayer() not working

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    8

    [C#] Tibia API - GetTileWithPlayer() not working

    Hello,

    I'm trying to use client.Map.GetTilesOnSameFloor() but it returns an error on GetTileWithPlayer().

    "NullReferenceException was unhandled
    Object reference not set to an instance of an object."
    playerTile returns null
    client.PlayerLocation returns {(32535, 31534, 7)}

    Map.MapPointer = 0x5E6E88 + BaseAddress;
    I'm using GetTile() TibiaAPI's current code by blaster_89.
    http://tpforums.org/forum/thread-9196-page-9.html

    It returns that erro when i use the following codes...
    Code:
    Tile tile = client.Map.GetTilesOnSameFloor().First(t => t.Location.Equals(new Location(Variables.Player.X, (Variables.Player.Y + 1), Variables.Player.Z)));
    Code:
    Tile tile = client.Map.GetTile(new Location(Variables.Player.X, (Variables.Player.Y -1), Variables.Player.Z));
    Code:
    public Tile GetTileWithPlayer()
            {
                if (playerTile == null || playerTile.Location != client.PlayerLocation)
                {
                    uint playerId = client.Player.Id;
    
                    playerTile = GetTiles(false, false).FirstOrDefault(
                        t => t.Objects.Any(
                            o => o.Id == 0x63 && o.Data == playerId));
                    playerTile.Location = client.PlayerLocation;
                }
                return playerTile;
            }
    Code:
    private Tile GetTile(Location worldLocation, Tile playerTile)
            {
                // All credits goes to blaster_89 who solved this.
                if (playerTile == null) { playerTile = GetTileWithPlayer(); }
                Location memLoc = worldLocation.ToMemoryLocation(playerTile, client);
                uint num = memLoc.ToTileNumber();
    
                int minFloor = 0, maxFloor = 0;
                for (int i = 0; i < 8; i++)
                {
                    if (playerTile.TileNumber >= Addresses.Map.MaxTiles * i &&
                        playerTile.TileNumber <= Addresses.Map.MaxTiles * (i + 1))
                    {
    
                        minFloor = Convert.ToInt32(Addresses.Map.MaxTiles * i);
                        maxFloor = Convert.ToInt32(Addresses.Map.MaxTiles * (i + 1) - 1);
                        break;
                    }
                }
                if (num > maxFloor) { num = Convert.ToUInt32(num - maxFloor + minFloor - 1); }
                else if (num < minFloor) { num = Convert.ToUInt32(maxFloor - minFloor + num + 1); }
                return GetTile(num, playerTile);
            }

  2. #2
    Super Moderator
    Join Date
    May 2007
    Posts
    1,191

    RE: [C#] Tibia API - GetTileWithPlayer() not working

    Are your offsets correct?

  3. #3
    Junior Member
    Join Date
    Mar 2012
    Posts
    8

    RE: [C#] Tibia API - GetTileWithPlayer() not working

    Hello,

    If it's not correct, please can you tell me what's wrong and the corrects values? Thanks!

    Code:
                Map.StepTile = 168;
                Map.StepTileObject = 12;
                Map.DistanceTileObjectCount = 0;
                Map.DistanceTileObjects = 4;
                Map.MaxTileObjects = 10;
                Map.MaxX = 18;
                Map.MaxY = 14;
                Map.MaxZ = 8;
                Map.MaxTiles = 2016;
                Map.ZAxisDefault = 7;
    I tried both offsets..
    Code:
                Map.DistanceObjectId = 4; 
                Map.DistanceObjectData = 0;
                Map.DistanceObjectDataEx = 8;
    Code:
                Map.DistanceObjectId = 0; 
                Map.DistanceObjectData = 4;
                Map.DistanceObjectDataEx = 8;

  4. #4
    Junior Member
    Join Date
    Mar 2012
    Posts
    8

    RE: [C#] Tibia API - GetTileWithPlayer() not working

    Does someone had that same error?

  5. #5
    Sorry for bumping but I have almost exactly the same problem now
    Last edited by normik; 09-16-2014 at 11:06 PM.

Posting Permissions

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