ACR_ServerCommunicator.ACR_ServerCommunicator.GetLocalPlayerByName C# (CSharp) Method

GetLocalPlayerByName() public method

Get a local player by character name.
public GetLocalPlayerByName ( string First, string Last ) : uint
First string Supplies the character first name.
Last string Optionally supplies the character last name. ///
return uint
        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;
        }
ACR_ServerCommunicator