steamworks.getUserInfo()

Type Function
Return value UserInfo
Revision Release 2024.3703
Keywords steam, steamworks, getUserInfo
See also steamworks.addEventListener()
steamworks.*

Overview

Returns a UserInfo object. This provides information about one user account such as the profile name, Steam level, online status, etc.

Note

When calling the steamworks.requestLeaderboardEntries() function, user information for each leaderboard entry will be immediately available. Steam may also unload each entry’s user information automatically. So, this information should be fetched immediately when it becomes available.

Gotchas

This function will return nil in the following cases:

Syntax

steamworks.getUserInfo( [userSteamId] )
userSteamId (optional)

String. The unique string ID of the user. The ID will default to the current user if this argument is not provided.

Example

local steamworks = require( "plugin.steamworks" )

-- Called when information about one user has been received or changed
local function onUserInfoUpdated( event )
    -- Print information about the user
    local userInfo = steamworks.getUserInfo( event.userSteamId )
    if ( userInfo ) then
        print( "User Name: " .. userInfo.name )
        print( "User Nickname: " .. userInfo.nickname )
        print( "Steam Level: " .. tostring(userInfo.steamLevel) )
        print( "Status: " .. userInfo.status )
        print( "Relationship: " .. userInfo.relationship )
    end
end

-- Set up a listener to be invoked when user info has been received or changed
steamworks.addEventListener( "userInfoUpdate", onUserInfoUpdated )