1. Hi, i want to change name of player when he connected, but i am stuck. I found this function ChangeNameServer(string playerName, uLink.NetworkMessageInfo info) but OnPlayerConnected hook havent uLink.NetworkMessageInfo.
    Is there way to solve it or pull uLink.NetworkMessageInfo from another type?
     
  2. Wulf

    Wulf Community Admin

    The name isn't stored there, it's under identity.Name.
     
  3. identity.Name change only name in chat. But when you use ChangeNameServer, another players can see new name under player model too
     
  4. Wulf

    Wulf Community Admin

    That would make more sense. So will that work for what you want?
     
  5. Not actualy, because i havent uLink.NetworkMessageInfo in OnPlayerConnected hook
     
  6. Wulf

    Wulf Community Admin

    This should handle what you are looking for:
    Code:
    var newName = "Bob";
    identity.Name = newName;
    var playerEntity = GameManager.GetPlayerEntity(player);
    if (playerEntity != null && identity.Name != newName)
    {
        ChatManager.Instance.AppendNameChangeNotice(identity.Name, newName);
        playerEntity.GetComponent<HurtMonoBehavior>().RPC("UpdateName", uLink.RPCMode.OthersExceptOwnerBuffered, newName);
    }
    The AppendNameChangeNotice is optional, and can be replaced with a custom message sending method instead.
     
  7. I confused, this code is work when i added it to chat command, but when i add it to OnPlayerConnected, its not found PlayerEntity, so the playerEntity ==null
     
  8. Wulf

    Wulf Community Admin

    The player may not have an entity at that point, so you might have to wait for a hook to be added where they do.
     
  9. So i actualy added the timer to OnPlayerConnected and it works fine!
     
  10. Wulf

    Wulf Community Admin

    That would work, but not ideal. ;)