#Get Player ID

5 messages · Page 1 of 1 (latest)

main flicker
#

How to get my own PlayerID. I tried it with "tm.players.CurrentPlayers()" but didn't get what i wanted.
Can someone help me?

glacial copper
#

CurrentPlayers() gives you a list of the IDs of all the players connected to the server. Mods are run server side, so "my own PlayerID" isn't defined as far as the mod is concerned. If you are the host, it's guaranteed to be 0 though

main flicker
#

Ok thanks. But now i get "nil" as an output and if i try to get the name or use the ID in other ways it doesnt work.

local currentplayers = tm.players.CurrentPlayers()
local Name = tm.players.GetPlayerName(currentplayers[0])

i'm sorry about the circumstances for you

glacial copper
#
  1. Lua starts array index at 1
  2. You don't need to use the current players function. The PlayerID of the host is always 0
main flicker
#

Thanks a lot