Player.SteamID
From GMod Wiki
Function | |
Syntax | Player:SteamID( ) |
Description: | |
Returns the players Steam ID | |
Returns: | String |
In Object: | Player |
Realm: | |
BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=Player.SteamID]Player.SteamID [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Examples
Description | Prints the SteamID and Community ID of all players in the console. |
---|---|
Used on | |
Code | for _,ply in ipairs( player.GetAll() ) do local stSteamID = string.Explode(":", ply:SteamID()) if (#stSteamID == 3) then local iCommunityID = tonumber(stSteamID[3]) * 2 + 76561197960265728 + tonumber(stSteamID[2]) print( "[" .. ply:GetName() .. "]< SteamID = " .. ply:SteamID() .. " ; Community ID = " .. iCommunityID .. " >" ) else print( "[" .. ply:GetName() .. "]< SteamID = " .. ply:SteamID() .. " ; Community ID = -undefined- >" ) end end |
Output | Calculates and outputs every player's community IDs in the console. A community ID is defined as this. NOTE: Due to Lua's limitations on extremely large numbers this example doesn't actually work. |
Additional Notes
- This is a reliable way to identify a player.
- Bots will always return "BOT"
- May return STEAM_ID_PENDING if the player is still joining
- If you're going to use a SteamID of a player for a filename for file.Write, be aware that SteamIDs contain ":" characters, which cannot be used in filenames. Or you replace those with some other symbols, using string.gsub. UniqueIDs are just numbers, so they CAN be used.
- When this function is serverside and on a single player game this function returns STEAM_0:0:0.