GetPlayerUid
The player’s id on this server - the same at every join from their game, theirs alone.
32 lowercase hex digits, the same every time the player joins this server from the same game install, whatever name they
type. Their game makes it from a secret only that install holds, so another player cannot claim it, and the ids one player has
on two servers have nothing in common. It is there from OnPlayerConnect on - a key for the mode’s own records (characters,
ranks, bans) where it would otherwise ask a password. "" when their game sent none: a join without the launcher’s look at the
server first (a direct join, an older launcher). A new Windows or a wiped app-data folder gives the player a new id; a copy of
the server’s data folder keeps the ids (the server keeps what they are made from in its database).
Syntax
Section titled “Syntax”GetPlayerUid(pid)| Parameter | Type | |
|---|---|---|
pid |
number | the player |
Returns
Section titled “Returns”string - 32 hex digits; "" when none
Example
Section titled “Example”-- a character per player without a password: the id is the keyfunction OnPlayerConnect(pid) local uid = GetPlayerUid(pid) if uid == "" then SendClientMessage(pid, COLOR_RED, "Join through the launcher to keep your character.") return end local row = db:QueryRow("SELECT x, y, z FROM characters WHERE uid = @uid", { uid = uid }) if row then SetPlayerPos(pid, row.x, row.y, row.z) endendSee also
Section titled “See also”GetPlayerByUid · GetPlayerSteamId · GetPlayerName · GetDatabase · the Players group of the index
