Indicate when Teleport has failed.

This commit is contained in:
Deathmax 2011-07-06 22:09:15 +08:00
parent ecc6da2a96
commit da60e1cd0c
2 changed files with 10 additions and 5 deletions

View file

@ -843,8 +843,8 @@ namespace TShockAPI
{ {
if (Main.player[i].active && (Main.player[i] != args.TPlayer)) if (Main.player[i].active && (Main.player[i] != args.TPlayer))
{ {
TShock.Players[i].Teleport(args.Player.TileX, args.Player.TileY + 3); if (TShock.Players[i].Teleport(args.Player.TileX, args.Player.TileY + 3))
TShock.Players[i].SendMessage(string.Format("You were teleported to {0}.", args.Player.Name)); TShock.Players[i].SendMessage(string.Format("You were teleported to {0}.", args.Player.Name));
} }
} }
return; return;

View file

@ -159,7 +159,11 @@ namespace TShockAPI
//150 Should avoid all client crash errors //150 Should avoid all client crash errors
//The error occurs when a tile trys to update which the client hasnt load yet, Clients only update tiles withen 150 blocks //The error occurs when a tile trys to update which the client hasnt load yet, Clients only update tiles withen 150 blocks
//Try 300 if it does not work (Higher number - Longer load times - Less chance of error) //Try 300 if it does not work (Higher number - Longer load times - Less chance of error)
SendTileSquare(tileX, tileY, 150); if (!SendTileSquare(tileX, tileY, 150))
{
SendMessage("Warning, teleport failed due to being too close to the edge of the map.", Color.Red);
return false;
}
if (TPlayer.SpawnX > 0 && TPlayer.SpawnY > 0) if (TPlayer.SpawnX > 0 && TPlayer.SpawnY > 0)
{ {
@ -202,11 +206,12 @@ namespace TShockAPI
SendData(PacketTypes.PlayerSpawn, "", Index, 0.0f, 0.0f, 0.0f); SendData(PacketTypes.PlayerSpawn, "", Index, 0.0f, 0.0f, 0.0f);
} }
public virtual void SendTileSquare(int x, int y, int size = 10) public virtual bool SendTileSquare(int x, int y, int size = 10)
{ {
if (x + size >= Main.maxTilesX || y + size >= Main.maxTilesX) if (x + size >= Main.maxTilesX || y + size >= Main.maxTilesX)
return; return false;
SendData(PacketTypes.TileSendSquare, "", size, (float)(x - (size / 2)), (float)(y - (size / 2)), 0f); SendData(PacketTypes.TileSendSquare, "", size, (float)(x - (size / 2)), (float)(y - (size / 2)), 0f);
return true;
} }
public virtual void GiveItem(int type, string name, int width, int height, int stack) public virtual void GiveItem(int type, string name, int width, int height, int stack)