diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs
index 57217799..df697519 100644
--- a/TShockAPI/Commands.cs
+++ b/TShockAPI/Commands.cs
@@ -64,7 +64,7 @@ namespace TShockAPI
{
string plStr = args.Message.Remove(0, 5).Trim();
int ply = args.PlayerID;
- if (!(Tools.FindPlayer(plStr) == -1 || plStr == ""))
+ if (!(Tools.FindPlayer(plStr) == -1 || Tools.FindPlayer(plStr) == -2 || plStr == ""))
{
if (!TShock.players[Tools.FindPlayer(plStr)].IsAdmin())
{
@@ -74,6 +74,8 @@ namespace TShockAPI
else
Tools.SendMessage(ply, "You can't kick another admin!", new float[] { 255f, 0f, 0f });
}
+ else if (Tools.FindPlayer(plStr) == -2)
+ Tools.SendMessage(ply, "More than one player matched!", new float[] { 255f, 0f, 0f });
else
Tools.SendMessage(ply, "Invalid player!", new float[] { 255f, 0f, 0f });
}
@@ -82,7 +84,7 @@ namespace TShockAPI
{
string plStr = args.Message.Remove(0, 4).Trim();
int ply = args.PlayerID;
- if (!(Tools.FindPlayer(plStr) == -1 || plStr == ""))
+ if (!(Tools.FindPlayer(plStr) == -1 || Tools.FindPlayer(plStr) == -2 || plStr == ""))
{
if (!TShock.players[Tools.FindPlayer(plStr)].IsAdmin())
{
@@ -92,6 +94,8 @@ namespace TShockAPI
else
Tools.SendMessage(ply, "You can't ban another admin!", new float[] { 255f, 0f, 0f });
}
+ else if (Tools.FindPlayer(plStr) == -2)
+ Tools.SendMessage(ply, "More than one player matched!", new float[] { 255f, 0f, 0f });
else
Tools.SendMessage(ply, "Invalid player!", new float[] { 255f, 0f, 0f });
}
diff --git a/TShockAPI/Tools.cs b/TShockAPI/Tools.cs
index 653155c2..d1852618 100644
--- a/TShockAPI/Tools.cs
+++ b/TShockAPI/Tools.cs
@@ -1,6 +1,7 @@
using System;
using System.IO;
using Terraria;
+using System.Collections.Generic;
namespace TShockAPI
{
@@ -116,7 +117,7 @@ namespace TShockAPI
/// int player
public static int FindPlayer(string ply)
{
- int pl = -1;
+ /*int pl = -1;
for (int i = 0; i < Main.player.Length; i++)
{
if ((ply.ToLower()) == Main.player[i].name.ToLower())
@@ -125,7 +126,17 @@ namespace TShockAPI
break;
}
}
- return pl;
+ return pl;*/
+ List found = new List();
+ for (int i = 0; i < Main.player.Length; i++)
+ if (Main.player[i].name.ToLower().Contains(ply.ToLower()))
+ found.Add(i);
+ if (found.Count == 1)
+ return found[0];
+ else if (found.Count > 1)
+ return -2;
+ else
+ return -1;
}
///