From 314613ef234698348ffda2c217fe0293a83a7083 Mon Sep 17 00:00:00 2001 From: Maverick Motherfucker Date: Mon, 30 May 2011 01:47:14 -0700 Subject: [PATCH] Got anti tile greif semi working --- TShockAPI/TShock.cs | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index e92b8120..fc755e77 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -12,6 +12,8 @@ namespace TShockAPI { public class TShock : TerrariaPlugin { + private uint[] tileThreshold = new uint[Main.maxPlayers]; + public static string saveDir = "./tshock/"; public override Version Version @@ -41,12 +43,29 @@ namespace TShockAPI GameHooks.OnUpdate += new Action(OnUpdate); GameHooks.OnLoadContent += new Action(OnLoadContent); ServerHooks.OnChat += new Action(OnChat); + NetHooks.OnPreGetData += GetData; } /* * Hooks: * */ + void GetData(byte id, messageBuffer msg, int idx, int length, HandledEventArgs e) + { + int n = 5; + byte[] buf = msg.readBuffer; + if (id == 17) + { + byte type = buf[n]; + n++; + if (type == 0) + { + tileThreshold[msg.whoAmI]++; + } + } + return; + } + void OnChat(int ply, string msg, HandledEventArgs handler) { if (IsAdmin(ply)) @@ -92,7 +111,22 @@ namespace TShockAPI void OnUpdate(GameTime time) { - + for (uint i = 0; i < Main.maxPlayers; i++) + { + if (tileThreshold[i] >= 5) + { + if (Main.player[i] != null) + { + WriteGrief((int)i); + Kick((int)i, "Fuck you bomb spam or some other fucking shit"); + } + tileThreshold[i] = 0; + } + else if (tileThreshold[i] > 0) + { + tileThreshold[i]--; + } + } } /*