Players can now TP if they have a bed set, though their bed spawn will be destroyed

This commit is contained in:
Twitchy 2011-06-23 19:33:40 +12:00
parent 74371539c0
commit 5a38810305

View file

@ -36,6 +36,7 @@ namespace TShockAPI
public int Index { get; protected set; } public int Index { get; protected set; }
public DateTime LastPvpChange { get; protected set; } public DateTime LastPvpChange { get; protected set; }
public Rectangle TempArea = new Rectangle(); public Rectangle TempArea = new Rectangle();
public bool RealPlayer public bool RealPlayer
{ {
get { return Index >= 0 && Index < Main.maxNetPlayers; } get { return Index >= 0 && Index < Main.maxNetPlayers; }
@ -133,21 +134,27 @@ namespace TShockAPI
public bool Teleport(int tileX, int tileY) public bool Teleport(int tileX, int tileY)
{ {
if (TPlayer.SpawnX >= 0 && TPlayer.SpawnY >= 0) int spawnTileX = Main.spawnTileX;
return false; int spawnTileY = Main.spawnTileY;
int oldSpawnX = Main.spawnTileX;
int oldSpawnY = Main.spawnTileY;
Main.spawnTileX = tileX; Main.spawnTileX = tileX;
Main.spawnTileY = tileY; Main.spawnTileY = tileY;
//Send only that player the new spawn point data NetMessage.SendData((int)PacketTypes.WorldInfo, Index, -1, "", 0, 0.0f, 0.0f, 0.0f);
NetMessage.SendData((int)PacketTypes.WorldInfo, Index, -1, "", 0, 0f, 0f, 0f); if (TPlayer.SpawnX >= 0 && TPlayer.SpawnY >= 0)
//Force them to respawn {
Spawn(); Main.tile[TPlayer.SpawnX, TPlayer.SpawnY].active = false;
//Reset to old spawnpoint and send spawn data back to player NetMessage.SendTileSquare(Index, TPlayer.SpawnX, TPlayer.SpawnY, 1);
Main.spawnTileX = (int)oldSpawnX; Spawn();
Main.spawnTileY = (int)oldSpawnY; Main.tile[TPlayer.SpawnX, TPlayer.SpawnY].active = true;
NetMessage.SendData((int)PacketTypes.WorldInfo, Index, -1, "", 0, 0f, 0f, 0f); NetMessage.SendTileSquare(Index, TPlayer.SpawnX, TPlayer.SpawnY, 1);
SendMessage("Warning! Your bed spawn point has been destroyed because of warp", Color.Red);
}
else
{
Spawn();
}
Main.spawnTileX = spawnTileX;
Main.spawnTileY = spawnTileY;
NetMessage.SendData((int)PacketTypes.WorldInfo, Index, -1, "", 0, 0.0f, 0.0f, 0.0f);
return true; return true;
} }