In Rust when using /pm it often happens that I get a "Player not found!" error even tho the name or partial name is correct. It seems like this plugin searches in offline players too and if there are multiple matches it'd throw this error as well.
Recently I have had a player called "Nigward" who I couldn't PM, turns out there was another player "NIGWARD" who wasn't online but would be selected as the target, so there was no way for me to PM the online player.
The same happens when a player is called "Simon" and there was another player once on the server called "Simono" then it's impossible to PM Simon as Simono is always selected instead.
I suggest only scanning the active player list and prioritizing exact name matches over partial matches, like so:
Recently I have had a player called "Nigward" who I couldn't PM, turns out there was another player "NIGWARD" who wasn't online but would be selected as the target, so there was no way for me to PM the online player.
The same happens when a player is called "Simon" and there was another player once on the server called "Simono" then it's impossible to PM Simon as Simono is always selected instead.
I suggest only scanning the active player list and prioritizing exact name matches over partial matches, like so:
// instead of
IPlayer target = covalence.Players.FindPlayer(args[0]);
// use
IPlayer target = BasePlayer.activePlayerList.Select(p => p.IPlayer).Where(p => p.Name == args[0]).FirstOrDefault()
?? BasePlayer.activePlayerList.Select(p => p.IPlayer).Where(p => p.Name.ToLower().Contains(args[0].ToLower())).FirstOrDefault();This will first look for an exact match, to avoid confusion between "Simon" and "Simono", and, if no exact match was found, do a partial match and only use online players to lookup as it makes inherently no sense to PM offline players.