From 85f1ba6643ec35596b9e788bd6b3661b93b82229 Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sat, 20 Aug 2011 20:45:19 +0800 Subject: [PATCH] Force respawn after death. (prevents some forms of invisibility) --- TShockAPI/GetDataHandlers.cs | 2 ++ TShockAPI/TSPlayer.cs | 2 ++ TShockAPI/TShock.cs | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index e1cbaf15..a2a52de7 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -500,6 +500,8 @@ namespace TShockAPI { return Tools.HandleGriefer(args.Player, TShock.Config.KillMeAbuseReason); } + args.Player.LastDeath = DateTime.Now; + args.Player.ForceSpawn = true; return false; } diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 9fab4321..426f9638 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -58,6 +58,8 @@ namespace TShockAPI public bool TpLock = false; Player FakePlayer; public List RequestedSections = new List(); + public DateTime LastDeath { get; set; } + public bool ForceSpawn = false; public bool RealPlayer { diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index e4ae03f5..87711492 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -385,6 +385,11 @@ namespace TShockAPI } if (CheckPlayerCollision(player.TileX, player.TileY)) player.SendMessage("You are currently nocliping!", Color.Red); + if (player.LastDeath != null && player.ForceSpawn && (DateTime.Now - player.LastDeath).Seconds >= 3) + { + player.Spawn(); + player.ForceSpawn = false; + } } } }