public uint GetLocalPlayerByName(string First, string Last)
{
foreach (uint PlayerObject in GetPlayers(true))
{
if (GetFirstName(PlayerObject) != First)
continue;
if (String.IsNullOrEmpty(Last))
{
if (!String.IsNullOrEmpty(GetLastName(PlayerObject)))
continue;
}
else
{
if (GetLastName(PlayerObject) != Last)
continue;
}
return PlayerObject;
}
string SearchDisplayName;
string ThisDisplayName;
//
// Make a final pass that checks against the display names of
// players in the game, to handle oddly named players (such as
// those with spaces in their first name).
//
// N.B. This match is ambiguous.
//
SearchDisplayName = First;
if (Last != null)
{
SearchDisplayName += " ";
SearchDisplayName += Last;
}
foreach (uint PlayerObject in GetPlayers(true))
{
string ThisLast;
ThisDisplayName = GetFirstName(PlayerObject);
ThisLast = GetLastName(PlayerObject);
if (!String.IsNullOrEmpty(ThisLast))
{
ThisDisplayName += " ";
ThisDisplayName += ThisLast;
}
if (ThisDisplayName != SearchDisplayName)
continue;
return PlayerObject;
}
return OBJECT_INVALID;
}