#41 Full name match now takes precedence over partial matches
This commit is contained in:
parent
2174d7e94d
commit
f600e9f0f4
1 changed files with 4 additions and 10 deletions
|
|
@ -139,20 +139,14 @@ namespace TShockAPI
|
||||||
/// <returns>int player</returns>
|
/// <returns>int player</returns>
|
||||||
public static int FindPlayer(string ply)
|
public static int FindPlayer(string ply)
|
||||||
{
|
{
|
||||||
/*int pl = -1;
|
|
||||||
for (int i = 0; i < Main.player.Length; i++)
|
|
||||||
{
|
|
||||||
if ((ply.ToLower()) == Main.player[i].name.ToLower())
|
|
||||||
{
|
|
||||||
pl = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return pl;*/
|
|
||||||
List<int> found = new List<int>();
|
List<int> found = new List<int>();
|
||||||
for (int i = 0; i < Main.player.Length; i++)
|
for (int i = 0; i < Main.player.Length; i++)
|
||||||
|
{
|
||||||
|
if (Main.player[i].name.ToLower().Equals(ply.ToLower()))
|
||||||
|
return i;
|
||||||
if (Main.player[i].name.ToLower().Contains(ply.ToLower()))
|
if (Main.player[i].name.ToLower().Contains(ply.ToLower()))
|
||||||
found.Add(i);
|
found.Add(i);
|
||||||
|
}
|
||||||
if (found.Count == 1)
|
if (found.Count == 1)
|
||||||
return found[0];
|
return found[0];
|
||||||
else if (found.Count > 1)
|
else if (found.Count > 1)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue