Converting steam identifier to retrieve profile

Hey there guys!

I have been doing some searching on converting the identifiers that get passed through players.json to convert into profile links. I started with steam. I’ll give my steam ID as an example: steam:110000100ae48a3

I’ve run this (minus steam:) through 10-15 steam id convertors and every one views this as an unknown format.

How can I convert this ID into something I can use for a profile link?

Thanks for your time!

You can use the following snippet to get a users SteamID, it also contains the line to convert from Hex to Dec

-- Get a players SteamID
function GetSteamId(source)
    local steamHex = nil
    local identifiers = GetPlayerIdentifiers(source)
    for _, identifier in next, identifiers do
        if string.find(identifier, "steam:") then
            steamHex = identifier
            break
        end
    end
    if not steamHex then
        return false, 0
    end
    if not string.find(steamHex, "steam:") then
        return false, 0
    end
    local steamId = tonumber(string.gsub(steamHex,"steam:", ""),16)
    if not steamId then
        return false, 0
    end
    return true, steamId
end

-- Usage:
local hasSteam, steamId = GetSteamId(source)
if hasSteam then
    -- Do stuff with their steamId
end

The output steamId value in this case would be 76561197971687587 based on your steam:110000100ae48a3 example

Edit: Function now actually iterates over all of the identifiers to find the Steam identifier

2 Likes

… except when Steam isn’t the first identifier.

AKA DON’T USE THIS SNIPPET

and why are you looking for ‘steam id converters’ when you should just convert from hex to decimal

Glitch, thanks so much for the help, I really appreciate it!

From my experience the Steam identifier has never been present if it’s not the first identifier available.
Totally possible that it appears in any random order in the identifiers, but I’ve never experienced that.

If anything it can simply be made to iterate all the licenses to find it

Edit: now it does