Exemplo n.º 1
0
        /// <summary>
        /// Sets an override player character name and community name on the player list for all players. Is not persistent.
        /// </summary>
        /// <param name="target">The player whose name is being overridden.</param>
        /// <param name="nameOverride">The new names for the player.</param>
        public void SetPlayerNameOverride(NwPlayer target, PlayerNameOverride nameOverride)
        {
            globalNameOverrides[target] = nameOverride;
            CacheOriginalNames(target);

            // If we've ran this before the PC has even been added to the other clients' player list then there's
            // nothing else we need to do, the hooks will take care of doing the renames. If we don't skip this
            // then the SendServerToPlayerPlayerList_All in the SendNameUpdate below runs before the server has even ran a
            // SendServerToPlayerPlayerList_Add and weird things happen(tm)
            if (PlayerListNameType != OverrideNameType.Original && renameAddedToPlayerList.Contains(target))
            {
                return;
            }

            SendNameUpdateToAllPlayers(target);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets an override player character name and community name on the player list as observed by a specific player. Is not persistent.
        /// </summary>
        /// <param name="target">The player whose name is being overridden.</param>
        /// <param name="nameOverride">The new names for the player.</param>
        /// <param name="observer">The observer to see the new names.</param>
        public void SetPlayerNameOverride(NwPlayer target, PlayerNameOverride nameOverride, NwPlayer observer)
        {
            if (!perPlayerOverrides.TryGetValue(target, out Dictionary <NwPlayer, PlayerNameOverride>?playerOverrides))
            {
                playerOverrides            = new Dictionary <NwPlayer, PlayerNameOverride>();
                perPlayerOverrides[target] = playerOverrides;
            }

            playerOverrides[observer] = nameOverride;
            CacheOriginalNames(target);

            // If we've ran this before the PC has even been added to the other clients' player list then there's
            // nothing else we need to do, the hooks will take care of doing the renames. If we don't skip this
            // then the SendServerToPlayerPlayerList_All in the SendNameUpdate below runs before the server has even ran a
            // SendServerToPlayerPlayerList_Add and weird things happen(tm)
            if (PlayerListNameType != OverrideNameType.Original && renameAddedToPlayerList.Contains(target))
            {
                return;
            }

            SendNameUpdate(target, observer);
        }