activePlayerCount

类型 事件
修订 版本 2024.3703
关键词 steam, steamworks, activePlayerCount
另请参阅 steamworks.requestActivePlayerCount()
steamworks.*

概述

此事件提供当前正在全球范围内玩游戏的玩家数量,不包括当前登录的用户。

此事件只能由已传递给 steamworks.requestActivePlayerCount() 函数的函数回调接收。

属性

event.count

event.isError

event.name

示例

local steamworks = require( "plugin.steamworks" )

-- Called by the "steamworks.requestActivePlayerCount()" function with the result
local function onReceivedActivePlayerCount( event )
    if ( event.isError ) then
        -- Request failed; typically happens when there is no Internet access
        print( "Failed to fetch number of active players." )
    else
        -- Print the number of active players to the log
        print( "Number of people playing this game: " .. tostring(event.count) )
    end
end

-- Fetch the number of players currently playing this game
-- Requires an active Internet connection to succeed
-- Will provide the requested result to the given function
steamworks.requestActivePlayerCount( onReceivedActivePlayerCount )