Retrieving nickname from SteamID?

Is there any way of doing this, when the player is not in the server?

You could do

function player.GetBySteamID( id )
	for _, ply in pairs(player.GetAll()) do
		if ply:SteamID() == id then
			return ply
	return false

then do

I don’t think that would work if the player has left?

look into the steamworks.* functions

I hate when you fucking retarded people disagree with me for no fucking reason.

(User was banned for this post ("Flaming / Cares about ratings" - Craptasket))

If you don’t mind player names being potentially out of date, you could write their name when they were connected and their steamid to a database/file and then call that.

Alternatively you could use and use the steam api to get their profile in JSON or something.

You will need to use the Steam Web API to get this information when they are not in your server. Can even do it in-game if needed using http.Fetch, and turn the results into a table using util.JSONToTable.

Edit: woops nevermind, turns out steamworks.RequestPlayerInfo works fine clientside, example below will work for a server-side solution though.

Server-side Example
local APIKey = “xxx”;

function GetPlayerSummary( steamid64, callback )

local uri = string.format( "", tostring( APIKey ), tostring( steamid64 ) );

local onSuccess = function( body, len, headers, code )

	local json = (body and util.JSONToTable( tostring( body ) ) or {});

	if( callback ) then

		local tbl = (json.response.players and json.response.players[1] or {});

		callback( tbl );



local onFailure = function( err )

	if( callback ) then

		callback( {} );



http.Fetch( uri, onSuccess, onFailure );


GetPlayerSummary( “76561197978593283”, function( tbl )

PrintTable( tbl );

end );

[del]The steamworks library only works in the menu environment[/del], no need to flame.

That’s a lie. Only some things in the steamworks are menu state only. I flame because people like you think you know everything but you don’t.

Ah my bad then, I didn’t think any steamworks stuff worked from the client once they were ingame, you were correct.

local function GetPlayerName(steamid, fn)
	local max = 5;
	local i = 0;
	local r;
	function r()
		if(steamworks.GetPlayerName(steamid) ~= "[unknown]") then
			local name = steamworks.GetPlayerName(steamid);
			i = i + 1;
			if(i >= max) then fn("[unknown]"); end
			timer.Simple(1, r);
	timer.Simple(1, r);

local function SteamIDTo64(stmd)
	local s = stmd:sub(9, 9);
	local s2 = stmd:sub(11);
	local num = ((s2 + s) * 2);
	return "7656119"..(num + 7960265728); -- deal with it 

GetPlayerName(SteamIDTo64("STEAM_0:0:44950009"), function(name)

You do realize there’s util.SteamIDTo64 now right?

had no idea, thanks

You could do something like this:

for players that have connected; you could also store the list in a file and reload it when the game starts.