Cuberite Forum
Rename player on spawn - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: Rename player on spawn (/thread-2116.html)



Rename player on spawn - DrMasik - 09-17-2015

I'm try to rename player to custom name on spown. But, it's do not work for me.
Code:
cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_SPAWNED, MyOnPlayerSpawned);

function MyOnPlayerSpawned(Player)
  Player:SetCustomName("CustomName");
  Player:SetName("CustomName2");
end



RE: Rename player on spawn - DrMasik - 09-17-2015

When I press <TAB> - i see old player name, but when I list players on server (server console) - I see new player name. Is it bug?


RE: Rename player on spawn - xoft - 09-17-2015

I don't think this is even supposed to work. The SetName() method is only useful before the player is spawned for other players, which I think happens before the PLAYER_SPAWNED hook. SetCustomName() should have worked, though.


RE: Rename player on spawn - xoft - 09-17-2015

In the cPlayer class docs: http://apidocs.cuberite.org/cPlayer.html


RE: Rename player on spawn - DrMasik - 09-17-2015

(09-17-2015, 06:10 AM)xoft Wrote: I don't think this is even supposed to work. The SetName() method is only useful before the player is spawned for other players, which I think happens before the PLAYER_SPAWNED hook. SetCustomName() should have worked, though.

I'm check some time and some combinations and convinced that player not renamed "into" players list. But, other players see new player name after they (not renamed player) reconnect and any operations with player such us kick, kill, etc. work only with new player name.