Type Function
Return value Boolean
Revision Release 2024.3703
Keywords steam, steamworks, requestActivePlayerCount
See also activePlayerCount


Asynchronously fetches the number of people running the application globally from Steam's server, not counting the currently logged in user.

Returns true if the request was successfully sent to Steam. Note that this does not necessarily mean that the requested operation will succeed. For example, this function will return true if there is no Internet connection. So, the listener must check the received event.isError property to determine if the requested operation succeeded.

Returns false if given invalid arguments or if the steamworks.isLoggedOn property is false.


steamworks.requestActivePlayerCount( listener )
listener (required)

Function. Function which will receive the result of the request via an activePlayerCount event.


local steamworks = require( "plugin.steamworks" )

-- Fetch the number of people currently playing this game
local function onReceivedActivePlayerCount( event )
    if ( event.isError ) then
        -- This will likely happen due to lack of Internet access
        print( "Failed to fetch active player count." )
        -- Print current number of people playing this game
        print( "Active Player Count: " .. tostring(event.count) )
steamworks.requestActivePlayerCount( onReceivedActivePlayerCount )