Fix /clearitems

1.2 has 400 item slots instead of 200.
This commit is contained in:
MarioE 2013-10-02 15:01:57 -04:00
parent 48e1db012c
commit 01dcf6c3fc

View file

@ -3695,31 +3695,27 @@ namespace TShockAPI
} }
else else
{ {
try if (!int.TryParse(args.Parameters[0], out radius))
{ {
radius = Convert.ToInt32(args.Parameters[0]); args.Player.SendErrorMessage("Invalid block radius.");
}
catch (Exception)
{
args.Player.SendErrorMessage(
"Please either enter the keyword \"all\", or the block radius you wish to delete all items from.");
return; return;
} }
} }
} }
int count = 0; int count = 0;
for (int i = 0; i < 200; i++) for (int i = 0; i < 400; i++)
{ {
if ( if ((Main.item[i].position.X - args.Player.X) * (Main.item[i].position.X - args.Player.X) +
(Math.Sqrt(Math.Pow(Main.item[i].position.X - args.Player.X, 2) + (Main.item[i].position.Y - args.Player.Y) * (Main.item[i].position.Y - args.Player.Y) <= radius * radius * 256
Math.Pow(Main.item[i].position.Y - args.Player.Y, 2)) < radius*16) && (Main.item[i].active)) && (Main.item[i].active))
{ {
Main.item[i].active = false; Main.item[i].active = false;
NetMessage.SendData(0x15, -1, -1, "", i, 0f, 0f, 0f, 0); TSPlayer.All.SendData(PacketTypes.ItemDrop, "", i);
count++; count++;
} }
} }
args.Player.SendSuccessMessage("All " + count + " items within a radius of " + radius + " have been deleted."); args.Player.SendSuccessMessage("Deleted {0} items within a radius of {1}", count, radius);
} }
private static void Heal(CommandArgs args) private static void Heal(CommandArgs args)