Author Topic: Finding the UniqueID of a player  (Read 2437 times)

0 Members and 1 Guest are viewing this topic.

Offline Smoot178

  • Newbie
  • *
  • Posts: 39
  • Karma: -4
Finding the UniqueID of a player
« on: September 17, 2009, 05:01:04 PM »
Hello again.

I am trying to find the UniqueID of a player like that of which most prop protection, the sui scoreboard, and utime uses to store information.

How can I find it out?

Thanks.

Offline Major_Pain

  • Newbie
  • *
  • Posts: 23
  • Karma: 1
Re: Finding the UniqueID of a player
« Reply #1 on: September 17, 2009, 05:07:00 PM »
Type status into console and it will be the first number in the line that the person's name is in.


Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Finding the UniqueID of a player
« Reply #2 on: September 17, 2009, 05:49:30 PM »
Major Pain is incorrect, you cannot find UniqueIDs that way (He's referring to the EntID, a very different number). You can only look up a unique id from lua. For example, you could execute the following in console:
Code: [Select]
lua_run print( Entity( entid ):UniqueID() )
Where entid is the EntID found using Major Pain's method. You'll see the unique id of the player in question.
Experiencing God's grace one day at a time.

Offline Smoot178

  • Newbie
  • *
  • Posts: 39
  • Karma: -4
Re: Finding the UniqueID of a player
« Reply #3 on: September 17, 2009, 07:10:21 PM »
Thanks, that worked!

Edit: but it didn't work on myself D:

:1: attempt to call method 'UniqueID' (a nil value)
« Last Edit: September 17, 2009, 07:13:41 PM by Smoot178 »

Offline Major_Pain

  • Newbie
  • *
  • Posts: 23
  • Karma: 1
Re: Finding the UniqueID of a player
« Reply #4 on: September 18, 2009, 03:15:28 PM »
My bad, I didn't thing he was talking about lua.

You can also store unique IDs in a table.

Code: [Select]
playersID = {} --Creates the table

function getAllPlayers() --Creates a function
for k,v in pairs(player.GetAll()) do--Makes a variable that stores the players(v)
playersID[v] = v:Nick() --Makes the key of the table the uniqueID and the string their name
end --Ends the for loop
end --Ends the function

concommand.Add( "storeplayers", getAllPlayers) --Creates a console command to store the players IDs in the table by calling the function

Then you could use PrintTable to print the "playersID" table. Like this:
Code: [Select]
lua_run PrintTable(playersID)
It should return the uniqueID on the left and the name of the player on the right.