From f600e9f0f4f3f87e07138bd04efa93caac022fc2 Mon Sep 17 00:00:00 2001 From: ricky Date: Wed, 8 Jun 2011 21:18:52 +1000 Subject: [PATCH] #41 Full name match now takes precedence over partial matches --- TShockAPI/Tools.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/TShockAPI/Tools.cs b/TShockAPI/Tools.cs index 93bee215..d76aef00 100755 --- a/TShockAPI/Tools.cs +++ b/TShockAPI/Tools.cs @@ -139,20 +139,14 @@ namespace TShockAPI /// int player 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 found = new List(); 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())) found.Add(i); + } if (found.Count == 1) return found[0]; else if (found.Count > 1)