Solved Change name c#

Discussion in 'Rust Development' started by Sir BenSon, Nov 5, 2016.

  1. Hey there,

    its possible to change the BasePlayer.displayName ingame? Not only for Chat (Chat is simple). It must change on kills, too

    Sir
     
  2. i tested it but its broken and lua is not an option for me
     
  3. Try something like this:
    Code:
    using System.Reflection;namespace Oxide.Plugins
    {
        class Name : RustPlugin
        {
            FieldInfo displayName = typeof(BasePlayer).GetField("_displayName", (BindingFlags.Instance | BindingFlags.NonPublic));        [ChatCommand("name")]
            private void NameChange(BasePlayer player, string command, string[] args) =>
                displayName.SetValue(player, "NewName");
        }
    }
    
     
  4. Ah the field in BasePlayer "_displayName" can changed to a string like i want?
     
  5. No, you would change the string "NewName" to the new name you'd like. I haven't tested this yet, by the way.
     
  6. Wulf

    Wulf Community Admin

    You can also easily rename using Covalence: player.Rename(string newName).