Page 1 of 1

How to get multiplayer name?

Posted: Tue Nov 03, 2015 5:23 am
by MisterBrownZA
Greetings everyone,

I eventually decided to join the forum - as I can't find any questions/answers relating to my problem.

I'd like to access game.players - multiplayer name for each player who has joined.

I hope someone can help me with this

Re: How to get multiplayer name?

Posted: Tue Nov 03, 2015 8:52 am
by prg
MisterBrownZA wrote:Greetings everyone,

I eventually decided to join the forum - as I can't find any questions/answers relating to my problem.

I'd like to access game.players - multiplayer name for each player who has joined.

I hope someone can help me with this

Code: Select all

for _, v in pairs(game.players) do game.local_player.print(v.name) end

Re: How to get multiplayer name?

Posted: Tue Nov 03, 2015 9:35 am
by MisterBrownZA
prg wrote:

Code: Select all

for _, v in pairs(game.players) do game.local_player.print(v.name) end
Amazing! So easy!

Quick question. I couldn't find local_player.print() method in the wiki, so wasn't sure how I was supposed to do this.

I'll try this when I get home tonight.

I'm guessing v.name returns the player's "get_localised_entity_name"

Re: How to get multiplayer name?

Posted: Tue Nov 03, 2015 10:00 am
by prg
MisterBrownZA wrote:Quick question. I couldn't find local_player.print() method in the wiki, so wasn't sure how I was supposed to do this.
Lua/Game#local_player
Lua/Player#print
MisterBrownZA wrote:I'm guessing v.name returns the player's "get_localised_entity_name"
That contains whatever the player entered in options -> other -> multiplayer username. localised_name is only a thing for entities, like the player's character, but that only ever says "player" so it's not very interesting.

Re: How to get multiplayer name?

Posted: Wed Nov 04, 2015 5:19 am
by MisterBrownZA
prg wrote:
MisterBrownZA wrote:Quick question. I couldn't find local_player.print() method in the wiki, so wasn't sure how I was supposed to do this.
Lua/Game#local_player
Lua/Player#print
MisterBrownZA wrote:I'm guessing v.name returns the player's "get_localised_entity_name"
That contains whatever the player entered in options -> other -> multiplayer username. localised_name is only a thing for entities, like the player's character, but that only ever says "player" so it's not very interesting.
Bravo. Everything worked perfectly!

Thanks a lot prg!