Player.SteamID

From GMod Wiki

Jump to: navigation, search
Function
Syntax Player:SteamID( )
Description:
Returns the players Steam ID
Returns: String
In Object: Player
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Player.SteamID]Player.SteamID [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionPrints the SteamID of all players in the console.
Used onNewerShared.png
Code
function PrintSteamIDS()
    for _, v in ipairs( player.GetAll() ) do
        print( v:Nick().."'s SteamID is: "..v:SteamID() ) )
    end
end
OutputConsole spam if there are lots of players.


DescriptionPrints the SteamID and Community ID of all players in the console.
Used onNewerShared.png
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
OutputCalculates 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

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox