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?
Solved Changing player name in OnPlayerConnected?
Discussion in 'Hurtworld Development' started by Estex, Dec 10, 2015.
-
Wulf Community Admin
The name isn't stored there, it's under identity.Name.
-
-
Wulf Community Admin
-
Not actualy, because i havent uLink.NetworkMessageInfo in OnPlayerConnected hook
-
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); }
-
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
-
Wulf Community Admin
-
-
Wulf Community Admin