Skip to content
Browse files

Added the /clearitems command. (includes new clearitems permission)

  • Loading branch information...
1 parent 574573f commit 89a1480b0f3a0f92a90aa673262bd47d2775335e @DaGamesta DaGamesta committed Nov 30, 2011
Showing with 49 additions and 0 deletions.
  1. +1 −0 DBEditor/CommandList.cs
  2. +45 −0 TShockAPI/Commands.cs
  3. +3 −0 TShockAPI/Permissions.cs
View
1 DBEditor/CommandList.cs
@@ -36,6 +36,7 @@ public static void AddRemainingTShockCommands()
CommandList.Add("kill");
CommandList.Add("butcher");
CommandList.Add("item");
+ CommandList.Add("clearitems");
CommandList.Add("heal");
CommandList.Add("whisper");
CommandList.Add("annoy");
View
45 TShockAPI/Commands.cs
@@ -184,6 +184,7 @@ public static void InitCommands()
add(Permissions.butcher, Butcher, "butcher");
add(Permissions.item, Item, "item", "i");
add(Permissions.item, Give, "give");
+ add(Permissions.clearitems, ClearItems, "clearitems");
add(Permissions.heal, Heal, "heal");
add(Permissions.buff, Buff, "buff");
add(Permissions.buffplayer, GBuff, "gbuff", "buffplayer");
@@ -2417,6 +2418,50 @@ private static void Give(CommandArgs args)
}
}
+ public static void ClearItems(CommandArgs args)
+ {
+
+ int radius = 50;
+ if (args.Parameters.Count > 0)
+ {
+
+ if (args.Parameters[0].ToLower() == "all")
+ {
+
+ radius = Int32.MaxValue / 16;
+
+ }
+ else
+ {
+
+ try
+ {
+
+ radius = Convert.ToInt32(args.Parameters[0]);
+
+ }
+ catch (Exception) { args.Player.SendMessage("Please either enter the keyword \"all\", or the block radius you wish to delete all items from.", Color.Red); return; }
+
+ }
+
+ }
+ int count = 0;
+ for (int i = 0; i < 200; i++)
+ {
+
+ if ((Math.Sqrt(Math.Pow(Main.item[i].position.X - args.Player.X, 2) + Math.Pow(Main.item[i].position.Y - args.Player.Y, 2)) < radius * 16) && (Main.item[i].active))
+ {
+
+ Main.item[i].active = false;
+ NetMessage.SendData(0x15, -1, -1, "", i, 0f, 0f, 0f, 0);
+ count++;
+ }
+
+ }
+ args.Player.SendMessage("All " + count.ToString() + " items within a radius of " + radius.ToString() + " have been deleted.");
+
+ }
+
private static void Heal(CommandArgs args)
{
TSPlayer playerToHeal;
View
3 TShockAPI/Permissions.cs
@@ -123,6 +123,9 @@ public static class Permissions
[Description("User can spawn items")]
public static readonly string item;
+ [Description("User can clear item drops.")]
+ public static readonly string clearitems;
+
[Description("")]
public static readonly string heal;

0 comments on commit 89a1480

Please sign in to comment.
Something went wrong with that request. Please try again.