What is a UniqueID

I’ve recently switched my server from pointshop’s default storage to the mysql version, and I had a question. The mysql version stores by a UniqueID, found by doing ply:UniqueID. I was wondering what exactly that was, and if there was any way to convert that from UniqueID to a name or SteamID.

Snip, mis-understood the question, ignore me.

http://forum.facepunch.com/showthread.php?t=1253982

Incorrect. What you are thinking of is the community id (steamid64). OP is asking for Player:UniqueID() not Player:SteamID64()

The unique ID is a difficult thing to reverse as it is a CRC hash. You can convert the steam id (STEAM_0:X:Y) to uniqueid in lua using:
[lua]local steamid = “STEAM_0:1:10101”
local uniqueid = util.CRC(“gm_”…steamid…"_gm")[/lua]

I’ve yet to find an easy way to find a steamid from the uniqueid as you cannot unhash a hashed CRC value that I know of.

I don’t know of any way to convert a UniqueID to a SteamID so what I’ve done on my server is keep a record linking a players name<->steamid<->communityid<->uniqueid so I can use one to find any of the others even when players are offline.

That’s one way to do it, use the built in SQLite system to store the info.

You could do that, but I actually I just read/write a big table to/from a file, I didn’t want to clog sv.db with all the information, and lookups can easily be performed by using the given information as a key to the (sub)table. The table itself has a lot of duplicated data, but it’s been fast and no problems so far. It does lack a fast way to search by partial name though.

In your game’s console type:


lua_run_cl print( LocalPlayer():UniqueID() )

This will tell you your own UniqueID. It’s always the same on any server.

Interesting. Thanks guys. I’ll probably end up just adding names and steamids to the table and query, since there doesn’t appear to be a way to convert it to steamid.

Assuming you are using util.JSONToTable and the reverse to store it in the file?

It’s probably not important but I don’t use util.JSONToTable, I use my own function that writes/read the file in binary to save space instead of in plain text.

EDIT: Crap, I did not mean to bump this.